changeset 967:9b418e63dbc2 Evo_2_23 tip

Add a 'Reverse' action to the compass heading dive menu. This allows the compass heading to be reversed for the return leg of the dive - as a bonus the reversal will be logged, establishing at which point in the log the dive was turned (mikeller)
author heinrichsweikamp
date Wed, 15 Jan 2025 16:38:27 +0100
parents 90edc237d60f
children
files Discovery/Inc/tStructure.h Discovery/Inc/text_multilanguage.h Discovery/Src/data_central.c Discovery/Src/tMenuEditXtra.c Discovery/Src/text_multilanguage.c
diffstat 5 files changed, 45 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/tStructure.h	Mon Jan 13 20:42:24 2025 +0100
+++ b/Discovery/Inc/tStructure.h	Wed Jan 15 16:38:27 2025 +0100
@@ -204,9 +204,10 @@
 /* DIVE MODE */
 #define StMXTRA_ResetStopwatch	_MB(2,4,1,1,0)
 #define StMXTRA_CompassHeading	_MB(2,4,2,1,0)
-#define StMXTRA_CompassHeadingClear	_MB(2,4,2,2,0)
-#define StMXTRA_CompassHeadingReset	_MB(2,4,2,3,0)
-#define StMXTRA_CompassHeadingLog	_MB(2,4,2,4,0)
+#define StMXTRA_CompassHeadingReverse	_MB(2,4,2,2,0)
+#define StMXTRA_CompassHeadingClear	_MB(2,4,2,3,0)
+#define StMXTRA_CompassHeadingReset	_MB(2,4,2,4,0)
+#define StMXTRA_CompassHeadingLog	_MB(2,4,2,5,0)
 
  /* SURFACE MODE */
 
--- a/Discovery/Inc/text_multilanguage.h	Mon Jan 13 20:42:24 2025 +0100
+++ b/Discovery/Inc/text_multilanguage.h	Wed Jan 15 16:38:27 2025 +0100
@@ -387,6 +387,7 @@
 
         TXT2BYTE_Current,
         TXT2BYTE_Log,
+        TXT2BYTE_Reverse,
 
 		TXT2BYTE_DDMMYY,
 		TXT2BYTE_MMDDYY,
--- a/Discovery/Src/data_central.c	Mon Jan 13 20:42:24 2025 +0100
+++ b/Discovery/Src/data_central.c	Wed Jan 15 16:38:27 2025 +0100
@@ -921,7 +921,7 @@
 
 void setCompassHeading(uint16_t heading)
 {
-    stateUsedWrite->diveSettings.compassHeading =  ((heading - 360) % 360) + 360;
+    stateUsedWrite->diveSettings.compassHeading = ((heading - 360) % 360) + 360;
 
     internalLogCompassHeading(heading, true, false);
 }
--- a/Discovery/Src/tMenuEditXtra.c	Mon Jan 13 20:42:24 2025 +0100
+++ b/Discovery/Src/tMenuEditXtra.c	Wed Jan 15 16:38:27 2025 +0100
@@ -314,6 +314,16 @@
 
 
 
+static uint8_t OnAction_CompassHeadingReverse(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+{
+    setCompassHeading((stateUsed->diveSettings.compassHeading + 180) % 360);
+
+    exitMenuEdit_to_Home_with_Menu_Update();
+
+    return EXIT_TO_HOME;
+}
+
+
 static uint8_t OnAction_CompassHeadingClear(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     clearCompassHeading();
@@ -352,6 +362,13 @@
     snprintf(text, 32, "\001%c%c", TXT_2BYTE, TXT2BYTE_CompassHeading);
     write_topline(text);
 
+    if (!isRefresh) {
+        snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_Set);
+        write_field_button(StMXTRA_CompassHeading, 20, 800, ME_Y_LINE1, &FontT48, text);
+    } else {
+        tMenuEdit_refresh_field(StMXTRA_CompassHeading);
+    }
+
     uint16_t heading;
     if (settings->compassInertia) {
         heading = (uint16_t)compass_getCompensated();
@@ -361,14 +378,18 @@
     snprintf(text,32,"\001%03i`",heading);
     write_label_var(0, 800, ME_Y_LINE1, &FontT54, text);
 
-    if (!isRefresh) {
-        snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_Set);
-        write_field_button(StMXTRA_CompassHeading, 20, 800, ME_Y_LINE2, &FontT48, text);
+    bool headingIsSet = stateUsed->diveSettings.compassHeading;
+    snprintf(text, 32, "%s%c%c", makeGrey(!headingIsSet), TXT_2BYTE, TXT2BYTE_Reverse);
+    if (headingIsSet) {
+        if (!isRefresh) {
+            write_field_button(StMXTRA_CompassHeadingReverse, 20, 800, ME_Y_LINE2, &FontT48, text);
+        } else {
+            tMenuEdit_refresh_field(StMXTRA_CompassHeadingReverse);
+        }
     } else {
-        tMenuEdit_refresh_field(StMXTRA_CompassHeading);
+        write_label_var(20, 800, ME_Y_LINE2, &FontT48, text);
     }
 
-    bool headingIsSet = stateUsed->diveSettings.compassHeading;
     snprintf(text, 32, "%s%c%c", makeGrey(!headingIsSet), TXT_2BYTE, TXT2BYTE_Clear);
     if (headingIsSet) {
         if (!isRefresh) {
@@ -407,6 +428,7 @@
 
     if (!isRefresh) {
         setEvent(StMXTRA_CompassHeading, (uint32_t)OnAction_CompassHeading);
+        setEvent(StMXTRA_CompassHeadingReverse, (uint32_t)OnAction_CompassHeadingReverse);
         setEvent(StMXTRA_CompassHeadingClear, (uint32_t)OnAction_CompassHeadingClear);
         setEvent(StMXTRA_CompassHeadingReset, (uint32_t)OnAction_CompassHeadingReset);
         setEvent(StMXTRA_CompassHeadingLog, (uint32_t)OnAction_CompassHeadingLog);
--- a/Discovery/Src/text_multilanguage.c	Mon Jan 13 20:42:24 2025 +0100
+++ b/Discovery/Src/text_multilanguage.c	Wed Jan 15 16:38:27 2025 +0100
@@ -1999,6 +1999,12 @@
 static uint8_t text_IT_BUZZER[] = "";
 static uint8_t text_ES_BUZZER[] = "";
 
+static uint8_t text_EN_Reverse[] = "Reverse";
+static uint8_t text_DE_Reverse[] = "Umkehren";
+static uint8_t text_FR_Reverse[] = "Inverser";
+static uint8_t text_IT_Reverse[] = "Invertire";
+static uint8_t text_ES_Reverse[] = "Invertir";
+
 /* Lookup Table -------------------------------------------------------------*/
 
 const tText text_array[] =
@@ -2307,7 +2313,12 @@
 	{(uint8_t)TXT2BYTE_YYMMDD, 			{text_EN_YYMMDD, text_DE_YYMMDD, text_FR_YYMMDD, text_IT_YYMMDD, text_ES_YYMMDD}},
 	{(uint8_t)TXT2BYTE_TIMEZONE, 		{text_EN_TIMEZONE, text_DE_TIMEZONE, text_FR_TIMEZONE, text_IT_TIMEZONE, text_ES_TIMEZONE}},
 
-	{(uint8_t)TXT2BYTE_BUZZER, 		{text_EN_BUZZER, text_DE_BUZZER, text_FR_BUZZER, text_IT_BUZZER, text_ES_BUZZER}},
+	{(uint8_t)TXT2BYTE_BUZZER, 			{text_EN_BUZZER, text_DE_BUZZER, text_FR_BUZZER, text_IT_BUZZER, text_ES_BUZZER}},
+
+	{(uint8_t)TXT2BYTE_Current, 		{text_EN_Current, text_DE_Current, text_FR_Current, text_IT_Current, text_ES_Current}},
+ 	{(uint8_t)TXT2BYTE_Log, 			{text_EN_Log, text_DE_Log, text_FR_Log, text_IT_Log, text_ES_Log}},
+	{(uint8_t)TXT2BYTE_Reverse, 		{text_EN_Reverse, text_DE_Reverse, text_FR_Reverse, text_IT_Reverse, text_ES_Reverse}},
+
 
 
 };