diff Discovery/Src/tMenuEditXtra.c @ 929:63c340abd70e Evo_2_23 tip

Add a line to the compass heading dive menu that shows the currently set heading to enable the diver to confirm it / add it to notes. Also add a log entry every time a new compass heading is set or the heading is cleared. And add a way to add compass headings to the log without changing the currently set heading - this was added after discussion with cave divers who are interested in recording headings when mapping out caves. From mikeller
author heinrichsweikamp
date Mon, 02 Dec 2024 11:16:10 +0100
parents 49ee233c7a74
children
line wrap: on
line diff
--- a/Discovery/Src/tMenuEditXtra.c	Tue Nov 26 21:30:06 2024 +0100
+++ b/Discovery/Src/tMenuEditXtra.c	Mon Dec 02 11:16:10 2024 +0100
@@ -316,7 +316,7 @@
 
 static uint8_t OnAction_CompassHeadingClear(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
-    stateUsedWrite->diveSettings.compassHeading = 0;
+    clearCompassHeading();
 
     exitMenuEdit_to_Home_with_Menu_Update();
 
@@ -326,7 +326,17 @@
 
 static uint8_t OnAction_CompassHeadingReset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
-    stateUsedWrite->diveSettings.compassHeading = settingsGetPointer()->compassBearing;
+    setCompassHeading(settingsGetPointer()->compassBearing);
+
+    exitMenuEdit_to_Home_with_Menu_Update();
+
+    return EXIT_TO_HOME;
+}
+
+
+static uint8_t OnAction_CompassHeadingLog(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+{
+	logCompassHeading((uint16_t)stateUsed->lifeData.compass_heading);
 
     exitMenuEdit_to_Home_with_Menu_Update();
 
@@ -383,10 +393,23 @@
         write_label_var(20, 800, ME_Y_LINE4, &FontT48, text);
     }
 
+    snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_Log);
+    if (!isRefresh) {
+        write_field_button(StMXTRA_CompassHeadingLog, 20, 800, ME_Y_LINE5, &FontT48, text);
+    } else {
+        tMenuEdit_refresh_field(StMXTRA_CompassHeadingLog);
+    }
+
+    if (headingIsSet) {
+        snprintf(text, 32, "%s%c%c (%03u`)", makeGrey(true), TXT_2BYTE, TXT2BYTE_Current, stateUsed->diveSettings.compassHeading);
+        write_label_var(20, 800, ME_Y_LINE6, &FontT48, text);
+    }
+
     if (!isRefresh) {
         setEvent(StMXTRA_CompassHeading, (uint32_t)OnAction_CompassHeading);
         setEvent(StMXTRA_CompassHeadingClear, (uint32_t)OnAction_CompassHeadingClear);
         setEvent(StMXTRA_CompassHeadingReset, (uint32_t)OnAction_CompassHeadingReset);
+        setEvent(StMXTRA_CompassHeadingLog, (uint32_t)OnAction_CompassHeadingLog);
     }
 
     write_buttonTextline(TXT2BYTE_ButtonBack, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonNext);