diff Discovery/Src/data_central.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 57fc479745b0
children
line wrap: on
line diff
--- a/Discovery/Src/data_central.c	Tue Nov 26 21:30:06 2024 +0100
+++ b/Discovery/Src/data_central.c	Mon Dec 02 11:16:10 2024 +0100
@@ -892,13 +892,38 @@
     return stateUsed->lifeData.compass_heading != -1;
 }
 
+static void internalLogCompassHeading(uint16_t heading, bool applyHeading, bool clearHeading)
+{
+    uint16_t compassHeading = 0;
+    if (clearHeading) {
+        compassHeading |= 0x8000;
+    } else {
+        compassHeading = heading & 0x1FF;
+    }
+    if (applyHeading) {
+        compassHeading |= 0x4000;
+    }
+
+    stateUsedWrite->events.compassHeadingUpdate = 1;
+    stateUsedWrite->events.info_compassHeadingUpdate = compassHeading;
+}
+
+void logCompassHeading(uint16_t heading) {
+    internalLogCompassHeading(heading, false, false);
+}
+
+void clearCompassHeading(void) {
+    uint16_t clearHeading = 0;
+    stateUsedWrite->diveSettings.compassHeading = clearHeading;
+
+    internalLogCompassHeading(clearHeading, true, true);
+}
 
 void setCompassHeading(uint16_t heading)
 {
+    stateUsedWrite->diveSettings.compassHeading =  ((heading - 360) % 360) + 360;
 
-    // if heading == 0 set compassHeading to 360, because compassHeading == 0 means 'off'
-
-    stateUsedWrite->diveSettings.compassHeading =  ((heading - 360) % 360) + 360;
+    internalLogCompassHeading(heading, true, false);
 }