Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Nick_W

Pages: 1 2 [3] 4
31
mc-Module / Modules drop off network
« on: September 09, 2016, 09:01:27 am »
Hi,

I have had several modules running now for some time. I have noticed the following behavior:

Module 1, which has been running continuously for many days, transmits data and beacons normally. It is running a very simple program, which transmits every 10 seconds. Range to the gateway does not seem to be a factor, as this is actually the module furthest away from the gateway.

Module 2, is close to Module 1, and is running a complicated sensor program, using the external BME280 sensor, it also transmits every 10 seconds. Occasionally this module reboots (I transmit boot messages), and sometimes the beacons disappear for a while, but then re-appear later. So question, why would beacons stop and start? I can understand rebooting (perhaps a bug in my program, or memory error, Watchdog reset etc).

The real problem is Module 3, which is currently a door open/close sensor, and hence has to be reliable. It is running a complicated program, that uses the accelerometer to detect door knocks. It is closest to the gateway, but I have noticed over a few days operation that it will stop sending for a while. It currently transmits door status every 1 minute. What seems to happen is that updates stop, but beacons continue. The beacon data does not update however - indicating to me that the program has stopped (not just the transmitting). Then, some time later (minutes to hours) the module reboots, and starts transmitting again. I just observed this, and at the time of the reset, the beacons stopped sending. So now it is transmitting data once per minute, but no beacons! Battery voltage is currently 2.6V, so it's running down slightly.

My ultimate plan is for the door sensor not to transmit every minute (to save power) but to use the beacon to send status, actual transmissions would only happen on an event (such as door open, door knock detected etc). The problem is that data transmissions are unreliable, and now the beacons seem unreliable also.

Quick follow up - as soon as I transmitted to the module (sent an enable knock sensor message), the beacons reappeared! I may be wrong about the beacons data not updating - there is a bug which makes this appear to be the case. Fixing that now...

My code is here https://github.com/NickWaterton/mcScript/tree/master/projects/DoorSensor
You need the MQTT and MMA8652 libraries from the same repository (in libraries) for the project.

Maybe you could take a look to see if I have something wrong, or to see if you get the same behavior. No external hardware required, should work as is on a standard module (110 I'm using). You'll need a magnet to simulate a door open/close (I have mine on an actual door).

Let me know what you think...

32
mc-Product General / Where I'm keeping my Code
« on: September 02, 2016, 05:10:21 pm »
Until we have the Github site here figure out (and maybe even after that), all my stuff is located at:
https://github.com/NickWaterton

The structure is not great, and things that are there and have the same name as on the mcThings GitHub site are probably NOT the same. I have changed a lot of stuff (examples too) and re-written some of the libraries (the accelerator library for instance is re-written).

Feel free to use it, no guarantees that there aren't any bugs, it's all a work in progress.  ;D

33
mc-Module / How to construct a Signed Short from Bytes
« on: September 02, 2016, 04:59:14 pm »
I had some problems making a signed Short from two bytes (in a ListOfBytes). As a Short is signed, I thought the result would be signed by default - well it isn't!

This was my code:

Code: [Select]
    //**************************************************************************/
    //
    //    @brief  Reads a signed 16 bit value over I2C
    //
    //**************************************************************************/
    Public Function readS16(reg As Byte) As Integer //should return Short
        Dim result As Short = 0
        Dim value As ListOfByte = read2X8(reg)
        If value <> Nothing Then
            result = (value(0) << 8) | value(1)
            //result = value.ExtractShort(0, Endianness.Big) //not working
        End If
        Return result
    End Function

So first ExtractShort() doesn't work (although this does exactly what I want - I think). The above always returns an unsigned Short (as Integer). Even if you change the return type to Short, it still returns an unsigned Short (or Integer, not sure which).

To make it a Signed Short (or Integer) I had to manually convert it to two's compliment:

Code: [Select]
    //**************************************************************************/
    //
    //    @brief  Reads a signed 16 bit value over I2C
    //
    //**************************************************************************/
    Public Function readS16(reg As Byte) As Integer //should return Short
        Dim result As Short = 0
        Dim value As ListOfByte = read2X8(reg)
        If value <> Nothing Then
            result = (value(0) << 8) | value(1)
            //result = value.ExtractShort(0, Endianness.Big) //not working
        End If
        //convert value to 2's compliment
        If (value(0) > 0x7f) Then
            result = (~result + 1) * (-1)
        End If
        Return result
    End Function

Just thought I would point this out for anyone manipulating bytes out there. Anyone know how to use ExtractShort() or why it doesn't work in the above?

Thanks,

34
mc-Module / Data Type Gotcha!
« on: September 02, 2016, 04:51:03 pm »
I recently made an error that had me puzzled for a while. It didn't generate any compiler errors, or run time errors, it just gives wildly incorrect values.

What I did was assign an integer plus a float to an integer (stupid I know).

Here is the example:

Code: [Select]
Dim Temp_Sample_Time As Integer = (2 * getTemperaturesamplingValue()) + 0.5

Even if you do this:
Code: [Select]
Dim Temp_Sample_Time As Integer = ((2 * getTemperaturesamplingValue()) + 0.5).ToInteger
or this:
Code: [Select]
Dim Temp_Sample_Time As Integer = ((2 * getTemperaturesamplingValue().ToFloat) + 0.5).ToInteger
It doesn't work (but no errors).

Converting a Float to Integer using Float.ToInteger gives weird results (i'm sure it make sense from a bitwise point of view).

getTemperaturesamplingValue() returns an Integer in the range 0 to 16. The above code set "Temp_Sample_Time" to some huge number, and sent the program off into neverland.

Code: [Select]
Dim Temp_Sample_Time As Float = (2 * getTemperaturesamplingValue()) + 0.5

The above is correct (although I re-wrote this differently in the end).

Just a note to the wise.

35
mc-Module / User bytes in beacon Issue
« on: August 31, 2016, 08:22:28 pm »
Hi,

As you may be aware, I have been experimenting with encoding information in the "user bytes" (4 of them) in the beacon. An excellent way of extending battery life.

Mc-Abe commented elsewhere
Quote

3: This was missed in the release notes. If there is no data in the beacon, it sends the version/type of module, this was mostly meant to be used by us to provide support but here is an explanation of the format for your reference:
Code: [Select]
byte[0] = 0x01 ------------------> Device Type for mcMod110
byte[1] = 0x07 = 7 ----------+
byte[2..3] = 0x016D = 365----+---> 0.7-365

Which I did note, but did not realize that byte 1 was the module type.

This new feature now makes embedding data in the "User Bytes" difficult, as I have no way of telling if a module is publishing my data or yours.

If these are indeed "User Bytes" then you should not be publishing anything in them, as they are reserved for the user.

I also believe this information is redundant, as the module type and version are published in other beacons (at least they were displayed before the "User Bytes" started carrying this information.

Can I ask that this feature be removed? So that we can have the user bytes back? Or add a way (another byte?) for us to tell if the bytes contain user data or system data.

The problem is that when a module boots, I will interpret its data as some valid (but wrong) value, until the first valid data is loaded into the beacon. This is inconsistent behavior for something defined as "User Bytes".

Thanks.

36
mc-Module / New mcStudio 7-897
« on: August 31, 2016, 07:35:46 am »
Great I can compile again!

The new "manual compile" feature is very welcome (project properties). I can now edit without "laggy" performance. The behavior seems odd though.

If I check "manual compile", then compiling (manual or not) does not seem to work. For example, usually when you click on "Build Application" you get output (in the "output" tab) that says "Build Successful". Now you get nothing. If you try to "Load and Save program in device" then it won't as it says "You are unable to load due to compiler errors".

If I uncheck "manual compile", then all works normally (ie you get the "Build Successful" output and you can program the modules").

So I'll edit with manual compile checked, and load with it unchecked. I don't think it's supposed to work this way though.

Thanks,

37
mc-Module / New module firmware 7-368 problem
« on: August 31, 2016, 07:26:30 am »
Just downloaded and installed all the new firmware/software

There seems to be a problem with module 110 F/W V 7-368. I have loaded it into 3 modules, and in all cases, the modules boot, then stop responding (I get beacons only). After a few minutes, they hang. I believe they hang as I flash the green LED briefly when publishing, and the green LED comes on and stays on.

This happens no matter what program I use (small or large).

I have reverted to F/W 7-366 which works without problems.

You might want to take a look.

38
mc-Module / Problem with Const variables in a class
« on: August 28, 2016, 05:45:56 pm »
I have been writing a library for the accelerometer. This uses lots of bitmasks.

Originally I defined these as Const - for example Const FS_MASK As Byte =0x03

What I found is that you can't refer to this constant outside the class (say from another class), it acts like a Private Constant, not a Shared Constant. Do you have to refer to the base class? Rather than an instance of the class?

Ie BASE.FS_MASK vs instance.FS_MASK. Not sure why this would matter, it's a constant so the two would be the same.

As a workaround I redefined them as Readonly variables (which works fine).

Is this how it works?

Thanks,

39
mc-Module / How to measure elapsed time
« on: August 28, 2016, 05:30:28 pm »
Is there a function like the Arduino millis or micros function?

I'm asking so that I can time events, ie store millis for event, then if it happens again within a window of time take action.

I realize there is Device.Uptime() but that only gives a resolution of seconds.

Thanks,

40
mc-Module / Build Failure Message "Internal Error Instr Type*1024"
« on: August 23, 2016, 12:27:45 pm »
I have a completed BME280 Library, which shows no errors in mcStudio, but fails to bulid with the error "Internal Error Instr Type*1024".

I'm not sure what this is - is it a memory error (the library is quite big)?

Thanks,

41
mc-Module / Odd beacon Behaviour
« on: August 21, 2016, 10:01:51 am »
I am trying to put data into the 4 beacon bytes available (so I don't have to publish via MQTT so much).

I have found some odd things:

This is my code for publishing beacon data:

Code: [Select]
    //**************************************************************************/
    //*!
    //    Encodes Float or Integer into 4 bytes of beacon data
    //    encoding is - byte 0 is data type (numeric value)
    //    Integer as Short (2 bytes)
    //    Fraction as byte (1 byte)
    //*/
    //**************************************************************************/
    Shared Sub BeaconPublish(data_Type As Byte, value As Object)
        Dim fraction As Byte = 0
        Dim data As Short = 0
        If value Is Float Then
            data = value.Cast(Float).ToShort() //get integer part (16 bit only)
            fraction = ((value.Cast(Float) - data) * 100.0).ToByte()
        ElseIf value Is Integer Then
            data = value.Cast(Integer).ToShort() //get integer part (16 bit only)
        ElseIf value Is Short Then
            data = value.Cast(Short)
        ElseIf value Is Byte Then
            data = value.Cast(Byte).ToShort() //get integer part (16 bit only)
        End If
        Dim beaconData As ListOfByte = New ListOfByte()
        beaconData.Add(data_Type)
        beaconData.AddShort(data)
        beaconData.Add(fraction)
        Lplan.SetBeaconData(beaconData)
        Lplan.SendBeacon()
        //Lplan.BeaconNow () //does not seem to work
    End Sub

This is what I receive and decode. Mostly it works, then sometimes I get the first three bytes repeated in the beacon data, sometimes just second and third (this gives the -17.67 result which is bogus)

Code: [Select]
10:33:59.868 [INFO ] [org.openhab.model.script.error:53   ] - Beacon Bytes:  EF:BF:BD:11:01:00:05:22:00:12:EF:BF:BD:2E:13:01:00:
10:33:59.943 [INFO ] [org.openhab.model.script.error:53   ] - bytes[6] = 5
10:34:01.321 [INFO ] [org.openhab.model.script.error:53   ] - Decoded Bytes:  Humidity 34.18000000 05:22:00:12
10:34:38.226 [INFO ] [org.openhab.model.script.error:53   ] - Beacon Bytes:  EF:BF:BD:11:01:00:08:EF:BF:BD:01:1C:EF:BF:BD:2E:13:01:00:
10:34:38.227 [INFO ] [org.openhab.model.script.error:53   ] - bytes[6] = 8
10:34:38.407 [INFO ] [org.openhab.model.script.error:53   ] - Decoded Bytes:  Altitude -17.67000000 08:EF:BF:BD
10:34:48.637 [INFO ] [org.openhab.model.script.error:53   ] - Beacon Bytes:  EF:BF:BD:11:01:00:01:EF:BF:BD:01:00:EF:BF:BD:2E:13:01:00:
10:34:48.718 [INFO ] [org.openhab.model.script.error:53   ] - bytes[6] = 1
10:34:49.918 [INFO ] [org.openhab.model.script.error:53   ] - Decoded Bytes:  Uptime -17.67000000 01:EF:BF:BD


Also, according to the documentation Lplan.SendBeacon() should accept a ListOfBytes as data - but it doesn't. In fact seems to do nothing.
Lplan.BeaconNow () is Documented, but does not seem to exist.

It would be helpful if we could send 5 bytes - then I could send 1 byte as data type, then 4 bytes as the data (as all numeric types are stored as 4 bytes), instead I have to fit 4 bytes of data into 3. Not a big problem as I'm publishing environmental data, so +/- 32k is plenty for temperature, humidity, pressure etc. Just saying...

Is this behavior a bug?

42
mc-Module / Odd Memory Behaviour
« on: August 17, 2016, 12:28:00 pm »
Hi,

I have observed some strange behavior with memory.

Now I realize that memory is managed by the GarbageCollector, which runs when memory is low. Not sure what is defined as "low", but if I have a small program, really doing nothing but publishing uptime and battery/memory levels, then memory gradually drops (2-300 bytes at a time) until it hits less than 1k or so, then there is a pause, and the the program continues with 15k free again (Garbage Collection activity I assume).

If I add in a new object (Temperature sensor) every event cycle - as a local variable, memory drops by 500 bytes or so every cycle, until it gets "low", then the module resets.

the output looks like this:

Code: [Select]
MCThings/000111BA/Count 23
MCThings/000111BA/Temperature 26.500000
MCThings/000111BA/Uptime 190
MCThings/000111BA/BatteryVoltage 2823
MCThings/000111BA/FreeMemory 1676
MCThings/000111BA/Count 25
MCThings/000111BA/Temperature 26.500000
MCThings/000111BA/Uptime 201
MCThings/000111BA/BatteryVoltage 2823
MCThings/000111BA/FreeMemory 976
MCThings/000111BA/Count 26
MCThings/000111BC/Uptime 12663
MCThings/000111BA/Temperature 26.500000
MCThings/000111BA/Uptime 211
MCThings/000111BA/BatteryVoltage 2823
MCThings/000111BA/FreeMemory 280
MCThings/000111BA/Count 27
MCThings/000111BA/Status Booted
MCThings/000111BA/Temperature 26.500000
MCThings/000111BA/Uptime 0
MCThings/000111BA/BatteryVoltage 2612
MCThings/000111BA/FreeMemory 15072
MCThings/000111BA/Count 6
MCThings/000111BA/Temperature 26.562500
MCThings/000111BA/Uptime 10
MCThings/000111BA/BatteryVoltage 2601
MCThings/000111BA/FreeMemory 14360
MCThings/000111BA/Count 7


Now this memory management system is weird (I'm used to local variables being released when out of scope), but it seems that the module is running out of memory before Garbage collection can free up some RAM - hence the reset.

There is no way to "Delete" or "free" an object, but I can manually run Garbage Collection.

Is this normal behavior? Do I need to manually run GarbageCollection when memory is low? this isn't the "automatic" memory management I was expecting...

43
mc-Module / Problems with I2c configuration
« on: August 17, 2016, 09:42:58 am »
I'm having some problems with my BME280 module, so I tried some experiments with the internal Temperature Sensor (to eliminate external errors).

I don't seem to be able to define an I2c object as shared (might not be just I2c, but this is what I am testing).

For example, this code works (the MQTT class just makes MQTT stuff easier):

Code: [Select]
Class MQTT
    Shared mcUIDString As String
   
    Shared Sub Publish(topic As String, value As String)
        If mcUIDString = Nothing Then
            mcUIDString = Device.mcUID().ToString("X8")
        End If
        Dim text_string As ListOfByte = New ListOfByte()
        text_string.Add(value)
        Lplan.Publish("MCThings/" + mcUIDString + "/" + topic, text_string)
    End Sub
   
    Shared Sub Publish(topic As String, value As Object)
        Dim text As String = value.ToString()
        If mcUIDString = Nothing Then
            mcUIDString = Device.mcUID().ToString("X8")
        End If
        Dim text_string As ListOfByte = New ListOfByte()
        text_string.Add(text)
        Lplan.Publish("MCThings/" + mcUIDString + "/" + topic, text_string)
    End Sub
   
    Shared Sub Publish_exact(topic As String, text As String)
        Dim text_String As ListOfByte = New ListOfByte()
        text_String.Add(text)
        Lplan.Publish(topic, text_String)
    End Sub
   
    Shared Sub BeaconPublish(data_Type As Byte, data As Integer)
        data = data & 0x0fffffff //blank top byte (can only send 24 bits maximum)
        Dim hi_byte As Byte = ((data >> 16) & 0xff).ToByte()
        Dim mid_byte As Byte = ((data >> 8) & 0xff).ToByte()
        Dim low_byte As Byte = (data & 0xff).ToByte()
        Dim beconData As ListOfByte = New ListOfByte()
        beconData.Add(data_Type)
        beconData.Add(hi_byte)
        beconData.Add(mid_byte)
        beconData.Add(low_byte)
        Lplan.SetBeaconData(beconData)
        Lplan.SendBeacon()
    End Sub
   
    Shared Sub Subscribe(topic As String)
        Lplan.Subscribe(topic)
    End Sub
   
End Class

Class Main
   
    //Shared Internal_Temp As TempSensor
    Shared booted As Boolean
    Shared count As Integer
   
    Shared Event Boot()
       
        booted = True
        count = 5
        //Internal_Temp = New TempSensor()
       
    End Event
   
    Shared Event Publish_Values() RaiseEvent Every 10 Seconds
        LedGreen = True
       
        If booted Then
            MQTT.Publish("Status", "Booted")
            booted = False
        End If   
       
        Dim Internal_Temp As TempSensor = New TempSensor()
        Dim TempC As Float = Internal_Temp.GetTemp()
        MQTT.Publish("Temperature", TempC)
        Dim Uptime As Integer = Device.Uptime()
        MQTT.Publish("Uptime", Uptime)
        Dim BattVolt As Integer = Device.BatteryVoltage()
        MQTT.Publish("BatteryVoltage", BattVolt)
        count = count + 1
        MQTT.Publish("Count", count)
       
        LedGreen = False
    End Event 
End Class

Class TempSensor
    // Function returns the temperature in degree celcius or
    // Float.NaN if something is wrong
   
    Public sensor As I2c
   
    Public Sub New()
        sensor = I2c.Create(400000, Pin.SCL, Pin.SDA, 0x48)
    End Sub
   
    Public Function GetTemp() As Float
        // Define the properties of the I2C peripheral and device address
        //Dim sensor As I2c
        //sensor = I2c.Create(400000, Pin.SCL, Pin.SDA, 0x48)
       
        // Power up the sensor and give it some time to settle
        Device.EnableTempSensor()
        Thread.Sleep(40000) // See page 13 of the datasheet
       
        // Read the sensor (only 2 bytes to read
        Dim res As ListOfByte = sensor.Read(2)
       
        // See Tmp102 documentation how to interpret the data (page 8)
        Dim temp As Float = Float.NaN
        If res <> Nothing Then
            // Shift the partial part to the right nibble
            Dim part As Float = res(1) >> 4
            // Temperature partial is 1/16*n where n is between 0 and 15           
            part = part / 16
            // Sign extend the byte to an integer
            temp = res(0).SignExtend() + part
        Else
            LedRed = True
            Thread.Sleep(50000)
            LedRed = False
        End If
       
        // power off
        Device.DisableTempSensor()
        Return temp
    End Function
   
    Shared Function GetDieTemp() As Float
        // Just get the temperature and return
        Return Device.TempDie
    End Function
   
    Shared Function ToFarenheit(celcius As Float) As Float
        Return (celcius * 9) / 5 + 32
    End Function
   
    Shared Function ToCelcius(farenheit As Float) As Float
        Return (farenheit - 32) * 5 / 9
    End Function
   
End Class

Note the "Dim Internal_Temp As TempSensor = New TempSensor()" in Class Main.

If I Try to Make this a shared variable of class main, it causes the module to reset. This does not work:

Code: [Select]
Class MQTT
    Shared mcUIDString As String
   
    Shared Sub Publish(topic As String, value As String)
        If mcUIDString = Nothing Then
            mcUIDString = Device.mcUID().ToString("X8")
        End If
        Dim text_string As ListOfByte = New ListOfByte()
        text_string.Add(value)
        Lplan.Publish("MCThings/" + mcUIDString + "/" + topic, text_string)
    End Sub
   
    Shared Sub Publish(topic As String, value As Object)
        Dim text As String = value.ToString()
        If mcUIDString = Nothing Then
            mcUIDString = Device.mcUID().ToString("X8")
        End If
        Dim text_string As ListOfByte = New ListOfByte()
        text_string.Add(text)
        Lplan.Publish("MCThings/" + mcUIDString + "/" + topic, text_string)
    End Sub
   
    Shared Sub Publish_exact(topic As String, text As String)
        Dim text_String As ListOfByte = New ListOfByte()
        text_String.Add(text)
        Lplan.Publish(topic, text_String)
    End Sub
   
    Shared Sub BeaconPublish(data_Type As Byte, data As Integer)
        data = data & 0x0fffffff //blank top byte (can only send 24 bits maximum)
        Dim hi_byte As Byte = ((data >> 16) & 0xff).ToByte()
        Dim mid_byte As Byte = ((data >> 8) & 0xff).ToByte()
        Dim low_byte As Byte = (data & 0xff).ToByte()
        Dim beconData As ListOfByte = New ListOfByte()
        beconData.Add(data_Type)
        beconData.Add(hi_byte)
        beconData.Add(mid_byte)
        beconData.Add(low_byte)
        Lplan.SetBeaconData(beconData)
        Lplan.SendBeacon()
    End Sub
   
    Shared Sub Subscribe(topic As String)
        Lplan.Subscribe(topic)
    End Sub
   
End Class

Class Main
   
    Shared Internal_Temp As TempSensor
    Shared booted As Boolean
    Shared count As Integer
   
    Shared Event Boot()
       
        booted = True
        count = 5
        Internal_Temp = New TempSensor()
       
    End Event
   
    Shared Event Publish_Values() RaiseEvent Every 10 Seconds
        LedGreen = True
       
        If booted Then
            MQTT.Publish("Status", "Booted")
            booted = False
        End If   
       
        //Dim Internal_Temp As TempSensor = New TempSensor()
        Dim TempC As Float = Internal_Temp.GetTemp()
        MQTT.Publish("Temperature", TempC)
        Dim Uptime As Integer = Device.Uptime()
        MQTT.Publish("Uptime", Uptime)
        Dim BattVolt As Integer = Device.BatteryVoltage()
        MQTT.Publish("BatteryVoltage", BattVolt)
        count = count + 1
        MQTT.Publish("Count", count)
       
        LedGreen = False
    End Event 
End Class

Class TempSensor
    // Function returns the temperature in degree celcius or
    // Float.NaN if something is wrong
   
    Public sensor As I2c
   
    Public Sub New()
        sensor = I2c.Create(400000, Pin.SCL, Pin.SDA, 0x48)
    End Sub
   
    Public Function GetTemp() As Float
        // Define the properties of the I2C peripheral and device address
        //Dim sensor As I2c
        //sensor = I2c.Create(400000, Pin.SCL, Pin.SDA, 0x48)
       
        // Power up the sensor and give it some time to settle
        Device.EnableTempSensor()
        Thread.Sleep(40000) // See page 13 of the datasheet
       
        // Read the sensor (only 2 bytes to read
        Dim res As ListOfByte = sensor.Read(2)
       
        // See Tmp102 documentation how to interpret the data (page 8)
        Dim temp As Float = Float.NaN
        If res <> Nothing Then
            // Shift the partial part to the right nibble
            Dim part As Float = res(1) >> 4
            // Temperature partial is 1/16*n where n is between 0 and 15           
            part = part / 16
            // Sign extend the byte to an integer
            temp = res(0).SignExtend() + part
        Else
            LedRed = True
            Thread.Sleep(50000)
            LedRed = False
        End If
       
        // power off
        Device.DisableTempSensor()
        Return temp
    End Function
   
    Shared Function GetDieTemp() As Float
        // Just get the temperature and return
        Return Device.TempDie
    End Function
   
    Shared Function ToFarenheit(celcius As Float) As Float
        Return (celcius * 9) / 5 + 32
    End Function
   
    Shared Function ToCelcius(farenheit As Float) As Float
        Return (farenheit - 32) * 5 / 9
    End Function
   
End Class

So if I change Internal_sensor from a local variable to a Shared variable, the module resets. What am I doing wrong? The TempSensor object should be created at boot, and should persist as a shared variable of class Main, but I'm guessing from the resets, it is being destroyed. No errors in MCStudio, and builds fine.

I'm wanting to do this as I want to create a BME280 object (one per sensor), but it seems that I have to create a new object every time I want to use it. I can't make a persistent I2C object.

Any suggestions would be appreciated.

44
mc-Studio / Turn Off Auto Syntax Checking?
« on: July 28, 2016, 05:33:03 pm »
Is there a way to turn off the auto syntax checking?

Every time I type 3 or so characters, the whole thing pauses for 10-15 seconds to check the syntax (and give an error as I haven't finished typing). It's incredibly painful (no I don't have the fastest computer).

I've been entering code in Notepad+ as it's much easier, then starting mc-Studio, but I can't even make simple changes without long pauses, or exiting and restarting mc-Studio.

It would be better to disable this, and have a manual push to check, or check on build system.

This makes the editor unusable for me. Please tell me there is a way to turn this off!

45
mc-Module / How to do power of calculations
« on: July 27, 2016, 10:26:30 am »
Hi,

I'm trying to calculate a "power of" value using floats.

The calculation involves pressure (variables are Floats) and has this in it: (atmospheric / seaLevel) ^ 0.1903

The error is "Operand(0) is not a byte, short, or Integer in bit-wise Xor (^)"

Now, the bitwise operator is ^ but the power of operator is also ^, and I want the power-of operator. How does VB.Net type languages differentiate?

In C I use pow(A, B) where I want A^B (to the power of, not bit-wise).

What's the equivalent?

Thanks,

Pages: 1 2 [3] 4