Mercurial > public > ostc4
diff 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 |
line wrap: on
line diff
--- a/Discovery/Src/tMenuEditXtra.c Tue Mar 07 22:14:20 2023 +0100 +++ b/Discovery/Src/tMenuEditXtra.c Wed Mar 15 09:18:07 2023 +0100 @@ -204,6 +204,19 @@ } +static void printScrubberResetText(char *text, SSettings *settings) +{ + int16_t currentTimerMinutes = settings->scrubberData[settings->scubberActiveId].TimerCur; + char colour = '\020'; + if (currentTimerMinutes <= 0) { + colour = '\025'; + } else if (currentTimerMinutes <= 30) { + colour = '\024'; + } + snprintf(text, 32, "%c\002%c%03i\016\016 %c\017", TXT_ScrubTimeReset, colour, currentTimerMinutes, TXT_Minutes); +} + + static void openEdit_Scrubber(void) { char text[32]; @@ -235,12 +248,7 @@ 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->scrubberData[pSettings->scubberActiveId].TimerCur - ,TXT_Minutes); - + printScrubberResetText(text, pSettings); write_field_button(StMXTRA_ScrubTimer_Reset, 20, 780, ME_Y_LINE3, &FontT48, text); if(pSettings->scrubberData[pSettings->scubberActiveId].lastDive.WeekDay != 0) @@ -420,11 +428,7 @@ 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); + printScrubberResetText(text, pSettings); tMenuEdit_newButtonText(StMXTRA_ScrubTimer_Reset, text); tMenuEdit_newInput(StMXTRA_ScrubTimer_Max, pSettings->scrubberData[pSettings->scubberActiveId].TimerMax, 0, 0, 0); @@ -495,12 +499,7 @@ 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->scrubberData[pSettings->scubberActiveId].TimerCur - ,TXT_Minutes); - + printScrubberResetText(text, pSettings); tMenuEdit_newButtonText(StMXTRA_ScrubTimer_Reset, text); snprintf(&text[0], 32,"%c%c\002 --.--.--", TXT_2BYTE, TXT2BYTE_SimDiveTime);