-
Couldn't load subscription status.
- Fork 118
Description
Hi, that code by loveelectronics.co.uk (it does not exist anymore) has sadly a bug.
The Wire.beginTransmission() and Wire.endTransmission() should not be used with Wire.requestFrom(). They are only used when writing data.
In the file "arduino/libraries/love_ADXL345/love_ADXL345.cpp" in the function Read(), those are used around the Wire.requestFrom(), those Wire.beginTransmission() and Wire.endTransmission() can be removed.
In the function Read(), the buffer is created on the stack, and a pointer to that buffer is returned. That is a bug. The scope of that buffer is only inside the function. As soon as the function returns, that buffer is no longer valid.