Open chevdor opened 5 years ago
Thanks for pointing that out. Was long time ago since I wrote that. I should find some time to update the whole code. Till that will fix the types.
No worries and thanks for sharing in the first place.
I can tell you I spotted another issue (lost hairs on that one :)) This is an issue that I guess you cannot run into with an 8bit MCU such as the ATmega328 but you will if you use something like an ESP32.
If you happen to test, I suggest testing on the temperature, if you get 250 °C, you know you lost :)
An important fix is to cast to (uint16_t) in locations such as: https://github.com/sqrtmo/GY-85-arduino/blob/master/GY_85.cpp#L157
Then suddenly, all the values match what an Arduino would output.
So around L157, you should find:
axis[0] = (int16_t)((int)(buff[4] << 8) | buff[5]) - g_offx;
axis[1] = (int16_t)((buff[2] << 8) | buff[3]) - g_offy;
axis[2] = (int16_t)((buff[6] << 8) | buff[7]) - g_offz;
axis[3] = (int16_t)((buff[0] << 8) | buff[1]); // temperature
NOTE: I did not check yet if this fixes breaks it on 8 bits MCUs.
Nice work on this lib, thanks for sharing.
In Arduinos such Uno, etc.. an
int
is 8 bits. Life is great. Now using a non 8 bit arch such as an ESP32, it starts getting messy.I think that switching from
int
touint8_t
would stay closer to what the lib should do.