Mercurial > public > ostc4
comparison 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 |
comparison
equal
deleted
inserted
replaced
709:c799151670d5 | 710:8adf9b8fc7fa |
---|---|
56 static void openEdit_CO2Sensor(void); | 56 static void openEdit_CO2Sensor(void); |
57 #endif | 57 #endif |
58 | 58 |
59 /* Announced function prototypes -----------------------------------------------*/ | 59 /* Announced function prototypes -----------------------------------------------*/ |
60 uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 60 uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
61 static uint8_t OnAction_ScrubberTimer(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 61 uint8_t OnAction_ScrubberTimerId(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
62 static uint8_t OnAction_ScrubberTimerMax(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
62 static uint8_t OnAction_ScrubberReset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 63 static uint8_t OnAction_ScrubberReset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
63 static uint8_t OnAction_ScrubberMode(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 64 static uint8_t OnAction_ScrubberMode(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
64 #ifdef ENABLE_PSCR_MODE | 65 #ifdef ENABLE_PSCR_MODE |
65 static uint8_t OnAction_PSCRO2Drop(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 66 static uint8_t OnAction_PSCRO2Drop(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
66 static uint8_t OnAction_PSCRLungRation(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 67 static uint8_t OnAction_PSCRLungRation(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
70 static uint8_t OnAction_CO2OnOff(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 71 static uint8_t OnAction_CO2OnOff(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
71 static uint8_t OnAction_CO2Calib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 72 static uint8_t OnAction_CO2Calib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
72 #endif | 73 #endif |
73 | 74 |
74 /* Exported functions --------------------------------------------------------*/ | 75 /* Exported functions --------------------------------------------------------*/ |
76 | |
75 | 77 |
76 void openEdit_Xtra(uint8_t line) | 78 void openEdit_Xtra(uint8_t line) |
77 { | 79 { |
78 set_globalState_Menu_Line(line); | 80 set_globalState_Menu_Line(line); |
79 | 81 |
208 uint8_t textIndex = 0; | 210 uint8_t textIndex = 0; |
209 uint16_t localScrubTimer; | 211 uint16_t localScrubTimer; |
210 | 212 |
211 SSettings *pSettings = settingsGetPointer(); | 213 SSettings *pSettings = settingsGetPointer(); |
212 | 214 |
213 localScrubTimer = pSettings->scrubTimerMax; | 215 localScrubTimer = pSettings->scrubberData[pSettings->scubberActiveId].TimerMax; |
214 | 216 |
215 resetMenuEdit(CLUT_MenuPageXtra); | 217 resetMenuEdit(CLUT_MenuPageXtra); |
216 | 218 |
217 | 219 |
218 snprintf(&text[textIndex], 32,"\001%c",TXT_ScrubTime); | 220 snprintf(&text[0], 32,"\001%c",TXT_ScrubTime); |
219 write_topline(text); | 221 write_topline(text); |
220 | 222 |
223 | |
224 snprintf(&text[0], 32,"%c \002#%d",TXT_ScrubTime,pSettings->scubberActiveId); | |
225 write_field_button(StMXTRA_ScrubTimer, 20, 780, ME_Y_LINE1, &FontT48, text); | |
221 | 226 |
222 snprintf(&text[textIndex], 32,\ | 227 snprintf(&text[textIndex], 32,\ |
223 "%c" | 228 "%c" |
224 "\016\016(%c)\017" | 229 "\016\016(%c)\017" |
225 ,TXT_ScrubTime | 230 ,TXT_ScrubTime |
226 ,TXT_Maximum); | 231 ,TXT_Maximum); |
227 | 232 |
228 write_label_var( 20, 340, ME_Y_LINE1, &FontT48, text); | 233 write_label_var( 20, 340, ME_Y_LINE2, &FontT48, text); |
229 snprintf(&text[textIndex], 32, "\002###\016\016 %c\017",TXT_Minutes); | 234 snprintf(&text[textIndex], 32, "\002###\016\016 %c\017",TXT_Minutes); |
230 | 235 |
231 write_field_udigit(StMXTRA_ScrubTimer, 610, 780, ME_Y_LINE1, &FontT48, text,localScrubTimer, 0, 0, 0); | 236 write_field_udigit(StMXTRA_ScrubTimer_Max, 610, 780, ME_Y_LINE2, &FontT48, text,localScrubTimer, 0, 0, 0); |
232 | 237 |
233 snprintf(&text[0], 32,\ | 238 snprintf(&text[0], 32,\ |
234 "%c\002%03u\016\016 %c\017" | 239 "%c\002%03u\016\016 %c\017" |
235 ,TXT_ScrubTimeReset | 240 ,TXT_ScrubTimeReset |
236 ,pSettings->scrubTimerCur | 241 ,pSettings->scrubberData[pSettings->scubberActiveId].TimerCur |
237 ,TXT_Minutes); | 242 ,TXT_Minutes); |
238 | 243 |
239 write_field_button(StMXTRA_ScrubTimer_Reset, 20, 780, ME_Y_LINE2, &FontT48, text); | 244 write_field_button(StMXTRA_ScrubTimer_Reset, 20, 780, ME_Y_LINE3, &FontT48, text); |
245 | |
246 if(pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay != 0) | |
247 { | |
248 snprintf(&text[0], 32,"%c%c\002 %02d.%02d.%02d", TXT_2BYTE, TXT2BYTE_SimDiveTime, pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Date, | |
249 pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Month, | |
250 pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Year); | |
251 } | |
252 else | |
253 { | |
254 snprintf(&text[0], 32,"%c%c\002 --.--.--", TXT_2BYTE, TXT2BYTE_SimDiveTime); | |
255 } | |
256 write_label_var( 20, 780, ME_Y_LINE4, &FontT48, text); | |
240 | 257 |
241 switch(pSettings->scrubTimerMode) | 258 switch(pSettings->scrubTimerMode) |
242 { | 259 { |
243 case SCRUB_TIMER_OFF: | 260 case SCRUB_TIMER_OFF: |
244 default: snprintf(&text[0], 32,"%c\002%c%c",TXT_ScrubTimeMode, TXT_2BYTE, TXT2BYTE_MoCtrlNone ); | 261 default: snprintf(&text[0], 32,"%c\002%c%c",TXT_ScrubTimeMode, TXT_2BYTE, TXT2BYTE_MoCtrlNone ); |
246 case SCRUB_TIMER_MINUTES: snprintf(&text[0], 32,"%c\002%c",TXT_ScrubTimeMode, TXT_Minutes ); | 263 case SCRUB_TIMER_MINUTES: snprintf(&text[0], 32,"%c\002%c",TXT_ScrubTimeMode, TXT_Minutes ); |
247 break; | 264 break; |
248 case SCRUB_TIMER_PERCENT: snprintf(&text[0], 32,"%c\002%c",TXT_ScrubTimeMode, TXT_Percent ); | 265 case SCRUB_TIMER_PERCENT: snprintf(&text[0], 32,"%c\002%c",TXT_ScrubTimeMode, TXT_Percent ); |
249 break; | 266 break; |
250 } | 267 } |
251 write_field_button(StMXTRA_ScrubTimer_OP_Mode, 30, 780, ME_Y_LINE3, &FontT48, text); | 268 write_field_button(StMXTRA_ScrubTimer_OP_Mode, 20, 780, ME_Y_LINE5, &FontT48, text); |
252 | 269 |
253 setEvent(StMXTRA_ScrubTimer, (uint32_t)OnAction_ScrubberTimer); | 270 setEvent(StMXTRA_ScrubTimer, (uint32_t)OnAction_ScrubberTimerId); |
271 setEvent(StMXTRA_ScrubTimer_Max, (uint32_t)OnAction_ScrubberTimerMax); | |
254 setEvent(StMXTRA_ScrubTimer_Reset, (uint32_t)OnAction_ScrubberReset); | 272 setEvent(StMXTRA_ScrubTimer_Reset, (uint32_t)OnAction_ScrubberReset); |
255 setEvent(StMXTRA_ScrubTimer_OP_Mode, (uint32_t)OnAction_ScrubberMode); | 273 setEvent(StMXTRA_ScrubTimer_OP_Mode, (uint32_t)OnAction_ScrubberMode); |
256 | 274 |
257 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | 275 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); |
258 | 276 |
377 stateUsedWrite->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; | 395 stateUsedWrite->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; |
378 exitMenuEdit_to_Home_with_Menu_Update(); | 396 exitMenuEdit_to_Home_with_Menu_Update(); |
379 return EXIT_TO_HOME; | 397 return EXIT_TO_HOME; |
380 } | 398 } |
381 | 399 |
382 static uint8_t OnAction_ScrubberTimer(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 400 |
401 uint8_t OnAction_ScrubberTimerId(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
402 { | |
403 char text[32]; | |
404 SSettings *pSettings; | |
405 pSettings = settingsGetPointer(); | |
406 | |
407 if(pSettings->scubberActiveId == 0) | |
408 { | |
409 pSettings->scubberActiveId = 1; | |
410 } | |
411 else | |
412 { | |
413 pSettings->scubberActiveId = 0; | |
414 } | |
415 | |
416 | |
417 snprintf(&text[0], 32,"%c \002#%d",TXT_ScrubTime,pSettings->scubberActiveId); | |
418 tMenuEdit_newButtonText(StMXTRA_ScrubTimer, text); | |
419 | |
420 snprintf(&text[0], 32,\ | |
421 "%c\002%03u\016\016 %c\017" | |
422 ,TXT_ScrubTimeReset | |
423 ,pSettings->scrubberData[pSettings->scubberActiveId].TimerCur | |
424 ,TXT_Minutes); | |
425 tMenuEdit_newButtonText(StMXTRA_ScrubTimer_Reset, text); | |
426 | |
427 tMenuEdit_newInput(StMXTRA_ScrubTimer_Max, pSettings->scrubberData[pSettings->scubberActiveId].TimerMax, 0, 0, 0); | |
428 | |
429 if(pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay != 0) | |
430 { | |
431 snprintf(&text[0], 32,"%c%c\002 %02d.%02d.%02d", TXT_2BYTE, TXT2BYTE_SimDiveTime, pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Date, | |
432 pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Month, | |
433 pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Year); | |
434 } | |
435 else | |
436 { | |
437 snprintf(&text[0], 32,"%c%c\002 --.--.--", TXT_2BYTE, TXT2BYTE_SimDiveTime); | |
438 } | |
439 clean_content( 20, 780, ME_Y_LINE4, &FontT48); | |
440 write_label_var( 20, 780, ME_Y_LINE4, &FontT48, text); | |
441 | |
442 return UNSPECIFIC_RETURN; | |
443 } | |
444 | |
445 static uint8_t OnAction_ScrubberTimerMax(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
383 { | 446 { |
384 SSettings *pSettings; | 447 SSettings *pSettings; |
385 uint8_t digitContentNew = EXIT_TO_MENU; | 448 uint8_t digitContentNew = EXIT_TO_MENU; |
386 uint32_t newScrubberTime; | 449 uint32_t newScrubberTime; |
387 | 450 |
395 | 458 |
396 if(newScrubberTime > MAX_SCRUBBER_TIME) | 459 if(newScrubberTime > MAX_SCRUBBER_TIME) |
397 newScrubberTime = MAX_SCRUBBER_TIME; | 460 newScrubberTime = MAX_SCRUBBER_TIME; |
398 | 461 |
399 pSettings = settingsGetPointer(); | 462 pSettings = settingsGetPointer(); |
400 pSettings->scrubTimerMax = newScrubberTime; | 463 pSettings->scrubberData[pSettings->scubberActiveId].TimerMax = newScrubberTime; |
401 if(pSettings->scrubTimerCur > newScrubberTime) | 464 if(pSettings->scrubberData[pSettings->scubberActiveId].TimerCur > newScrubberTime) |
402 { | 465 { |
403 pSettings->scrubTimerCur = newScrubberTime; | 466 pSettings->scrubberData[pSettings->scubberActiveId].TimerCur = newScrubberTime; |
404 } | 467 } |
405 | 468 |
406 tMenuEdit_newInput(editId, newScrubberTime, 0, 0, 0); | 469 tMenuEdit_newInput(editId, newScrubberTime, 0, 0, 0); |
407 digitContentNew = UNSPECIFIC_RETURN; | 470 digitContentNew = UNSPECIFIC_RETURN; |
408 } | 471 } |
424 uint8_t OnAction_ScrubberReset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 487 uint8_t OnAction_ScrubberReset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
425 { | 488 { |
426 char text[32]; | 489 char text[32]; |
427 SSettings *pSettings; | 490 SSettings *pSettings; |
428 pSettings = settingsGetPointer(); | 491 pSettings = settingsGetPointer(); |
429 pSettings->scrubTimerCur = pSettings->scrubTimerMax; | 492 pSettings->scrubberData[pSettings->scubberActiveId].TimerCur = pSettings->scrubberData[pSettings->scubberActiveId].TimerMax; |
430 | 493 pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay = 0; /* invalidate date */ |
431 | 494 |
432 snprintf(&text[0], 32,\ | 495 snprintf(&text[0], 32,\ |
433 "%c\002%03u\016\016 %c\017" | 496 "%c\002%03u\016\016 %c\017" |
434 ,TXT_ScrubTimeReset | 497 ,TXT_ScrubTimeReset |
435 ,pSettings->scrubTimerCur | 498 ,pSettings->scrubberData[pSettings->scubberActiveId].TimerCur |
436 ,TXT_Minutes); | 499 ,TXT_Minutes); |
437 | 500 |
438 tMenuEdit_refresh_field(StMXTRA_ScrubTimer_Reset); | 501 tMenuEdit_newButtonText(StMXTRA_ScrubTimer_Reset, text); |
502 | |
503 snprintf(&text[0], 32,"%c%c\002 --.--.--", TXT_2BYTE, TXT2BYTE_SimDiveTime); | |
504 clean_content( 20, 780, ME_Y_LINE4, &FontT48); | |
505 write_label_var( 20, 780, ME_Y_LINE4, &FontT48, text); | |
506 | |
439 | 507 |
440 return UNSPECIFIC_RETURN; | 508 return UNSPECIFIC_RETURN; |
441 } | 509 } |
442 | 510 |
443 uint8_t OnAction_ScrubberMode(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 511 uint8_t OnAction_ScrubberMode(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |