Mercurial > public > ostc4
changeset 635:66c8a4ff9fc4
Debounce fallback warning:
In previous versions the fallback option (automatical setting of a fixed setpoint) was only done for communication timeout scenario in combination with a HUD. It is now also applied in case all sensors are rated as out of bounds. The signaling of the fallback warning (including optional automatic setpoint change) is now done taking a 5 seconds debounds time into account.
In case a fallback warning is active, then the only way to reset it is by selecting a new setpoint or by changing the sensor configuration (no change compared to previous implementation
author | Ideenmodellierer |
---|---|
date | Wed, 24 Feb 2021 21:03:22 +0100 |
parents | 7c73f066cd16 |
children | c47766ec3f96 |
files | Discovery/Src/tCCR.c |
diffstat | 1 files changed, 18 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Discovery/Src/tCCR.c Wed Feb 24 19:18:26 2021 +0100 +++ b/Discovery/Src/tCCR.c Wed Feb 24 21:03:22 2021 +0100 @@ -82,7 +82,7 @@ /* Private variables with external access via get_xxx() function -------------*/ /* Private function prototypes -----------------------------------------------*/ -static void tCCR_fallbackToFixedSetpoint(void); +static uint8_t tCCR_fallbackToFixedSetpoint(void); #ifndef USART_IR_HUD @@ -252,7 +252,7 @@ } } - +/* this function is called out of the 100ms callback => to be considered for debouncing */ uint8_t get_ppO2SensorWeightedResult_cbar(void) { static uint8_t lastValidValue = 0; @@ -273,13 +273,21 @@ } if(count == 0) /* all sensors out of bounds! => return last valid value as workaround till diver takes action */ { - set_warning_fallback(); - retVal = lastValidValue; + if(debounce_warning_fallback(100)) + { + set_warning_fallback(); + retVal = tCCR_fallbackToFixedSetpoint(); /* this function only changes setpoint if option is enabled */ + } + if(retVal == 0) + { + retVal = lastValidValue; + } } else { - retVal = (uint8_t)(result / count); - lastValidValue = retVal; + reset_debounce_warning_fallback(); + retVal = (uint8_t)(result / count); + lastValidValue = retVal; } return retVal; } @@ -416,8 +424,9 @@ #endif /* Private functions ---------------------------------------------------------*/ -static void tCCR_fallbackToFixedSetpoint(void) +static uint8_t tCCR_fallbackToFixedSetpoint(void) { + uint8_t retVal = 0; if((stateUsed->mode == MODE_DIVE) && (stateUsed->diveSettings.diveMode == DIVEMODE_CCR) && (stateUsed->diveSettings.CCR_Mode == CCRMODE_Sensors) && (stateUsed->diveSettings.fallbackOption)) { uint8_t setpointCbar, actualGasID; @@ -429,5 +438,7 @@ setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar); set_warning_fallback(); + retVal = stateUsed->diveSettings.setpoint[1].setpoint_cbar; } + return retVal; }