Mercurial > public > ostc4
changeset 774:6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
author | heinrichsweikamp |
---|---|
date | Wed, 10 May 2023 16:25:39 +0200 |
parents | 2c243233c999 |
children | 46c6d2380d4e |
files | Common/Inc/data_central.h Discovery/Inc/tMenu.h Discovery/Inc/tStructure.h Discovery/Inc/text_multilanguage.h Discovery/Src/data_central.c Discovery/Src/tHome.c Discovery/Src/tMenu.c Discovery/Src/tMenuEdit.c Discovery/Src/tMenuEditXtra.c Discovery/Src/text_multilanguage.c |
diffstat | 10 files changed, 142 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/Common/Inc/data_central.h Wed May 10 16:24:57 2023 +0200 +++ b/Common/Inc/data_central.h Wed May 10 16:25:39 2023 +0200 @@ -502,4 +502,5 @@ uint8_t isLoopMode(uint8_t Mode); +void setCompassHeading(uint16_t heading); #endif // DATA_CENTRAL_H
--- a/Discovery/Inc/tMenu.h Wed May 10 16:24:57 2023 +0200 +++ b/Discovery/Inc/tMenu.h Wed May 10 16:25:39 2023 +0200 @@ -31,6 +31,8 @@ /* Includes ------------------------------------------------------------------*/ #include <stdio.h> #include <string.h> +#include <stdbool.h> + #include "stm32f4xx_hal.h" #include "base.h" #include "gfx.h" @@ -85,4 +87,5 @@ void selectPage(uint32_t selection); +char *makeGrey(bool isGrey); #endif /* TMENU_H */
--- a/Discovery/Inc/tStructure.h Wed May 10 16:24:57 2023 +0200 +++ b/Discovery/Inc/tStructure.h Wed May 10 16:25:39 2023 +0200 @@ -195,6 +195,8 @@ /* 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) /* SURFACE MODE */
--- a/Discovery/Inc/text_multilanguage.h Wed May 10 16:24:57 2023 +0200 +++ b/Discovery/Inc/text_multilanguage.h Wed May 10 16:25:39 2023 +0200 @@ -356,6 +356,10 @@ TXT2BYTE_BailoutShort, TXT2BYTE_LoopShort, + TXT2BYTE_Set, + TXT2BYTE_Clear, + TXT2BYTE_Reset, + TXT2BYTE_END };
--- a/Discovery/Src/data_central.c Wed May 10 16:24:57 2023 +0200 +++ b/Discovery/Src/data_central.c Wed May 10 16:25:39 2023 +0200 @@ -860,3 +860,11 @@ } return retVal; } + +void setCompassHeading(uint16_t heading) +{ + + // if heading == 0 set compassHeading to 360, because compassHeading == 0 means 'off' + + stateUsedWrite->diveSettings.compassHeading = ((heading - 360) % 360) + 360; +}
--- a/Discovery/Src/tHome.c Wed May 10 16:24:57 2023 +0200 +++ b/Discovery/Src/tHome.c Wed May 10 16:25:39 2023 +0200 @@ -485,7 +485,7 @@ break; case StDBEAR: // t5_gauge - stateUsedWrite->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; + setCompassHeading((uint16_t)stateUsed->lifeData.compass_heading); set_globalState(StD); break;
--- a/Discovery/Src/tMenu.c Wed May 10 16:24:57 2023 +0200 +++ b/Discovery/Src/tMenu.c Wed May 10 16:25:39 2023 +0200 @@ -1402,3 +1402,9 @@ } tMscreen.FBStartAdress = pBackup; } + + +char *makeGrey(bool isGrey) +{ + return isGrey ? "\031" : ""; +}
--- a/Discovery/Src/tMenuEdit.c Wed May 10 16:24:57 2023 +0200 +++ b/Discovery/Src/tMenuEdit.c Wed May 10 16:25:39 2023 +0200 @@ -212,22 +212,20 @@ case (StMHARD3_Sensor_Detect): case (StMHARD3_Sensor_Info): refreshFct = refresh_O2Sensors; break; - case (StMHARD2_Compass_SetCourse & MaskFieldDigit): refreshFct = refresh_CompassEdit; - break; - /* case (StMXTRA_CompassHeading & MaskFieldDigit): StMXTRA_CompassHeading and StMXTRA_PSCR_O2_Drop share the same menu ID => select function based on divemode */ + case (StMHARD2_Compass_SetCourse & MaskFieldDigit): + refreshFct = refresh_CompassEdit; + + break; + case (StMXTRA_CompassHeading & MaskFieldDigit): + refreshFct = refresh_CompassHeading; + + break; case (StMXTRA_PSCR_O2_Drop & MaskFieldDigit): - if(actual_menu_content == MENU_SURFACE) - { - if(settingsGetPointer()->dive_mode != DIVEMODE_PSCR) /* workaround because PSCR mode is set dynamic */ - { - refreshFct = refresh_CO2Data; - } - } - else - { - refreshFct = refresh_CompassHeading; - } - break; + if (settingsGetPointer()->dive_mode != DIVEMODE_PSCR) { /* workaround because PSCR mode is set dynamic */ + refreshFct = refresh_CO2Data; + } + + break; case (StMXTRA_CO2_Sensor & MaskFieldDigit): refreshFct = refresh_CO2Data; break; case (StMSYS4_Info & MaskFieldDigit): refreshFct = &refresh_InformationPage;
--- a/Discovery/Src/tMenuEditXtra.c Wed May 10 16:24:57 2023 +0200 +++ b/Discovery/Src/tMenuEditXtra.c Wed May 10 16:25:39 2023 +0200 @@ -27,6 +27,8 @@ ////////////////////////////////////////////////////////////////////////////// /* Includes ------------------------------------------------------------------*/ +#include <stdbool.h> + #include "tMenuEditXtra.h" #include "gfx_fonts.h" @@ -354,23 +356,84 @@ } #endif + +static uint8_t OnAction_CompassHeadingClear(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + stateUsedWrite->diveSettings.compassHeading = 0; + + exitMenuEdit_to_Home_with_Menu_Update(); + + return EXIT_TO_HOME; +} + + +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; + + exitMenuEdit_to_Home_with_Menu_Update(); + + return EXIT_TO_HOME; +} + + +static void drawCompassHeadingMenu(bool doInitialise) +{ + char text[32]; + snprintf(text, 32, "\001%c%c", TXT_2BYTE, TXT2BYTE_CompassHeading); + write_topline(text); + + uint16_t heading = (uint16_t)stateUsed->lifeData.compass_heading; + snprintf(text,32,"\001%03i`",heading); + write_label_var(0, 800, ME_Y_LINE1, &FontT54, text); + + if (doInitialise) { + snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_Set); + write_field_button(StMXTRA_CompassHeading, 20, 800, ME_Y_LINE2, &FontT48, text); + } else { + tMenuEdit_refresh_field(StMXTRA_CompassHeading); + } + + bool headingIsSet = stateUsed->diveSettings.compassHeading; + snprintf(text, 32, "%s%c%c", makeGrey(!headingIsSet), TXT_2BYTE, TXT2BYTE_Clear); + if (headingIsSet) { + if (doInitialise) { + write_field_button(StMXTRA_CompassHeadingClear, 20, 800, ME_Y_LINE3, &FontT48, text); + } else { + tMenuEdit_refresh_field(StMXTRA_CompassHeadingClear); + } + } else { + write_label_var(20, 800, ME_Y_LINE3, &FontT48, text); + } + + int16_t compassBearing = settingsGetPointer()->compassBearing; + bool canSetBearing = compassBearing && compassBearing != stateUsed->diveSettings.compassHeading; + snprintf(text, 32, "%s%c%c (%03u`)", makeGrey(!canSetBearing), TXT_2BYTE, TXT2BYTE_Reset, compassBearing); + if (canSetBearing) { + if (doInitialise) { + write_field_button(StMXTRA_CompassHeadingReset, 20, 800, ME_Y_LINE4, &FontT48, text); + } else { + tMenuEdit_refresh_field(StMXTRA_CompassHeadingReset); + } + } else { + write_label_var(20, 800, ME_Y_LINE4, &FontT48, text); + } + + if (doInitialise) { + setEvent(StMXTRA_CompassHeading, (uint32_t)OnAction_CompassHeading); + setEvent(StMXTRA_CompassHeadingClear, (uint32_t)OnAction_CompassHeadingClear); + setEvent(StMXTRA_CompassHeadingReset, (uint32_t)OnAction_CompassHeadingReset); + } + + write_buttonTextline(TXT2BYTE_ButtonBack, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonNext); +} + + void refresh_CompassHeading(void) { - uint16_t heading; - char text[32]; + drawCompassHeadingMenu(false); +} - text[0] = '\001'; - text[1] = TXT_2BYTE; - text[2] = TXT2BYTE_CompassHeading; - text[3] = 0; - write_topline(text); - - heading = (uint16_t)stateUsed->lifeData.compass_heading; - snprintf(text,32,"\001%03i`",heading); - write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text); - - tMenuEdit_refresh_field(StMXTRA_CompassHeading); -} void refresh_CO2Data(void) { @@ -391,14 +454,13 @@ void openEdit_CompassHeading(void) { - write_field_button(StMXTRA_CompassHeading,20, 800, ME_Y_LINE4, &FontT48, "Set"); - setEvent(StMXTRA_CompassHeading, (uint32_t)OnAction_CompassHeading); + drawCompassHeadingMenu(true); } uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { - stateUsedWrite->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; + setCompassHeading((uint16_t)stateUsed->lifeData.compass_heading); exitMenuEdit_to_Home_with_Menu_Update(); return EXIT_TO_HOME; }
--- a/Discovery/Src/text_multilanguage.c Wed May 10 16:24:57 2023 +0200 +++ b/Discovery/Src/text_multilanguage.c Wed May 10 16:25:39 2023 +0200 @@ -776,6 +776,27 @@ static uint8_t text_IT_EndDiveMode[] = "End dive"; static uint8_t text_ES_EndDiveMode[] = "End dive"; +// Dive Menu +static uint8_t text_EN_Set[] = "Set"; +static uint8_t text_DE_Set[] = "Setzen"; +static uint8_t text_FR_Set[] = "Réinitialiser"; +static uint8_t text_IT_Set[] = "Impostare"; +static uint8_t text_ES_Set[] = "Establecer"; + +// Dive Menu +static uint8_t text_EN_Clear[] = "Clear"; +static uint8_t text_DE_Clear[] = "Löschen"; +static uint8_t text_FR_Clear[] = "Annuler"; +static uint8_t text_IT_Clear[] = "Cancellare"; +static uint8_t text_ES_Clear[] = "Borrar"; + +// Dive Menu +static uint8_t text_EN_Reset[] = "Reset"; +static uint8_t text_DE_Reset[] = "Zurücksetzen"; +static uint8_t text_FR_Reset[] = "Réinitialiser"; +static uint8_t text_IT_Reset[] = "Ripristina"; +static uint8_t text_ES_Reset[] = "Restaurar"; + // Menu SIM static uint8_t text_EN_Simulator[] = "Simulator"; static uint8_t text_DE_Simulator[] = ""; @@ -2082,6 +2103,10 @@ {(uint8_t)TXT2BYTE_CcrSummary, {text_EN_CcrSummary, text_DE_CcrSummary, text_FR_CcrSummary, text_IT_CcrSummary, text_ES_CcrSummary}}, {(uint8_t)TXT2BYTE_Setpoint, {text_EN_Setpoint, text_DE_Setpoint, text_FR_Setpoint, text_IT_Setpoint, text_ES_Setpoint}}, {(uint8_t)TXT2BYTE_Scrubber, {text_EN_Scrubber, text_DE_Scrubber, text_FR_Scrubber, text_IT_Scrubber, text_ES_Scrubber}}, + + {(uint8_t)TXT2BYTE_Set, {text_EN_Set, text_DE_Set, text_FR_Set, text_IT_Set, text_ES_Set}}, + {(uint8_t)TXT2BYTE_Clear, {text_EN_Clear, text_DE_Clear, text_FR_Clear, text_IT_Clear, text_ES_Clear}}, + {(uint8_t)TXT2BYTE_Reset, {text_EN_Reset, text_DE_Reset, text_FR_Reset, text_IT_Reset, text_ES_Reset}}, {(uint8_t)TXT2BYTE_BailoutShort, {text_EN_BailoutShort, text_DE_BailoutShort, text_FR_BailoutShort, text_IT_BailoutShort, text_ES_BailoutShort}}, {(uint8_t)TXT2BYTE_LoopShort, {text_EN_LoopShort, text_DE_LoopShort, text_FR_LoopShort, text_IT_LoopShort, text_ES_LoopShort}}, };