Skip to content

Commit

Permalink
New equation (#410)
Browse files Browse the repository at this point in the history
Improved tilt calculation
  • Loading branch information
tomsykes authored Nov 10, 2020
1 parent 2054d44 commit c0c8447
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions pio/src/iSpindel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c0c8447

Please sign in to comment.