diff Discovery/Src/t3.c @ 539:d784f281833a

Added inertia simulation for compass heading: In previous version calculated compass values were directly used for visualization of the compass. This causes a fast changing (jumping) of values. With the inertia introduction the compass behalfs more like an analog compass. The final value is reached slowly and the displayed values are more stable. For configuration a new menu item has been added to the compass menu allowing to switch inertia off (default), small and large inertia simulation
author Ideenmodellierer
date Sat, 10 Oct 2020 16:59:18 +0200
parents 0e1db77b2aca
children 6fbf7cd391cb
line wrap: on
line diff
--- a/Discovery/Src/t3.c	Sat Oct 10 13:51:44 2020 +0200
+++ b/Discovery/Src/t3.c	Sat Oct 10 16:59:18 2020 +0200
@@ -697,6 +697,7 @@
 
     /* compass position */
     point_t center;
+    uint16_t heading;
 
     // CVIEW_T3_StopWatch
     SDivetime Stopwatch = {0,0,0,0};
@@ -723,6 +724,15 @@
     tempWinC2Y1 = tXc2->WindowY1;
     tempWinC2Tab = tXc2->WindowTab;
 
+    if(settingsGetPointer()->compassInertia)
+    {
+    	heading = (uint16_t)compass_getCompensated();
+    }
+    else
+    {
+    	heading = (uint16_t)stateUsed->lifeData.compass_heading;
+    }
+
     switch(tX_selection_customview)
     {
     case CVIEW_T3_ApnoeSurfaceInfo:
@@ -905,9 +915,9 @@
         center.y = 116;
         snprintf(text,TEXTSIZE,"\032\f%c%c",TXT_2BYTE, TXT2BYTE_Compass);
         GFX_write_string(&FontT42,tXc1,text,0);
-        snprintf(text,100,"\030\003%03i`",(uint16_t)stateUsed->lifeData.compass_heading);
+        snprintf(text,100,"\030\003%03i`",heading);
         GFX_write_string(&FontT105,tXc1,text,0);
-        t3_basics_compass(tXscreen, center, (uint16_t)stateUsed->lifeData.compass_heading, stateUsed->diveSettings.compassHeading);
+        t3_basics_compass(tXscreen, center, heading, stateUsed->diveSettings.compassHeading);
         break;
 
     case CVIEW_T3_Decostop:
@@ -1103,10 +1113,9 @@
 
         snprintf(text,TEXTSIZE,"\032\f%c%c",TXT_2BYTE, TXT2BYTE_Compass);
         GFX_write_string(&FontT42,tXc1,text,0);
-        //snprintf(text,100,"\030\003%03i`",(uint16_t)stateUsed->lifeData.compass_heading);
-        snprintf(text,100,"\030%03i`",(uint16_t)stateUsed->lifeData.compass_heading);
+        snprintf(text,100,"\030%03i`",heading);
         GFX_write_string(&FontT144,tXc1,text,0);
-        t3_basics_compass(tXscreen, center, (uint16_t)stateUsed->lifeData.compass_heading, stateUsed->diveSettings.compassHeading);
+        t3_basics_compass(tXscreen, center, heading, stateUsed->diveSettings.compassHeading);
 
     	break;