MPU6050_light icon indicating copy to clipboard operation
MPU6050_light copied to clipboard

'long' should be 'unsigned long' for millis value.

Open Koepel opened this issue 3 years ago • 0 comments

To avoid the rollover problem, the variable to store a millis value in should be 'unsigned long'.

In "MPU6050_light.h", the preInterval should be unsigned long. In the example "GetAllData.ino", the timer should be unsigned long.

There are a few minor things:

Could you use spaces instead of tabs ? Both are used and the indents are not the same. A millis timer is: if (currentMillis - previousMillis >= interval) {. Could you change the > into >= in the example "GetAllData.ino" ?

This is trickery code:

accZ = (!upsideDownMounting - upsideDownMounting) * ((float)rawData[2]) / acc_lsb_to_g - accZoffset;

Please use normal code:

accZ = ((float)rawData[2]) / acc_lsb_to_g - accZoffset;
if (upsideDownMounting)
  accZ = -accZ;

Koepel avatar Jun 25 '21 07:06 Koepel