changeset 777:6a8cf91e5b22

This is only showing if one of the compass views is visible. It should make it possible to verify that a correct heading is set as the user can see the compass readout when pushing the button. (mikeller)
author heinrichsweikamp
date Mon, 22 May 2023 09:14:27 +0200
parents 46c6d2380d4e
children 74253a41cf80
files Discovery/Inc/t7.h Discovery/Src/t7.c Discovery/Src/tHome.c
diffstat 3 files changed, 33 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/t7.h	Thu May 11 12:13:03 2023 +0200
+++ b/Discovery/Inc/t7.h	Mon May 22 09:14:27 2023 +0200
@@ -29,6 +29,8 @@
 #define T7_H
 
 /* Includes ------------------------------------------------------------------*/
+#include <stdbool.h>
+
 #include "stm32f4xx_hal.h"
 #include "gfx_engine.h"
 #include "configuration.h"
@@ -79,6 +81,7 @@
 uint8_t t7_GetEnabled_customviews();
 uint8_t t7_customview_disabled(uint8_t view);
 
+bool t7_isCompassShowing(void);
 /*
 	 void t7c_refresh(uint32_t FramebufferStartAddress);
 */
--- a/Discovery/Src/t7.c	Thu May 11 12:13:03 2023 +0200
+++ b/Discovery/Src/t7.c	Mon May 22 09:14:27 2023 +0200
@@ -2800,6 +2800,11 @@
 
         GFX_write_string_color(&FontT48, &t7c2, TextR1, 0, CLUT_WarningYellow);
     }
+    else if(get_globalState() == StDBEAR)
+    {
+        snprintf(TextR1, TEXTSIZE, "\a\001 %c%c? ", TXT_2BYTE, TXT2BYTE_DiveBearingQ);
+        GFX_write_string_color(&FontT48,&t7c2,TextR1,0,CLUT_WarningYellow);
+    }
     else if(get_globalState() == StDSIM1)
     {
         snprintf(TextR1,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ);
@@ -4481,3 +4486,8 @@
     }
 
 }
+
+bool t7_isCompassShowing(void)
+{
+    return selection_customview == CVIEW_Compass || selection_custom_field == LLC_Compass;
+}
--- a/Discovery/Src/tHome.c	Thu May 11 12:13:03 2023 +0200
+++ b/Discovery/Src/tHome.c	Mon May 22 09:14:27 2023 +0200
@@ -181,6 +181,16 @@
 }
 
 
+static void checkSetStateCompassSim(SSettings *settings)
+{
+    if (settings->design == 7 && t7_isCompassShowing()) {
+        set_globalState(StDBEAR);
+    } else {
+        checkSetStateSim(settings);
+    }
+}
+
+
 void tHomeDiveMenuControl(uint8_t sendAction)
 {
     SSettings *settings = settingsGetPointer();
@@ -277,7 +287,7 @@
                 break;
             }
 
-            checkSetStateSim(settings);
+            checkSetStateCompassSim(settings);
 
             break;
         case StDBAILOUT:
@@ -287,11 +297,11 @@
                 break;
             }
 
-            checkSetStateSim(settings);
+            checkSetStateCompassSim(settings);
 
             break;
         case StDSETPOINT:
-            checkSetStateSim(settings);
+            checkSetStateCompassSim(settings);
 
             break;
         case StDSIM1:
@@ -355,6 +365,12 @@
             break;
 #endif
         case StDBEAR:
+            if (settingsGetPointer()->design == 7) {
+                checkSetStateSim(settings);
+
+                break;
+            }
+
         	if(settingsGetPointer()->design == 5)
         	{
         		set_globalState(StDRAVG);
@@ -500,7 +516,7 @@
             set_globalState(StD);
 
             break;
-        case StDBEAR: // t5_gauge
+        case StDBEAR: // t5_gauge, t7
             setCompassHeading((uint16_t)stateUsed->lifeData.compass_heading);
             set_globalState(StD);
             break;