pololu / lsm303-arduino

Arduino library for Pololu LSM303 boards
http://www.pololu.com/catalog/product/2124
MIT License
140 stars 137 forks source link

32 bit ARM Fail. #3

Closed se5a closed 12 years ago

se5a commented 12 years ago

code compiles fine, but due to right shift operator gives wrong output. on a 32bit arm platform.

Requires type cast, so the desired 16 bit signed integer is always used: about line 200 in LSM303.cpp in function void LSM303::readAcc(void)

change: a.x = (xha << 8 | xla) >> 4; a.y = (yha << 8 | yla) >> 4; a.z = (zha << 8 | zla) >> 4; to: a.x = (int16_t)(xha << 8 | xla) >> 4; a.y = (int16_t)(yha << 8 | yla) >> 4; a.z = (int16_t)(zha << 8 | zla) >> 4;

kevin-pololu commented 12 years ago

Thanks, this should be fixed as of the latest version.