changeset 759:9825dcf50675

Some compass improvements from mikeller
author heinrichsweikamp
date Fri, 17 Mar 2023 09:35:25 +0100
parents b6d8a6fbf4fd
children 21949c88da90
files Discovery/Inc/text_multilanguage.h Discovery/Src/t7.c Discovery/Src/tMenuHardware.c Discovery/Src/text_multilanguage.c
diffstat 4 files changed, 37 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/text_multilanguage.h	Wed Mar 15 09:18:07 2023 +0100
+++ b/Discovery/Inc/text_multilanguage.h	Fri Mar 17 09:35:25 2023 +0100
@@ -348,6 +348,7 @@
 		TXT2BYTE_Maximum,
 
 		TXT2BYTE_CheckSettings,
+		TXT2BYTE_NotCalibrated,
 
 		TXT2BYTE_END
 };
--- a/Discovery/Src/t7.c	Wed Mar 15 09:18:07 2023 +0100
+++ b/Discovery/Src/t7.c	Fri Mar 17 09:35:25 2023 +0100
@@ -28,6 +28,7 @@
 
 /* Includes ------------------------------------------------------------------*/
 #include <stdlib.h>
+#include <stdbool.h>
 
 #include "t7.h"
 #include "t3.h"
@@ -1752,6 +1753,12 @@
 }
 
 
+bool isCompassCalibrated(void)
+{
+    return stateUsed->lifeData.compass_heading != -1;
+}
+
+
 void t7_refresh_customview(void)
 {
 	static uint8_t last_customview = CVIEW_END;
@@ -1894,6 +1901,27 @@
             }
             t7cC.WindowNumberOfTextLines = 1;
 		}
+        else if(!isCompassCalibrated()) {
+            if(warning_count_high_time) {
+                shiftWindowY0 += 20;
+                t7cC.WindowY0 -= shiftWindowY0;
+                textpointer = 0;
+                text[textpointer++] = '\001';
+                text[textpointer++] = TXT_2BYTE;
+                text[textpointer++] = TXT2BYTE_Compass;
+                text[textpointer++] = '\n';
+                text[textpointer++] = '\r';
+                text[textpointer++] = '\001';
+                text[textpointer++] = TXT_2BYTE;
+                text[textpointer++] = TXT2BYTE_NotCalibrated;
+                text[textpointer++] = '\n';
+                text[textpointer++] = '\r';
+                text[textpointer++] = 0;
+                GFX_write_string_color(&FontT42, &t7cC,text, 1, CLUT_WarningRed);
+                t7cC.WindowY0 += shiftWindowY0;
+            }
+            t7cC.WindowNumberOfTextLines = 2;
+		}
         else // customtext
         {
             lineCountCustomtext = t7_customtextPrepare(text);
--- a/Discovery/Src/tMenuHardware.c	Wed Mar 15 09:18:07 2023 +0100
+++ b/Discovery/Src/tMenuHardware.c	Fri Mar 17 09:35:25 2023 +0100
@@ -81,7 +81,7 @@
 
         if(settingsGetPointer()->compassBearing != 0)
         {
-            textPointer += snprintf(&text[textPointer],20,"(%03u`)",settingsGetPointer()->compassBearing);
+            textPointer += snprintf(&text[textPointer], 20, "(%03u`)", settingsGetPointer()->compassBearing % 360);
         }
         text[textPointer] = 0;
 /*
--- a/Discovery/Src/text_multilanguage.c	Wed Mar 15 09:18:07 2023 +0100
+++ b/Discovery/Src/text_multilanguage.c	Fri Mar 17 09:35:25 2023 +0100
@@ -1778,6 +1778,12 @@
 static uint8_t text_IT_KeyLock[] = "";
 static uint8_t text_ES_KeyLock[] = "";
 
+static uint8_t text_EN_NotCalibrated[] = "not calibrated";
+static uint8_t text_DE_NotCalibrated[] = "nicht kalibriert";
+static uint8_t text_FR_NotCalibrated[] = "non calibrée";
+static uint8_t text_IT_NotCalibrated[] = "non calibrata";
+static uint8_t text_ES_NotCalibrated[] = "no calibrada";
+
 /* Lookup Table -------------------------------------------------------------*/
 
 const tText text_array[] =
@@ -2041,6 +2047,5 @@
 	{(uint8_t)TXT2BYTE_Maximum, 		{text_EN_Maximum, text_DE_Maximum, text_FR_Maximum, text_IT_Maximum, text_ES_Maximum}},
 
 	{(uint8_t)TXT2BYTE_CheckSettings, 	{text_EN_CheckSettings, text_DE_CheckSettings, text_FR_CheckSettings, text_IT_CheckSettings, text_ES_CheckSettings}},
-
-
+	{(uint8_t)TXT2BYTE_NotCalibrated, 	{text_EN_NotCalibrated, text_DE_NotCalibrated, text_FR_NotCalibrated, text_IT_NotCalibrated, text_ES_NotCalibrated}},
 };