diff Discovery/Src/data_central.c @ 1007:65d35e66efb9 GasConsumption

Improve compass calibration dialog: The previous calibration dialog showed some "magic" numbers and a 60 second count down. The new version is trying to guide the user through the calibration process: first rotate pitch, then roll and at last yaw angle. A step to the next angle is taken when enough data per angle is collected (change from red to green). To enable the yaw visualization a simple calibration is done while rotating the axis. The function behind the calibration was not modified => the suggested process can be ignored and the same handling as the with old dialog may be applied. With the new process the dialog may be left early. Anyhow it will still be left after 60 seconds and the fine calibration is performed in the same way as before.
author Ideenmodellierer
date Mon, 05 May 2025 21:02:34 +0200
parents 9b418e63dbc2
children 5924a2d1d3ba
line wrap: on
line diff
--- a/Discovery/Src/data_central.c	Sat May 03 17:52:05 2025 +0200
+++ b/Discovery/Src/data_central.c	Mon May 05 21:02:34 2025 +0200
@@ -843,30 +843,33 @@
 {
 	float newTarget = newHeading;
 
-	if(settingsGetPointer()->compassInertia == 0)
+	if((newHeading > 0.0) && (newHeading < 360))
 	{
-		compass_compensated = newHeading;
-	}
-	else
-	{
-		if((compass_compensated > 270.0) && (newHeading < 90.0))		/* transition passing 0 clockwise */
+		if(settingsGetPointer()->compassInertia == 0)
 		{
-			newTarget = newHeading + 360.0;
+			compass_compensated = newHeading;
 		}
+		else
+		{
+			if((compass_compensated > 270.0) && (newHeading < 90.0))		/* transition passing 0 clockwise */
+			{
+				newTarget = newHeading + 360.0;
+			}
 
-		if((compass_compensated < 90.0) && (newHeading > 270.0))		/* transition passing 0 counter clockwise */
-		{
-			newTarget = newHeading - 360.0;
-		}
+			if((compass_compensated < 90.0) && (newHeading > 270.0))		/* transition passing 0 counter clockwise */
+			{
+				newTarget = newHeading - 360.0;
+			}
 
-		compass_compensated = compass_compensated + ((newTarget - compass_compensated) / (COMPASS_FRACTION * (settingsGetPointer()->compassInertia)));
-		if(compass_compensated < 0.0)
-		{
-			compass_compensated += 360.0;
-		}
-		if(compass_compensated >= 360.0)
-		{
-			compass_compensated -= 360.0;
+			compass_compensated = compass_compensated + ((newTarget - compass_compensated) / (COMPASS_FRACTION * (settingsGetPointer()->compassInertia)));
+			if(compass_compensated < 0.0)
+			{
+				compass_compensated += 360.0;
+			}
+			if(compass_compensated >= 360.0)
+			{
+				compass_compensated -= 360.0;
+			}
 		}
 	}
 }