Hi guys, I'm using the magnetometer of LSm303agr, but I have some doubts about how to interpret the data.
Hi guys,
I'm using the magnetometer of LSm303agr, but I have some doubts about how to interpret the data. Let me explain below:
I know that LSm303agr returns magnetometer coordinates in two bytes (MSB, LSB) each one. Is it correct this conversion to get the coordinates as int16?
Thank you in advance.
int16_t X_MAG, Y_MAG, Z_MAG;
X_MAG = (int16_t)(i2c_ByteRead(0x3D, 0x69) << 8) | i2c_ByteRead(0x3D, 0x68);
Y_MAG = (int16_t)(i2c_ByteRead(0x3D, 0x6B) << 8) | i2c_ByteRead(0x3D, 0x6A);
Z_MAG = (int16_t)(i2c_ByteRead(0x3D, 0x6D) << 8) | i2c_ByteRead(0x3D, 0x6C);