# HG changeset patch # User Ideenmodellierer # Date 1704466882 -3600 # Node ID aed39d19269c218d642e5fae1383ec6ea94db4af # Parent 18946846b95b01a17f09d52dad948e5a03fe81f9 Added T3 autofocus for Gas list: An automatic switch to the gaslist will now happen in case a better gas is available or in case the current gas is not breathable (ppo2 HIGH/LOW). From the gaslist view a new gas may be selected view quickmenu or switching to the common gas selection tab. diff -r 18946846b95b -r aed39d19269c Discovery/Src/data_central.c --- a/Discovery/Src/data_central.c Wed Dec 27 19:37:17 2023 +0100 +++ b/Discovery/Src/data_central.c Fri Jan 05 16:01:22 2024 +0100 @@ -383,6 +383,10 @@ { stateReal.diveSettings.activeAFViews |= (1 << CVIEW_T3_Navigation); } + if(t3_customview_disabled(CVIEW_T3_GasList) == 0) + { + stateReal.diveSettings.activeAFViews |= (1 << CVIEW_T3_GasList); + } } diff -r 18946846b95b -r aed39d19269c Discovery/Src/t3.c --- a/Discovery/Src/t3.c Wed Dec 27 19:37:17 2023 +0100 +++ b/Discovery/Src/t3.c Fri Jan 05 16:01:22 2024 +0100 @@ -1968,6 +1968,51 @@ return snprintf(text, size, "%c%u\016\016%%\017", colour, currentTimerMinutes * 100 / settingsGetPointer()->scrubberData[settings->scubberActiveId].TimerMax); } } + +uint8_t t3_HandleAFGaslist() +{ + static uint8_t debounce = 0; + static uint8_t lastState = AF_VIEW_NOCHANGE; + uint8_t detectionState = AF_VIEW_NOCHANGE; + + if((stateUsed->warnings.betterGas) /* switch if better gas is available or depending on ppo2 if in OC mode */ + || ((stateUsed->diveSettings.diveMode == DIVEMODE_OC) && ((stateUsed->warnings.ppO2Low) || (stateUsed->warnings.ppO2High)))) + { + if(debounce < 10) + { + debounce++; + } + else + { + detectionState = AF_VIEW_ACTIVATED; + } + } + else + { + if(debounce > 0) + { + debounce--; + } + else + { + detectionState = AF_VIEW_DEACTIVATED; + } + } + if(detectionState) /* no state change => return 0 */ + { + if((detectionState == lastState)) + { + detectionState = AF_VIEW_NOCHANGE; + } + else + { + lastState = detectionState; + } + } + + return detectionState; +} + void t3_handleAutofocus(void) { static uint8_t returnView = CVIEW_T3_END; @@ -1990,4 +2035,22 @@ break; } } + if(stateUsed->diveSettings.activeAFViews & (1 << CVIEW_T3_GasList)) + { + switch(t3_HandleAFGaslist()) + { + case AF_VIEW_ACTIVATED: returnView = t3_selection_customview; + t3_select_customview(CVIEW_T3_GasList); + + break; + case AF_VIEW_DEACTIVATED: if((returnView != CVIEW_T3_END) && (t3_selection_customview == CVIEW_T3_GasList)) + { + t3_select_customview(returnView); + returnView = CVIEW_T3_END; + } + break; + default: + break; + } + } } diff -r 18946846b95b -r aed39d19269c Discovery/Src/tHome.c --- a/Discovery/Src/tHome.c Wed Dec 27 19:37:17 2023 +0100 +++ b/Discovery/Src/tHome.c Fri Jan 05 16:01:22 2024 +0100 @@ -233,6 +233,10 @@ { set_globalState(StDMGAS); } + else + { + set_globalState(StDMENU); + } break; #ifdef ENABLE_T3_PPO_SIM case CVIEW_sensors: if(is_stateUsedSetToSim())