diff Discovery/Src/t7.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 0ad0b26ec56b
children 43a2dd4ba30f
line wrap: on
line diff
--- a/Discovery/Src/t7.c	Sat Oct 10 13:51:44 2020 +0200
+++ b/Discovery/Src/t7.c	Sat Oct 10 16:59:18 2020 +0200
@@ -1634,6 +1634,7 @@
 
     char text[256];
     uint16_t textpointer = 0;
+    uint16_t heading = 0;
     int16_t start;
     uint8_t lineCountCustomtext = 0;
     int16_t shiftWindowY0;
@@ -1677,15 +1678,6 @@
     case CVIEW_CompassDebug:
         snprintf(text,100,"\032\f\001Compass raw");
         GFX_write_string(&FontT42,&t7cH,text,0);
-/*
-        pStateReal->lifeData.compass_heading = dataIn.data[dataIn.boolCompassData].compass_heading;
-        pStateReal->lifeData.compass_roll = dataIn.data[dataIn.boolCompassData].compass_roll;
-        pStateReal->lifeData.compass_pitch = dataIn.data[dataIn.boolCompassData].compass_pitch;
-
-        pStateReal->lifeData.compass_DX_f = dataIn.data[dataIn.boolCompassData].compass_DX_f;
-        pStateReal->lifeData.compass_DY_f = dataIn.data[dataIn.boolCompassData].compass_DY_f;
-        pStateReal->lifeData.compass_DZ_f = dataIn.data[dataIn.boolCompassData].compass_DZ_f;
-*/
         snprintf(text,255,"%1.1f\n\r%1.1f\n\r%1.1f\n\r%i\n\r%i\n\r%i"
                     ,stateUsed->lifeData.compass_heading
                     ,stateUsed->lifeData.compass_roll
@@ -1978,9 +1970,18 @@
 
     case CVIEW_Compass:
     default:
+
+	    if(pSettings->compassInertia)
+	    {
+	    	heading = (uint16_t)compass_getCompensated();
+	    }
+	    else
+	    {
+	    	heading = (uint16_t)stateUsed->lifeData.compass_heading;
+	    }
         snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE, TXT2BYTE_Compass);
         GFX_write_string(&FontT42,&t7cH,text,0);
-        t7_compass((uint16_t)stateUsed->lifeData.compass_heading, stateUsed->diveSettings.compassHeading);
+        t7_compass(heading, stateUsed->diveSettings.compassHeading);
 
         if(!pSettings->FlipDisplay)
         {
@@ -1993,7 +1994,7 @@
         	t7cY0free.WindowY0 = 0;
         	t7cY0free.WindowY1 = 250;
         }
-        snprintf(text,100,"\030\001%03i`",(uint16_t)stateUsed->lifeData.compass_heading);
+        snprintf(text,100,"\030\001%03i`",heading);
         GFX_write_string(&FontT54,&t7cY0free,text,0);
         if(!pSettings->FlipDisplay)
         {
@@ -2747,6 +2748,7 @@
 {
     uint8_t i, j, textptr, lineCount;
     char nextChar;
+    uint8_t alignmentChanged = 0;
 
     textptr = 0;
     lineCount = 0;
@@ -2762,14 +2764,16 @@
         do
         {
             nextChar = settingsGetPointer()->customtext[i+j];
-         	if(nextChar == '^')		/* center */
+         	if((nextChar == '^') && (alignmentChanged == 0))		/* center */
            	{
            		text[textptr++] = '\001';
+           		alignmentChanged = 1;
            		i++;
            	}else
-           	if(nextChar == 180)		/* '´' => Right */
+           	if((nextChar == 180) && (alignmentChanged == 0))		/* '�' => Right */
            	{
            		text[textptr++] = '\002';
+           		alignmentChanged = 1;
            		i++;
            	}else
            	{
@@ -2798,6 +2802,7 @@
             text[textptr++] = '\n';
             text[textptr++] = '\r';
         }
+        alignmentChanged = 0;
         lineCount++;
         for(uint8_t k=0;k<2;k++)
         {