diff Small_CPU/Src/compass.c @ 1010:08f76d3e9856 GasConsumption

Bugfix: Pitch compensation The pitch was not calculated correct during calibration process. As result the heading value is sensetive to pitch movment. The issue has been solved by applying the correct formular for calculation.
author Ideenmodellierer
date Tue, 06 May 2025 22:07:39 +0200
parents 65d35e66efb9
children
line wrap: on
line diff
--- a/Small_CPU/Src/compass.c	Tue May 06 12:57:33 2025 +0200
+++ b/Small_CPU/Src/compass.c	Tue May 06 22:07:39 2025 +0200
@@ -1107,7 +1107,7 @@
 	sinPhi = sinf(Phi);
 	cosPhi = cosf(Phi);
 
-	Teta = atan2((double)accel_DX_f, sqrt((double)accel_DY_f * accel_DY_f + (double)accel_DZ_f * accel_DZ_f));
+	Teta = atanf(-(float)accel_DX_f/(accel_DY_f * sinPhi + accel_DZ_f * cosPhi));
 	compass_pitch = Teta * (180.0 / PI);
 
 	sinTeta = sinf(Teta);