comparison Discovery/Src/tCCR.c @ 696:cc542448fb28

Merge
author heinrichsweikamp
date Fri, 19 Aug 2022 11:30:24 +0200
parents 1b995079c045
children 8adf9b8fc7fa
comparison
equal deleted inserted replaced
661:87bee7cc77b3 696:cc542448fb28
63 /* Based on an assumed cycle time by the sensor of 1 second. Started at time of last RX */ 63 /* Based on an assumed cycle time by the sensor of 1 second. Started at time of last RX */
64 64
65 #define BOTTLE_SENSOR_TIMEOUT (6000u) /* signal pressure budget as not received after 10 minutes (6000 * 100ms) */ 65 #define BOTTLE_SENSOR_TIMEOUT (6000u) /* signal pressure budget as not received after 10 minutes (6000 * 100ms) */
66 66
67 #define MAX_SENSOR_COMPARE_DEVIATION (0.15f) /* max deviation between two sensors allowed before their results are rated as suspect */ 67 #define MAX_SENSOR_COMPARE_DEVIATION (0.15f) /* max deviation between two sensors allowed before their results are rated as suspect */
68 #define MAX_SENSOR_VOLTAGE_MV (250u) /* max allowed voltage value for a sensor measurement */
69
70 #ifdef ENABLE_ALTERNATIVE_SENSORTYP
71 #define MIN_SENSOR_VOLTAGE_MV (3u) /* min allowed voltage value for a sensor measurement (Inspiration, Submatix, Sentinel Typ) */
72 #else
73 #define MIN_SENSOR_VOLTAGE_MV (8u) /* min allowed voltage value for a sensor measurement (legacy OSTC TYP) */
74 #endif
68 75
69 /* Private variables ---------------------------------------------------------*/ 76 /* Private variables ---------------------------------------------------------*/
70 static SIrLink receiveHUD[2]; 77 static SIrLink receiveHUD[2];
71 static uint8_t boolHUDdata = 0; 78 static uint8_t boolHUDdata = 0;
72 static uint8_t data_old__lost_connection_to_HUD = 1; 79 static uint8_t data_old__lost_connection_to_HUD = 1;
171 { 178 {
172 sensorState[i] = sensorOK; 179 sensorState[i] = sensorOK;
173 180
174 if(sensorActive[i]) 181 if(sensorActive[i])
175 { 182 {
176 if( (stateUsed->lifeData.sensorVoltage_mV[i] < 8) || 183 if( (stateUsed->lifeData.sensorVoltage_mV[i] < MIN_SENSOR_VOLTAGE_MV) ||
177 (stateUsed->lifeData.sensorVoltage_mV[i] > 250)) 184 (stateUsed->lifeData.sensorVoltage_mV[i] > MAX_SENSOR_VOLTAGE_MV))
178 { 185 {
179 sensorActive[i] = 0; 186 sensorActive[i] = 0;
180 switch(i) 187 switch(i)
181 { 188 {
182 case 0: 189 case 0:
328 tCCR_fallbackToFixedSetpoint(); 335 tCCR_fallbackToFixedSetpoint();
329 } 336 }
330 } 337 }
331 338
332 /* decrease scrubber timer only in real dive mode */ 339 /* decrease scrubber timer only in real dive mode */
333 if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (pSettings->dive_mode == DIVEMODE_CCR) && (stateUsed->mode == MODE_DIVE) && (stateUsed == stateRealGetPointer())) 340 if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (isLoopMode(pSettings->dive_mode)) && (stateUsed->mode == MODE_DIVE) && (stateUsed == stateRealGetPointer()))
334 { 341 {
335 ScrubberTimeoutCount++; 342 ScrubberTimeoutCount++;
336 if(ScrubberTimeoutCount >= 600) /* resolution is minutes */ 343 if(ScrubberTimeoutCount >= 600) /* resolution is minutes */
337 { 344 {
338 ScrubberTimeoutCount = 0; 345 ScrubberTimeoutCount = 0;
442 /* Private functions ---------------------------------------------------------*/ 449 /* Private functions ---------------------------------------------------------*/
443 450
444 static uint8_t tCCR_fallbackToFixedSetpoint(void) 451 static uint8_t tCCR_fallbackToFixedSetpoint(void)
445 { 452 {
446 uint8_t retVal = 0; 453 uint8_t retVal = 0;
447 if((stateUsed->mode == MODE_DIVE) && (stateUsed->diveSettings.diveMode == DIVEMODE_CCR) && (stateUsed->diveSettings.CCR_Mode == CCRMODE_Sensors) && (stateUsed->diveSettings.fallbackOption)) 454 uint8_t setpointCbar, actualGasID;
448 { 455
449 uint8_t setpointCbar, actualGasID; 456 if((stateUsed->mode == MODE_DIVE) && (stateUsed->diveSettings.CCR_Mode == CCRMODE_Sensors) && (stateUsed->diveSettings.fallbackOption))
450 457 {
451 setpointCbar = stateUsed->diveSettings.setpoint[1].setpoint_cbar; 458 if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR)
452 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint; 459 {
453 460 setpointCbar = stateUsed->diveSettings.setpoint[1].setpoint_cbar;
454 actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings; 461 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint;
455 setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar); 462 }
456 463 else
457 set_warning_fallback(); 464 {
458 retVal = stateUsed->diveSettings.setpoint[1].setpoint_cbar; 465 setpointCbar = stateUsed->lifeData.ppo2Simulated_bar * 100;
466 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_Simulation;
467 }
468 actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings;
469 setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar);
470
471 set_warning_fallback();
472 retVal = setpointCbar;
459 } 473 }
460 return retVal; 474 return retVal;
461 } 475 }