diff Discovery/Src/t7.c @ 759:9825dcf50675

Some compass improvements from mikeller
author heinrichsweikamp
date Fri, 17 Mar 2023 09:35:25 +0100
parents b6d8a6fbf4fd
children 8deb28b2d4da
line wrap: on
line diff
--- 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);