- trueAccelerationX = accelerationX - calibrationX;
- trueAccelerationY = accelerationY - calibrationY;
- trueAccelerationZ = accelerationZ - calibrationZ;
+ accelerationX = accelerationX - calibrationX;
+ accelerationX = accelerationY - calibrationY;
+ accelerationX = accelerationZ - calibrationZ;
+
+ // If the function is run the first time, make sure that there
+ // are no differences with previous and current acceleration
+ if (firstRun) {
+ previousAccelerationX = accelerationX;
+ previousAccelerationY = accelerationY;
+ previousAccelerationZ = accelerationZ;
+ firstRun = false;
+ }