comparison Discovery/Src/check_warning.c @ 662:1b995079c045 Betatest

PSCR Mode
author heinrichs weikamp
date Tue, 14 Dec 2021 15:36:10 +0100
parents c47766ec3f96
children b456be1e152d
comparison
equal deleted inserted replaced
661:87bee7cc77b3 662:1b995079c045
126 126
127 127
128 /* Private functions ---------------------------------------------------------*/ 128 /* Private functions ---------------------------------------------------------*/
129 static int8_t check_fallback(SDiveState * pDiveState) 129 static int8_t check_fallback(SDiveState * pDiveState)
130 { 130 {
131 if(fallback && ((pDiveState->mode != MODE_DIVE) || (pDiveState->diveSettings.diveMode != DIVEMODE_CCR))) 131 if(fallback && ((pDiveState->mode != MODE_DIVE) || (!isLoopMode(pDiveState->diveSettings.diveMode))))
132 fallback = 0; 132 fallback = 0;
133 133
134 pDiveState->warnings.fallback = fallback; 134 pDiveState->warnings.fallback = fallback;
135 return pDiveState->warnings.fallback; 135 return pDiveState->warnings.fallback;
136 } 136 }
179 pDiveState->warnings.sensorLinkLost = 0; 179 pDiveState->warnings.sensorLinkLost = 0;
180 pDiveState->warnings.sensorOutOfBounds[0] = 0; 180 pDiveState->warnings.sensorOutOfBounds[0] = 0;
181 pDiveState->warnings.sensorOutOfBounds[1] = 0; 181 pDiveState->warnings.sensorOutOfBounds[1] = 0;
182 pDiveState->warnings.sensorOutOfBounds[2] = 0; 182 pDiveState->warnings.sensorOutOfBounds[2] = 0;
183 183
184 if((pDiveState->diveSettings.diveMode == DIVEMODE_CCR) && (pDiveState->diveSettings.CCR_Mode == CCRMODE_Sensors)) 184 if(isLoopMode(pDiveState->diveSettings.diveMode) && (pDiveState->diveSettings.CCR_Mode == CCRMODE_Sensors))
185 185
186 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) 186 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
187 { 187 {
188 { 188 {
189 if(!get_HUD_battery_voltage_V()) 189 if(!get_HUD_battery_voltage_V())
216 pDiveState->warnings.betterGas = 0; 216 pDiveState->warnings.betterGas = 0;
217 betterGasId = 0; 217 betterGasId = 0;
218 betterGasIdLocal = pLifeData->actualGas.GasIdInSettings; 218 betterGasIdLocal = pLifeData->actualGas.GasIdInSettings;
219 bestGasDepth = 255; 219 bestGasDepth = 255;
220 220
221 if(pDiveSettings->diveMode == DIVEMODE_CCR) 221 if(isLoopMode(pDiveSettings->diveMode))
222 gasIdOffset = NUM_OFFSET_DILUENT; 222 gasIdOffset = NUM_OFFSET_DILUENT;
223 else 223 else
224 gasIdOffset = 0; 224 gasIdOffset = 0;
225 225
226 /* life data is float, gas data is uint8 */ 226 /* life data is float, gas data is uint8 */
283 */ 283 */
284 static int8_t check_BetterSetpoint(SDiveState * pDiveState) 284 static int8_t check_BetterSetpoint(SDiveState * pDiveState)
285 { 285 {
286 pDiveState->warnings.betterSetpoint = 0; 286 pDiveState->warnings.betterSetpoint = 0;
287 betterSetpointId = 0; 287 betterSetpointId = 0;
288
289 if((stateUsed->mode != MODE_DIVE) || (pDiveState->diveSettings.diveMode != DIVEMODE_CCR) || (pDiveState->diveSettings.CCR_Mode != CCRMODE_FixedSetpoint))
290 {
291 return 0;
292 }
293
294 uint8_t bestSetpointDepth = 0; // travel the deeper, the better 288 uint8_t bestSetpointDepth = 0; // travel the deeper, the better
295 uint8_t betterSetpointIdLocal = 0; // nothing better 289 uint8_t betterSetpointIdLocal = 0; // nothing better
296 290
297 if(!actualLeftMaxDepth(pDiveState)) /* travel gases */ 291
298 { 292 if((stateUsed->mode == MODE_DIVE) && (pDiveState->diveSettings.diveMode == DIVEMODE_CCR))
299 for(int i=1; i<=NUM_GASES; i++) 293 {
294 if(!actualLeftMaxDepth(pDiveState)) /* travel gases */
300 { 295 {
301 if( (pDiveState->diveSettings.setpoint[i].note.ub.active) 296 for(int i=1; i<=NUM_GASES; i++)
302 && (pDiveState->diveSettings.setpoint[i].depth_meter) 297 {
303 && (pDiveState->diveSettings.setpoint[i].depth_meter <= ( pDiveState->lifeData.depth_meter + 0.01f )) 298 if( (pDiveState->diveSettings.setpoint[i].note.ub.active)
304 && (pDiveState->diveSettings.setpoint[i].depth_meter >= bestSetpointDepth) 299 && (pDiveState->diveSettings.setpoint[i].depth_meter)
305 ) 300 && (pDiveState->diveSettings.setpoint[i].depth_meter <= ( pDiveState->lifeData.depth_meter + 0.01f ))
306 { 301 && (pDiveState->diveSettings.setpoint[i].depth_meter >= bestSetpointDepth)
307 betterSetpointIdLocal = i; 302 )
308 bestSetpointDepth = pDiveState->diveSettings.setpoint[i].depth_meter; 303 {
309 } 304 betterSetpointIdLocal = i;
310 } 305 bestSetpointDepth = pDiveState->diveSettings.setpoint[i].depth_meter;
311 if((betterSetpointIdLocal) && (pDiveState->diveSettings.setpoint[betterSetpointIdLocal].setpoint_cbar != pDiveState->lifeData.actualGas.setPoint_cbar)) 306 }
312 { 307 }
313 betterSetpointId = betterSetpointIdLocal; 308 if((betterSetpointIdLocal) && (pDiveState->diveSettings.setpoint[betterSetpointIdLocal].setpoint_cbar != pDiveState->lifeData.actualGas.setPoint_cbar))
314 pDiveState->warnings.betterSetpoint = 1; 309 {
310 betterSetpointId = betterSetpointIdLocal;
311 pDiveState->warnings.betterSetpoint = 1;
312 }
315 } 313 }
316 } 314 }
317 return pDiveState->warnings.betterSetpoint; 315 return pDiveState->warnings.betterSetpoint;
318 } 316 }
319 317