Mercurial > public > ostc4
diff Discovery/Src/tMenuEditXtra.c @ 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 | 63c340abd70e |
children |
line wrap: on
line diff
--- 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);