Mercurial > public > ostc4
diff Discovery/Src/tMenuEditXtra.c @ 710:8adf9b8fc7fa
Extension scrubber time:
In previous version only one scrubber timer was available. After movement of scruvver timer menu menu space became available allowing to upgrade the functionality to support two scrubbers. To make it easier to identify combination ID to used scrubber the date of the last usage of the scrubber timer has been added.
author | Ideenmodellierer |
---|---|
date | Tue, 08 Nov 2022 21:16:17 +0100 |
parents | e81afd727993 |
children | 062deb659531 |
line wrap: on
line diff
--- a/Discovery/Src/tMenuEditXtra.c Tue Nov 08 21:13:14 2022 +0100 +++ b/Discovery/Src/tMenuEditXtra.c Tue Nov 08 21:16:17 2022 +0100 @@ -58,7 +58,8 @@ /* 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); +uint8_t OnAction_ScrubberTimerId(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +static uint8_t OnAction_ScrubberTimerMax(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); static uint8_t OnAction_ScrubberReset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); static uint8_t OnAction_ScrubberMode(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); #ifdef ENABLE_PSCR_MODE @@ -73,6 +74,7 @@ /* Exported functions --------------------------------------------------------*/ + void openEdit_Xtra(uint8_t line) { set_globalState_Menu_Line(line); @@ -210,33 +212,48 @@ SSettings *pSettings = settingsGetPointer(); - localScrubTimer = pSettings->scrubTimerMax; + localScrubTimer = pSettings->scrubberData[pSettings->scubberActiveId].TimerMax; resetMenuEdit(CLUT_MenuPageXtra); - snprintf(&text[textIndex], 32,"\001%c",TXT_ScrubTime); + snprintf(&text[0], 32,"\001%c",TXT_ScrubTime); write_topline(text); + snprintf(&text[0], 32,"%c \002#%d",TXT_ScrubTime,pSettings->scubberActiveId); + write_field_button(StMXTRA_ScrubTimer, 20, 780, ME_Y_LINE1, &FontT48, text); + snprintf(&text[textIndex], 32,\ "%c" "\016\016(%c)\017" ,TXT_ScrubTime ,TXT_Maximum); - write_label_var( 20, 340, ME_Y_LINE1, &FontT48, text); + write_label_var( 20, 340, ME_Y_LINE2, &FontT48, text); snprintf(&text[textIndex], 32, "\002###\016\016 %c\017",TXT_Minutes); - write_field_udigit(StMXTRA_ScrubTimer, 610, 780, ME_Y_LINE1, &FontT48, text,localScrubTimer, 0, 0, 0); + write_field_udigit(StMXTRA_ScrubTimer_Max, 610, 780, ME_Y_LINE2, &FontT48, text,localScrubTimer, 0, 0, 0); snprintf(&text[0], 32,\ "%c\002%03u\016\016 %c\017" ,TXT_ScrubTimeReset - ,pSettings->scrubTimerCur + ,pSettings->scrubberData[pSettings->scubberActiveId].TimerCur ,TXT_Minutes); - write_field_button(StMXTRA_ScrubTimer_Reset, 20, 780, ME_Y_LINE2, &FontT48, text); + write_field_button(StMXTRA_ScrubTimer_Reset, 20, 780, ME_Y_LINE3, &FontT48, text); + + if(pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay != 0) + { + snprintf(&text[0], 32,"%c%c\002 %02d.%02d.%02d", TXT_2BYTE, TXT2BYTE_SimDiveTime, pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Date, + pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Month, + pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Year); + } + else + { + snprintf(&text[0], 32,"%c%c\002 --.--.--", TXT_2BYTE, TXT2BYTE_SimDiveTime); + } + write_label_var( 20, 780, ME_Y_LINE4, &FontT48, text); switch(pSettings->scrubTimerMode) { @@ -248,9 +265,10 @@ case SCRUB_TIMER_PERCENT: snprintf(&text[0], 32,"%c\002%c",TXT_ScrubTimeMode, TXT_Percent ); break; } - write_field_button(StMXTRA_ScrubTimer_OP_Mode, 30, 780, ME_Y_LINE3, &FontT48, text); + write_field_button(StMXTRA_ScrubTimer_OP_Mode, 20, 780, ME_Y_LINE5, &FontT48, text); - setEvent(StMXTRA_ScrubTimer, (uint32_t)OnAction_ScrubberTimer); + setEvent(StMXTRA_ScrubTimer, (uint32_t)OnAction_ScrubberTimerId); + setEvent(StMXTRA_ScrubTimer_Max, (uint32_t)OnAction_ScrubberTimerMax); setEvent(StMXTRA_ScrubTimer_Reset, (uint32_t)OnAction_ScrubberReset); setEvent(StMXTRA_ScrubTimer_OP_Mode, (uint32_t)OnAction_ScrubberMode); @@ -379,7 +397,52 @@ return EXIT_TO_HOME; } -static uint8_t OnAction_ScrubberTimer(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) + +uint8_t OnAction_ScrubberTimerId(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + char text[32]; + SSettings *pSettings; + pSettings = settingsGetPointer(); + + if(pSettings->scubberActiveId == 0) + { + pSettings->scubberActiveId = 1; + } + else + { + pSettings->scubberActiveId = 0; + } + + + snprintf(&text[0], 32,"%c \002#%d",TXT_ScrubTime,pSettings->scubberActiveId); + tMenuEdit_newButtonText(StMXTRA_ScrubTimer, text); + + snprintf(&text[0], 32,\ + "%c\002%03u\016\016 %c\017" + ,TXT_ScrubTimeReset + ,pSettings->scrubberData[pSettings->scubberActiveId].TimerCur + ,TXT_Minutes); + tMenuEdit_newButtonText(StMXTRA_ScrubTimer_Reset, text); + + tMenuEdit_newInput(StMXTRA_ScrubTimer_Max, pSettings->scrubberData[pSettings->scubberActiveId].TimerMax, 0, 0, 0); + + if(pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay != 0) + { + snprintf(&text[0], 32,"%c%c\002 %02d.%02d.%02d", TXT_2BYTE, TXT2BYTE_SimDiveTime, pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Date, + pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Month, + pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Year); + } + else + { + snprintf(&text[0], 32,"%c%c\002 --.--.--", TXT_2BYTE, TXT2BYTE_SimDiveTime); + } + clean_content( 20, 780, ME_Y_LINE4, &FontT48); + write_label_var( 20, 780, ME_Y_LINE4, &FontT48, text); + + return UNSPECIFIC_RETURN; +} + +static uint8_t OnAction_ScrubberTimerMax(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { SSettings *pSettings; uint8_t digitContentNew = EXIT_TO_MENU; @@ -397,10 +460,10 @@ newScrubberTime = MAX_SCRUBBER_TIME; pSettings = settingsGetPointer(); - pSettings->scrubTimerMax = newScrubberTime; - if(pSettings->scrubTimerCur > newScrubberTime) + pSettings->scrubberData[pSettings->scubberActiveId].TimerMax = newScrubberTime; + if(pSettings->scrubberData[pSettings->scubberActiveId].TimerCur > newScrubberTime) { - pSettings->scrubTimerCur = newScrubberTime; + pSettings->scrubberData[pSettings->scubberActiveId].TimerCur = newScrubberTime; } tMenuEdit_newInput(editId, newScrubberTime, 0, 0, 0); @@ -426,16 +489,21 @@ char text[32]; SSettings *pSettings; pSettings = settingsGetPointer(); - pSettings->scrubTimerCur = pSettings->scrubTimerMax; - + pSettings->scrubberData[pSettings->scubberActiveId].TimerCur = pSettings->scrubberData[pSettings->scubberActiveId].TimerMax; + pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay = 0; /* invalidate date */ snprintf(&text[0], 32,\ "%c\002%03u\016\016 %c\017" ,TXT_ScrubTimeReset - ,pSettings->scrubTimerCur + ,pSettings->scrubberData[pSettings->scubberActiveId].TimerCur ,TXT_Minutes); - tMenuEdit_refresh_field(StMXTRA_ScrubTimer_Reset); + tMenuEdit_newButtonText(StMXTRA_ScrubTimer_Reset, text); + + snprintf(&text[0], 32,"%c%c\002 --.--.--", TXT_2BYTE, TXT2BYTE_SimDiveTime); + clean_content( 20, 780, ME_Y_LINE4, &FontT48); + write_label_var( 20, 780, ME_Y_LINE4, &FontT48, text); + return UNSPECIFIC_RETURN; }