I'm a baffled as to why there's a member function called, convertTo2sComplement(). Integers of any size in C are by definition two's complement already. There's nothing to convert.
Furthermore, the result of convertTo2sComplement() for any negative value is always 2, which is clearly incorrect.
The solution is to remove the function entirely. It's not needed and no other MMA8252 library I've looked at has one. They all just write the uint8_t offset values directly to the appropriate I2C registers.
I'm a baffled as to why there's a member function called, convertTo2sComplement(). Integers of any size in C are by definition two's complement already. There's nothing to convert.
Furthermore, the result of convertTo2sComplement() for any negative value is always 2, which is clearly incorrect.
The solution is to remove the function entirely. It's not needed and no other MMA8252 library I've looked at has one. They all just write the uint8_t offset values directly to the appropriate I2C registers.