# HG changeset patch # User heinrichsweikamp # Date 1733134570 -3600 # Node ID 63c340abd70ec643a4618bc924b7028604cd8ae8 # Parent 9b7859554beba0dd89ba46e3f005dd7ffd5142f0 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 diff -r 9b7859554beb -r 63c340abd70e Common/Inc/data_central.h --- a/Common/Inc/data_central.h Tue Nov 26 21:30:06 2024 +0100 +++ b/Common/Inc/data_central.h Mon Dec 02 11:16:10 2024 +0100 @@ -306,7 +306,9 @@ int16_t bailout; int16_t info_bailoutHe; int16_t info_bailoutO2; -} SEvents; + int16_t compassHeadingUpdate; + uint16_t info_compassHeadingUpdate; +} SEvents; @@ -544,6 +546,8 @@ uint8_t isLoopMode(uint8_t Mode); bool isCompassCalibrated(void); +void logCompassHeading(uint16_t heading); +void clearCompassHeading(void); void setCompassHeading(uint16_t heading); const SDecoinfo *getDecoInfo(void); diff -r 9b7859554beb -r 63c340abd70e Discovery/Inc/tStructure.h --- a/Discovery/Inc/tStructure.h Tue Nov 26 21:30:06 2024 +0100 +++ b/Discovery/Inc/tStructure.h Mon Dec 02 11:16:10 2024 +0100 @@ -206,6 +206,7 @@ #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) /* SURFACE MODE */ diff -r 9b7859554beb -r 63c340abd70e Discovery/Inc/text_multilanguage.h --- a/Discovery/Inc/text_multilanguage.h Tue Nov 26 21:30:06 2024 +0100 +++ b/Discovery/Inc/text_multilanguage.h Mon Dec 02 11:16:10 2024 +0100 @@ -385,6 +385,9 @@ TXT2BYTE_VpmTable, TXT2BYTE_Page, + TXT2BYTE_Current, + TXT2BYTE_Log, + TXT2BYTE_END, }; diff -r 9b7859554beb -r 63c340abd70e Discovery/Src/data_central.c --- 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); } diff -r 9b7859554beb -r 63c340abd70e Discovery/Src/logbook.c --- a/Discovery/Src/logbook.c Tue Nov 26 21:30:06 2024 +0100 +++ b/Discovery/Src/logbook.c Mon Dec 02 11:16:10 2024 +0100 @@ -458,6 +458,10 @@ eventByte1.ub.bit7 = 1; eventByte2.ub.bit0 = 1; } + if (state->events.compassHeadingUpdate) { + eventByte1.ub.bit7 = 1; + eventByte2.ub.bit1 = 1; + } //Add EventByte 1 if(eventByte1.uw > 0) { @@ -498,6 +502,11 @@ sample[length] = state->events.info_bailoutHe; length += 1; } + if (state->events.compassHeadingUpdate) { + // New heading and type of heading + sample[length++] = state->events.info_compassHeadingUpdate & 0xFF; + sample[length++] = (state->events.info_compassHeadingUpdate & 0xFF00) >> 8; + } if(divisor.temperature == 0) diff -r 9b7859554beb -r 63c340abd70e Discovery/Src/tMenuEditXtra.c --- 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); diff -r 9b7859554beb -r 63c340abd70e Discovery/Src/text_multilanguage.c --- a/Discovery/Src/text_multilanguage.c Tue Nov 26 21:30:06 2024 +0100 +++ b/Discovery/Src/text_multilanguage.c Mon Dec 02 11:16:10 2024 +0100 @@ -1562,6 +1562,7 @@ static uint8_t text_FR_FocusSpotSize[] = ""; static uint8_t text_IT_FocusSpotSize[] = ""; static uint8_t text_ES_FocusSpotSize[] = ""; + /* static uint8_t text_EN_ApneaCount[] = ""; static uint8_t text_DE_ApneaCount[] = ""; @@ -1956,6 +1957,18 @@ static uint8_t text_IT_Page[] = "Scorrere"; static uint8_t text_ES_Page[] = "Desplazarse"; +static uint8_t text_EN_Current[] = "Current"; +static uint8_t text_DE_Current[] = "Aktuell"; +static uint8_t text_FR_Current[] = "Actuel"; +static uint8_t text_IT_Current[] = "Attuale"; +static uint8_t text_ES_Current[] = "Actual"; + +static uint8_t text_EN_Log[] = "Log"; +static uint8_t text_DE_Log[] = "Aufzeichnen"; +static uint8_t text_FR_Log[] = "Enregistrer"; +static uint8_t text_IT_Log[] = "Registrare"; +static uint8_t text_ES_Log[] = "Registrar"; + /* Lookup Table -------------------------------------------------------------*/ const tText text_array[] = @@ -2070,7 +2083,7 @@ {(uint8_t)TXT2BYTE_SetMarkerShort, {text_EN_SetMarkerShort, text_DE_SetMarkerShort, text_FR_SetMarkerShort, text_IT_SetMarkerShort, text_ES_SetMarkerShort}}, {(uint8_t)TXT2BYTE_CheckMarker, {text_EN_CheckMarker, text_DE_CheckMarker, text_FR_CheckMarker, text_IT_CheckMarker, text_ES_CheckMarker}}, {(uint8_t)TXT2BYTE_CompassHeading, {text_EN_CompassHeading, text_DE_CompassHeading, text_FR_CompassHeading, text_IT_CompassHeading, text_ES_CompassHeading}}, - {(uint8_t)TXT2BYTE_CalibView, {text_EN_CalibView, text_DE_CalibView, text_FR_CalibView, text_IT_CalibView, text_ES_CalibView}}, + {(uint8_t)TXT2BYTE_CalibView, {text_EN_CalibView, text_DE_CalibView, text_FR_CalibView, text_IT_CalibView, text_ES_CalibView}}, {(uint8_t)TXT2BYTE_IndicateFrame, {text_EN_IndicateFrame, text_DE_IndicateFrame, text_FR_IndicateFrame, text_IT_IndicateFrame, text_ES_IndicateFrame}}, {(uint8_t)TXT2BYTE_BoostBacklight, {text_EN_BoostBacklight, text_DE_BoostBacklight, text_FR_BoostBacklight, text_IT_BoostBacklight, text_ES_BoostBacklight}}, {(uint8_t)TXT2BYTE_FocusSpotSize, {text_EN_FocusSpotSize, text_DE_FocusSpotSize, text_FR_FocusSpotSize, text_IT_FocusSpotSize, text_ES_FocusSpotSize}}, @@ -2256,4 +2269,7 @@ {(uint8_t)TXT2BYTE_VpmTable, {text_EN_VpmTable, text_DE_VpmTable, text_FR_VpmTable, text_IT_VpmTable, text_ES_VpmTable}}, {(uint8_t)TXT2BYTE_Page, {text_EN_Page, text_DE_Page, text_FR_Page, text_IT_Page, text_ES_Page}}, + + {(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}}, };