Mercurial > public > ostc4
diff Discovery/Src/tMenuEditXtra.c @ 654:890440ab993a
Introduced new menu tab for addition CCR options:
The Xtra menu tab was only used in dive mode before. The tab is now enabled in surface mode and provide access to scrubber timer functionality. To enables this infrastructure (structure, multilanguage strings etc.) have been added to the sourcecode.
author | Ideenmodellierer |
---|---|
date | Sun, 25 Apr 2021 20:41:19 +0200 |
parents | ff2b393e290f |
children | 1b995079c045 |
line wrap: on
line diff
--- a/Discovery/Src/tMenuEditXtra.c Sun Apr 25 20:36:18 2021 +0200 +++ b/Discovery/Src/tMenuEditXtra.c Sun Apr 25 20:41:19 2021 +0200 @@ -44,9 +44,13 @@ void openEdit_SetManualMarker(void); void openEdit_SetEndDive(void); void openEdit_CalibViewport(void); +static void openEdit_ScrubberTimer(uint8_t line); +static void openEdit_ScrubberReset(void); +static void openEdit_ScrubberTimerMode(void); /* Announced function prototypes -----------------------------------------------*/ uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +static uint8_t OnAction_ScrubberTimer(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); /* Exported functions --------------------------------------------------------*/ @@ -55,31 +59,49 @@ set_globalState_Menu_Line(line); resetMenuEdit(CLUT_MenuPageXtra); - switch(line) + /* DIVE MODE */ + if(actual_menu_content != MENU_SURFACE) { - case 1: - default: - openEdit_ResetStopwatch(); - break; - case 2: - openEdit_CompassHeading(); - break; - case 3: - openEdit_SetManualMarker(); - break; - case 4: - openEdit_CalibViewport(); - break; - case 5: - if(is_stateUsedSetToSim()) - { - openEdit_SimFollowDecostops(); - } - else - { - openEdit_SetEndDive(); - } - break; + switch(line) + { + case 1: + default: + openEdit_ResetStopwatch(); + break; + case 2: + openEdit_CompassHeading(); + break; + case 3: + openEdit_SetManualMarker(); + break; + case 4: + openEdit_CalibViewport(); + break; + case 5: + if(is_stateUsedSetToSim()) + { + openEdit_SimFollowDecostops(); + } + else + { + openEdit_SetEndDive(); + } + break; + } + } + else /* surface mode */ + { + switch(line) + { + case 1: openEdit_ScrubberTimer(line); + break; + case 2: openEdit_ScrubberReset(); + break; + case 3: openEdit_ScrubberTimerMode(); + break; + default: + break; + } } } @@ -115,6 +137,60 @@ exitMenuEdit_to_Home(); } + + +static void openEdit_ScrubberTimer(uint8_t line) +{ + uint16_t localScrubTimer; + uint16_t y_line; + + char text[32]; + SSettings *pSettings = settingsGetPointer(); + localScrubTimer = pSettings->scrubTimerMax; + + y_line = ME_Y_LINE_BASE + (line * ME_Y_LINE_STEP); + + text[0] = '\001'; + text[1] = TXT_ScrubTime; + text[2] = 0; + write_topline(text); + + text[0] = '\002'; + strcpy(&text[1],"\016\016"); + text[3] = TXT_Minutes; + text[4] = 0; + write_label_fix( 20, 800, y_line, &FontT48, TXT_ScrubTime); + write_label_var( 435, 780, y_line, &FontT48, text); + write_field_udigit(StMXTRA_ScrubTimer_Max_Minutes, 600, 779, y_line, &FontT48, "###", (uint32_t)localScrubTimer, 0, 0, 0); + + write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); + + setEvent(StMXTRA_ScrubTimer_Max_Minutes, (uint32_t)OnAction_ScrubberTimer); + startEdit(); +} + +static void openEdit_ScrubberReset(void) +{ + SSettings *pSettings; + pSettings = settingsGetPointer(); + pSettings->scrubTimerCur = pSettings->scrubTimerMax; + exitMenuEdit_to_Menu_with_Menu_Update(); +} + +static void openEdit_ScrubberTimerMode(void) +{ + uint8_t newMode; + SSettings *pSettings; + pSettings = settingsGetPointer(); + newMode = pSettings->scrubTimerMode + 1; + if(newMode >= SCRUB_TIMER_END) + { + newMode = SCRUB_TIMER_OFF; + } + pSettings->scrubTimerMode = newMode; + exitMenuEdit_to_Menu_with_Menu_Update(); +} + void refresh_CompassHeading(void) { uint16_t heading; @@ -149,3 +225,46 @@ exitMenuEdit_to_Home_with_Menu_Update(); return EXIT_TO_HOME; } + +static uint8_t OnAction_ScrubberTimer(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + SSettings *pSettings; + uint8_t digitContentNew = EXIT_TO_MENU; + uint32_t newScrubberTime; + + if(action == ACTION_BUTTON_ENTER) + { + return digitContent; + } + if(action == ACTION_BUTTON_ENTER_FINAL) + { + evaluateNewString(editId, &newScrubberTime, 0, 0, 0); + + if(newScrubberTime > MAX_SCRUBBER_TIME) + newScrubberTime = MAX_SCRUBBER_TIME; + + pSettings = settingsGetPointer(); + pSettings->scrubTimerMax = newScrubberTime; + if(pSettings->scrubTimerCur > newScrubberTime) + { + pSettings->scrubTimerCur = newScrubberTime; + } + + tMenuEdit_newInput(editId, newScrubberTime, 0, 0, 0); + digitContentNew = UPDATE_AND_EXIT_TO_MENU; + } + if(action == ACTION_BUTTON_NEXT) + { + digitContentNew = digitContent + 1; + if(digitContentNew > '9') + digitContentNew = '0'; + } + if(action == ACTION_BUTTON_BACK) + { + digitContentNew = digitContent - 1; + if(digitContentNew < '0') + digitContentNew = '9'; + } + return digitContentNew; +} +