Pressure sensor BMP 085 and I2C


Recommended Posts

The problem is variable casting : variable read/write to I2C are byte, but variables in DAQFactory are double.

So, if I give a double to DF, what he will send as a byte to I2C ?

Reversely, if I get a byte from I2C into a Double, what will be in the double ?

Link to comment
Share on other sites

DAQFactory largely does the casting for you. However, there are cases, mostly in write routines, where you need to make sure the value you are sending is in range. In other words, not sending 256 to a byte value. The easiest way to do this is with what I called artificial type casting. If you take a number and & it with 0xff, you basically are type casting it an unsigned byte:

value & 0xff

Its still a double, its just limited to the range of an unsigned byte. The rest is handled for you. In the reverse, when you are receiving a byte, it will automatically get converted to a double.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.