Mercurial > public > ostc4
diff Discovery/Src/tCCR.c @ 696:cc542448fb28
Merge
author | heinrichsweikamp |
---|---|
date | Fri, 19 Aug 2022 11:30:24 +0200 |
parents | 1b995079c045 |
children | 8adf9b8fc7fa |
line wrap: on
line diff
--- a/Discovery/Src/tCCR.c Mon Nov 01 12:39:34 2021 +0100 +++ b/Discovery/Src/tCCR.c Fri Aug 19 11:30:24 2022 +0200 @@ -65,6 +65,13 @@ #define BOTTLE_SENSOR_TIMEOUT (6000u) /* signal pressure budget as not received after 10 minutes (6000 * 100ms) */ #define MAX_SENSOR_COMPARE_DEVIATION (0.15f) /* max deviation between two sensors allowed before their results are rated as suspect */ +#define MAX_SENSOR_VOLTAGE_MV (250u) /* max allowed voltage value for a sensor measurement */ + +#ifdef ENABLE_ALTERNATIVE_SENSORTYP +#define MIN_SENSOR_VOLTAGE_MV (3u) /* min allowed voltage value for a sensor measurement (Inspiration, Submatix, Sentinel Typ) */ +#else +#define MIN_SENSOR_VOLTAGE_MV (8u) /* min allowed voltage value for a sensor measurement (legacy OSTC TYP) */ +#endif /* Private variables ---------------------------------------------------------*/ static SIrLink receiveHUD[2]; @@ -173,8 +180,8 @@ if(sensorActive[i]) { - if( (stateUsed->lifeData.sensorVoltage_mV[i] < 8) || - (stateUsed->lifeData.sensorVoltage_mV[i] > 250)) + if( (stateUsed->lifeData.sensorVoltage_mV[i] < MIN_SENSOR_VOLTAGE_MV) || + (stateUsed->lifeData.sensorVoltage_mV[i] > MAX_SENSOR_VOLTAGE_MV)) { sensorActive[i] = 0; switch(i) @@ -330,7 +337,7 @@ } /* decrease scrubber timer only in real dive mode */ - if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (pSettings->dive_mode == DIVEMODE_CCR) && (stateUsed->mode == MODE_DIVE) && (stateUsed == stateRealGetPointer())) + if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (isLoopMode(pSettings->dive_mode)) && (stateUsed->mode == MODE_DIVE) && (stateUsed == stateRealGetPointer())) { ScrubberTimeoutCount++; if(ScrubberTimeoutCount >= 600) /* resolution is minutes */ @@ -444,18 +451,25 @@ 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; + uint8_t setpointCbar, actualGasID; - setpointCbar = stateUsed->diveSettings.setpoint[1].setpoint_cbar; - stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint; + if((stateUsed->mode == MODE_DIVE) && (stateUsed->diveSettings.CCR_Mode == CCRMODE_Sensors) && (stateUsed->diveSettings.fallbackOption)) + { + if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR) + { + setpointCbar = stateUsed->diveSettings.setpoint[1].setpoint_cbar; + stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint; + } + else + { + setpointCbar = stateUsed->lifeData.ppo2Simulated_bar * 100; + stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_Simulation; + } + actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings; + setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar); - actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings; - setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar); - - set_warning_fallback(); - retVal = stateUsed->diveSettings.setpoint[1].setpoint_cbar; + set_warning_fallback(); + retVal = setpointCbar; } return retVal; }