comparison Discovery/Src/tMenuEditXtra.c @ 758:b6d8a6fbf4fd

- Colours for scrubber display when time remaining falls below a threshold value - Display negative values when time is up and diving continues; - count down remaining scrubber time only when the dive computer is not set to bailout - after all, there is not much point in counting down time if the diver is not breathing through the scrubber.
author heinrichsweikamp
date Wed, 15 Mar 2023 09:18:07 +0100
parents be25ab2d902c
children 6b248bcdbf28
comparison
equal deleted inserted replaced
757:39ff186b6f98 758:b6d8a6fbf4fd
202 } 202 }
203 exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only(); 203 exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only();
204 } 204 }
205 205
206 206
207 static void printScrubberResetText(char *text, SSettings *settings)
208 {
209 int16_t currentTimerMinutes = settings->scrubberData[settings->scubberActiveId].TimerCur;
210 char colour = '\020';
211 if (currentTimerMinutes <= 0) {
212 colour = '\025';
213 } else if (currentTimerMinutes <= 30) {
214 colour = '\024';
215 }
216 snprintf(text, 32, "%c\002%c%03i\016\016 %c\017", TXT_ScrubTimeReset, colour, currentTimerMinutes, TXT_Minutes);
217 }
218
219
207 static void openEdit_Scrubber(void) 220 static void openEdit_Scrubber(void)
208 { 221 {
209 char text[32]; 222 char text[32];
210 uint8_t textIndex = 0; 223 uint8_t textIndex = 0;
211 uint16_t localScrubTimer; 224 uint16_t localScrubTimer;
233 write_label_var( 20, 340, ME_Y_LINE2, &FontT48, text); 246 write_label_var( 20, 340, ME_Y_LINE2, &FontT48, text);
234 snprintf(&text[textIndex], 32, "\002###\016\016 %c\017",TXT_Minutes); 247 snprintf(&text[textIndex], 32, "\002###\016\016 %c\017",TXT_Minutes);
235 248
236 write_field_udigit(StMXTRA_ScrubTimer_Max, 610, 780, ME_Y_LINE2, &FontT48, text,localScrubTimer, 0, 0, 0); 249 write_field_udigit(StMXTRA_ScrubTimer_Max, 610, 780, ME_Y_LINE2, &FontT48, text,localScrubTimer, 0, 0, 0);
237 250
238 snprintf(&text[0], 32,\ 251 printScrubberResetText(text, pSettings);
239 "%c\002%03u\016\016 %c\017"
240 ,TXT_ScrubTimeReset
241 ,pSettings->scrubberData[pSettings->scubberActiveId].TimerCur
242 ,TXT_Minutes);
243
244 write_field_button(StMXTRA_ScrubTimer_Reset, 20, 780, ME_Y_LINE3, &FontT48, text); 252 write_field_button(StMXTRA_ScrubTimer_Reset, 20, 780, ME_Y_LINE3, &FontT48, text);
245 253
246 if(pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay != 0) 254 if(pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay != 0)
247 { 255 {
248 snprintf(&text[0], 32,"%c%c\002 %02d.%02d.%02d", TXT_2BYTE, TXT2BYTE_SimDiveTime, pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Date, 256 snprintf(&text[0], 32,"%c%c\002 %02d.%02d.%02d", TXT_2BYTE, TXT2BYTE_SimDiveTime, pSettings->scrubberData[pSettings->scubberActiveId].lastDive.Date,
418 426
419 427
420 snprintf(&text[0], 32,"%c \002#%d",TXT_ScrubTime,pSettings->scubberActiveId); 428 snprintf(&text[0], 32,"%c \002#%d",TXT_ScrubTime,pSettings->scubberActiveId);
421 tMenuEdit_newButtonText(StMXTRA_ScrubTimer, text); 429 tMenuEdit_newButtonText(StMXTRA_ScrubTimer, text);
422 430
423 snprintf(&text[0], 32,\ 431 printScrubberResetText(text, pSettings);
424 "%c\002%03u\016\016 %c\017"
425 ,TXT_ScrubTimeReset
426 ,pSettings->scrubberData[pSettings->scubberActiveId].TimerCur
427 ,TXT_Minutes);
428 tMenuEdit_newButtonText(StMXTRA_ScrubTimer_Reset, text); 432 tMenuEdit_newButtonText(StMXTRA_ScrubTimer_Reset, text);
429 433
430 tMenuEdit_newInput(StMXTRA_ScrubTimer_Max, pSettings->scrubberData[pSettings->scubberActiveId].TimerMax, 0, 0, 0); 434 tMenuEdit_newInput(StMXTRA_ScrubTimer_Max, pSettings->scrubberData[pSettings->scubberActiveId].TimerMax, 0, 0, 0);
431 435
432 if(pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay != 0) 436 if(pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay != 0)
493 SSettings *pSettings; 497 SSettings *pSettings;
494 pSettings = settingsGetPointer(); 498 pSettings = settingsGetPointer();
495 pSettings->scrubberData[pSettings->scubberActiveId].TimerCur = pSettings->scrubberData[pSettings->scubberActiveId].TimerMax; 499 pSettings->scrubberData[pSettings->scubberActiveId].TimerCur = pSettings->scrubberData[pSettings->scubberActiveId].TimerMax;
496 pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay = 0; /* invalidate date */ 500 pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay = 0; /* invalidate date */
497 501
498 snprintf(&text[0], 32,\ 502 printScrubberResetText(text, pSettings);
499 "%c\002%03u\016\016 %c\017"
500 ,TXT_ScrubTimeReset
501 ,pSettings->scrubberData[pSettings->scubberActiveId].TimerCur
502 ,TXT_Minutes);
503
504 tMenuEdit_newButtonText(StMXTRA_ScrubTimer_Reset, text); 503 tMenuEdit_newButtonText(StMXTRA_ScrubTimer_Reset, text);
505 504
506 snprintf(&text[0], 32,"%c%c\002 --.--.--", TXT_2BYTE, TXT2BYTE_SimDiveTime); 505 snprintf(&text[0], 32,"%c%c\002 --.--.--", TXT_2BYTE, TXT2BYTE_SimDiveTime);
507 clean_content( 20, 780, ME_Y_LINE4, &FontT48); 506 clean_content( 20, 780, ME_Y_LINE4, &FontT48);
508 write_label_var( 20, 780, ME_Y_LINE4, &FontT48, text); 507 write_label_var( 20, 780, ME_Y_LINE4, &FontT48, text);