Mercurial > public > ostc4
comparison Discovery/Src/t3.c @ 1014:8c0134a287da GasConsumption
Add a log data event to the scrubber timer at the start of the dive and every time the timer (in minutes)
is decremented. The event contains a 12 bit signed integer for the remaining scrubber duration, and two
flags for scrubber warning (0x2000, <= 30 minutes remaining) and scrubber error (0x4000, <= 0 minutes remaining).
(mikeller)
| author | heinrichsweikamp |
|---|---|
| date | Sun, 11 May 2025 16:18:20 +0200 |
| parents | 5a690195b6b7 |
| children | 6e11f7327efd |
comparison
equal
deleted
inserted
replaced
| 1013:fa1af49319e5 | 1014:8c0134a287da |
|---|---|
| 31 #include <stdlib.h> | 31 #include <stdlib.h> |
| 32 | 32 |
| 33 #include "t3.h" | 33 #include "t3.h" |
| 34 | 34 |
| 35 #include "data_exchange_main.h" | 35 #include "data_exchange_main.h" |
| 36 #include "settings.h" | |
| 36 #include "decom.h" | 37 #include "decom.h" |
| 37 #include "gfx_fonts.h" | 38 #include "gfx_fonts.h" |
| 38 #include "math.h" | 39 #include "math.h" |
| 39 #include "tHome.h" | 40 #include "tHome.h" |
| 40 #include "timer.h" | 41 #include "timer.h" |
| 1332 } | 1333 } |
| 1333 snprintf(&text[textpointer],TEXTSIZE,"\001%5ld",stateUsed->lifeData.CO2_data.CO2_ppm); | 1334 snprintf(&text[textpointer],TEXTSIZE,"\001%5ld",stateUsed->lifeData.CO2_data.CO2_ppm); |
| 1334 GFX_write_string(&FontT105,tXc1,text,1); | 1335 GFX_write_string(&FontT105,tXc1,text,1); |
| 1335 } | 1336 } |
| 1336 | 1337 |
| 1337 if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && isLoopMode(pSettings->dive_mode)) | 1338 if (isScrubberTimerEnabled(pSettings)) { |
| 1338 { | |
| 1339 snprintf(text,TEXTSIZE,"\032\002\f%c",TXT_ScrubTime); | 1339 snprintf(text,TEXTSIZE,"\032\002\f%c",TXT_ScrubTime); |
| 1340 GFX_write_string(&FontT42,tXc1,text,0); | 1340 GFX_write_string(&FontT42,tXc1,text,0); |
| 1341 | 1341 |
| 1342 textpointer = 0; | 1342 textpointer = 0; |
| 1343 text[textpointer++] = '\002'; | 1343 text[textpointer++] = '\002'; |
| 1344 textpointer += printScrubberText(&text[textpointer], 10, stateUsed->scrubberDataDive, pSettings); | 1344 textpointer += printScrubberText(&text[textpointer], 10, stateUsed->scrubberDataDive, pSettings, false); |
| 1345 GFX_write_string(&FontT105,tXc1,text,1); | 1345 GFX_write_string(&FontT105,tXc1,text,1); |
| 1346 } | 1346 } |
| 1347 } | 1347 } |
| 1348 break; | 1348 break; |
| 1349 | 1349 |
| 1994 uint8_t t3_getCustomView(void) | 1994 uint8_t t3_getCustomView(void) |
| 1995 { | 1995 { |
| 1996 return t3_selection_customview; | 1996 return t3_selection_customview; |
| 1997 } | 1997 } |
| 1998 | 1998 |
| 1999 int printScrubberText(char *text, size_t size, const SScrubberData *scrubberData, SSettings *settings) | 1999 unsigned printScrubberText(char *text, size_t size, const SScrubberData scrubberData[], const SSettings *settings, bool useTwoLines) |
| 2000 { | 2000 { |
| 2001 uint8_t timerId = 0; | 2001 unsigned textIndex = 0; |
| 2002 int16_t currentTimerMinutes = 0; | 2002 for (unsigned timerId = 0; timerId < 2; timerId++) { |
| 2003 char colour = 0; | 2003 if (settings->scrubberActiveId & (1 << timerId)) { |
| 2004 uint8_t textIndex = 0; | 2004 const SScrubberData *currentScrubberData = &scrubberData[timerId]; |
| 2005 | 2005 char colour = '\020'; |
| 2006 for(timerId = 0; timerId < 2; timerId++) | 2006 if (isScrubberError(currentScrubberData)) { |
| 2007 { | 2007 colour = '\025'; |
| 2008 if(settings->scubberActiveId & (1 << timerId)) | 2008 } else if (isScrubberWarning(currentScrubberData)) { |
| 2009 { | 2009 colour = '\024'; |
| 2010 currentTimerMinutes = scrubberData[timerId].TimerCur; | 2010 } |
| 2011 colour = '\020'; | 2011 |
| 2012 if (currentTimerMinutes <= 0) | 2012 if (useTwoLines) { |
| 2013 { | 2013 textIndex += snprintf(&text[textIndex], size, "\016\016"); |
| 2014 colour = '\025'; | 2014 } |
| 2015 | |
| 2016 int16_t currentTimerMinutes = currentScrubberData->TimerCur; | |
| 2017 if (settings->scrubTimerMode == SCRUB_TIMER_MINUTES || currentTimerMinutes < 0) { | |
| 2018 textIndex += snprintf(&text[textIndex], size, "%c%3i'", colour, currentTimerMinutes); | |
| 2019 } else { | |
| 2020 if (useTwoLines) { | |
| 2021 textIndex += snprintf(&text[textIndex], size, "%c%u%%", colour, currentTimerMinutes * 100 / settings->scrubberData[timerId].TimerMax); | |
| 2022 } else { | |
| 2023 textIndex += snprintf(&text[textIndex], size, "%c%u\016\016%%\017", colour, currentTimerMinutes * 100 / settings->scrubberData[timerId].TimerMax); | |
| 2024 } | |
| 2025 } | |
| 2026 | |
| 2027 if (settings->scrubberActiveId == 0x03 && timerId == 0) { | |
| 2028 /* both timers are active => print separator */ | |
| 2029 if (useTwoLines) { | |
| 2030 textIndex += snprintf(&text[textIndex], size, "\r\n"); | |
| 2031 } else { | |
| 2032 textIndex += snprintf(&text[textIndex], size, "\020|"); | |
| 2033 } | |
| 2015 } | 2034 } |
| 2016 else if (currentTimerMinutes <= 30) | 2035 } |
| 2017 { | 2036 } |
| 2018 colour = '\024'; | 2037 |
| 2019 } | |
| 2020 if (settings->scrubTimerMode == SCRUB_TIMER_MINUTES || currentTimerMinutes < 0) | |
| 2021 { | |
| 2022 textIndex += snprintf(&text[textIndex], size, "%c%3i'", colour, currentTimerMinutes); | |
| 2023 } | |
| 2024 else | |
| 2025 { | |
| 2026 textIndex += snprintf(&text[textIndex], size, "%c%u\016\016%%\017", colour, currentTimerMinutes * 100 / settingsGetPointer()->scrubberData[timerId].TimerMax); | |
| 2027 } | |
| 2028 if((settings->scubberActiveId == 3) && (timerId == 0)) /* both timers are active => print separator */ | |
| 2029 { | |
| 2030 textIndex += snprintf(&text[textIndex], size, " | "); | |
| 2031 } | |
| 2032 } | |
| 2033 } | |
| 2034 return textIndex; | 2038 return textIndex; |
| 2035 } | 2039 } |
| 2036 | 2040 |
| 2037 void t3_AF_updateBorderConditions() | 2041 void t3_AF_updateBorderConditions() |
| 2038 { | 2042 { |
