From c0c844773922f4089869493c4ea09fe908aa874d Mon Sep 17 00:00:00 2001 From: tomsykes Date: Tue, 10 Nov 2020 15:22:24 +0000 Subject: [PATCH] New equation (#410) Improved tilt calculation --- pio/src/iSpindel.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pio/src/iSpindel.cpp b/pio/src/iSpindel.cpp index 0803264e..dac5d81f 100644 --- a/pio/src/iSpindel.cpp +++ b/pio/src/iSpindel.cpp @@ -845,9 +845,7 @@ float calculateTilt() float _ax = ax; float _ay = ay; float _az = az; - float pitch = (atan2(_ay, sqrt(_ax * _ax + _az * _az))) * 180.0 / M_PI; - float roll = (atan2(_ax, sqrt(_ay * _ay + _az * _az))) * 180.0 / M_PI; - return sqrt(pitch * pitch + roll * roll); + return acos(_az / (sqrt(_ax * _ax + _ay * _ay + _az * _az))) * 180.0 / M_PI; } bool testAccel()