Mercurial > public > ostc4
annotate Discovery/Src/check_warning.c @ 758:b6d8a6fbf4fd
- Colours for scrubber display when time remaining falls below a threshold value
- Display negative values when time is up and diving continues;
- count down remaining scrubber time only when the dive computer is not set to bailout - after all, there is not much point in counting down time if the diver is not breathing through the scrubber.
author | heinrichsweikamp |
---|---|
date | Wed, 15 Mar 2023 09:18:07 +0100 |
parents | 6de83d8205a0 |
children | 29d9b5bc7946 |
rev | line source |
---|---|
38 | 1 /** |
2 ****************************************************************************** | |
3 * @file check_warning.c | |
4 * @author heinrichs weikamp gmbh | |
5 * @date 17-Nov-2014 | |
6 * @version V0.0.1 | |
7 * @since 17-Nov-2014 | |
8 * @brief check and set warnings for warnings | |
9 * | |
10 @verbatim | |
11 ============================================================================== | |
12 ##### How to use ##### | |
13 ============================================================================== | |
14 OSTC3 Warnings: | |
15 niedriger Batteriezustand ( | |
16 zu hoher oder zu niedriger Sauerstoffpartialdruck (ppO2) 0.2 - 1.6 | |
17 zu hoher CNS (Gefahr der Sauerstoffvergiftung) 90% | |
18 zu hohe Gradientenfaktoren 90 - 90 | |
19 Missachtung der Dekostopps (der �berschrittene Dekostopp wird rot angezeigt) 0 m | |
20 zu hohe Aufstiegsgeschwindigkeit 30 m/min | |
21 aGF-Warnung: die Berechnung der Dekompression wird �ber alternative GF-Werte durchgef�hrt | |
22 Fallback-Warnung bei ausgefallenem Sensor | |
23 | |
24 @endverbatim | |
25 ****************************************************************************** | |
26 * @attention | |
27 * | |
28 * <h2><center>© COPYRIGHT(c) 2014 heinrichs weikamp</center></h2> | |
29 * | |
30 ****************************************************************************** | |
31 */ | |
32 | |
33 /* Includes ------------------------------------------------------------------*/ | |
34 | |
35 #include "data_exchange.h" | |
36 #include "check_warning.h" | |
37 #include "settings.h" | |
38 #include "decom.h" | |
39 #include "tCCR.h" | |
40 | |
636 | 41 |
42 #define DEBOUNCE_FALLBACK_TIME_MS (5000u) /* set warning after 5 seconds of pending error condition */ | |
43 | |
756 | 44 |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
45 /* Private variables with access ----------------------------------------------*/ |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
46 static uint8_t betterGasId = 0; |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
47 static uint8_t betterSetpointId = 0; |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
48 static int8_t fallback = 0; |
636 | 49 static uint16_t debounceFallbackTimeMS = 0; |
38 | 50 |
51 /* Private function prototypes -----------------------------------------------*/ | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
52 static int8_t check_fallback(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
53 static int8_t check_ppO2(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
54 static int8_t check_O2_sensors(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
55 static int8_t check_CNS(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
56 static int8_t check_Deco(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
57 static int8_t check_AscentRate(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
58 static int8_t check_aGF(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
59 static int8_t check_BetterGas(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
60 static int8_t check_BetterSetpoint(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
61 static int8_t check_Battery(SDiveState * pDiveState); |
478
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
62 #ifdef ENABLE_BOTTLE_SENSOR |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
63 static int8_t check_pressureSensor(SDiveState * pDiveState); |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
64 #endif |
756 | 65 #ifdef ENABLE_CO2_SUPPORT |
66 static int8_t check_co2(SDiveState * pDiveState); | |
67 #endif | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
68 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2); |
38 | 69 |
70 /* Exported functions --------------------------------------------------------*/ | |
71 | |
72 void check_warning(void) | |
73 { | |
272
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
268
diff
changeset
|
74 check_warning2(stateUsedWrite); |
38 | 75 } |
76 | |
77 | |
78 void check_warning2(SDiveState * pDiveState) | |
79 { | |
80 pDiveState->warnings.numWarnings = 0; | |
81 | |
82 pDiveState->warnings.numWarnings += check_aGF(pDiveState); | |
83 pDiveState->warnings.numWarnings += check_AscentRate(pDiveState); | |
84 pDiveState->warnings.numWarnings += check_CNS(pDiveState); | |
85 pDiveState->warnings.numWarnings += check_Deco(pDiveState); | |
86 pDiveState->warnings.numWarnings += check_ppO2(pDiveState); | |
87 pDiveState->warnings.numWarnings += check_O2_sensors(pDiveState); | |
88 pDiveState->warnings.numWarnings += check_BetterGas(pDiveState); | |
89 pDiveState->warnings.numWarnings += check_BetterSetpoint(pDiveState); | |
90 pDiveState->warnings.numWarnings += check_Battery(pDiveState); | |
91 pDiveState->warnings.numWarnings += check_fallback(pDiveState); | |
478
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
92 #ifdef ENABLE_BOTTLE_SENSOR |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
93 pDiveState->warnings.numWarnings += check_pressureSensor(pDiveState); |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
94 #endif |
756 | 95 #ifdef ENABLE_CO2_SUPPORT |
96 pDiveState->warnings.numWarnings += check_co2(pDiveState); | |
97 #endif | |
38 | 98 } |
99 | |
100 | |
101 void set_warning_fallback(void) | |
102 { | |
103 fallback = 1; | |
104 } | |
105 | |
106 | |
107 void clear_warning_fallback(void) | |
108 { | |
109 fallback = 0; | |
636 | 110 debounceFallbackTimeMS = 0; |
38 | 111 } |
112 | |
113 | |
114 uint8_t actualBetterGasId(void) | |
115 { | |
116 return betterGasId; | |
117 } | |
118 | |
119 | |
120 uint8_t actualBetterSetpointId(void) | |
121 { | |
122 return betterSetpointId; | |
123 } | |
124 | |
125 | |
126 uint8_t actualLeftMaxDepth(const SDiveState * pDiveState) | |
127 { | |
128 if(pDiveState->lifeData.depth_meter > (pDiveState->lifeData.max_depth_meter - 3.0f)) | |
129 return 0; | |
130 else | |
131 return 1; | |
132 } | |
133 | |
134 | |
135 /* Private functions ---------------------------------------------------------*/ | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
136 static int8_t check_fallback(SDiveState * pDiveState) |
38 | 137 { |
662 | 138 if(fallback && ((pDiveState->mode != MODE_DIVE) || (!isLoopMode(pDiveState->diveSettings.diveMode)))) |
38 | 139 fallback = 0; |
140 | |
141 pDiveState->warnings.fallback = fallback; | |
142 return pDiveState->warnings.fallback; | |
143 } | |
144 | |
145 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
146 static int8_t check_ppO2(SDiveState * pDiveState) |
38 | 147 { |
582
64bf41faab83
Show Fallback if no valid sensor value is available:
Ideenmodellierer
parents:
563
diff
changeset
|
148 if((pDiveState->mode != MODE_DIVE) || (pDiveState->warnings.fallback)) |
38 | 149 { |
150 pDiveState->warnings.ppO2Low = 0; | |
151 pDiveState->warnings.ppO2High = 0; | |
152 return 0; | |
153 } | |
154 | |
155 uint8_t localPPO2, testPPO2high; | |
156 | |
157 if(pDiveState->lifeData.ppO2 < 0) | |
158 localPPO2 = 0; | |
159 else | |
160 if(pDiveState->lifeData.ppO2 >= 2.5f) | |
161 localPPO2 = 255; | |
162 else | |
163 localPPO2 = (uint8_t)(pDiveState->lifeData.ppO2 * 100); | |
164 | |
165 if((localPPO2 + 1) <= settingsGetPointer()->ppO2_min) | |
166 pDiveState->warnings.ppO2Low = 1; | |
167 else | |
168 pDiveState->warnings.ppO2Low = 0; | |
169 | |
170 if(actualLeftMaxDepth(pDiveState)) | |
171 testPPO2high = settingsGetPointer()->ppO2_max_deco; | |
172 else | |
173 testPPO2high = settingsGetPointer()->ppO2_max_std; | |
174 | |
175 if(localPPO2 >= (testPPO2high + 1)) | |
176 pDiveState->warnings.ppO2High = 1; | |
177 else | |
178 pDiveState->warnings.ppO2High = 0; | |
179 | |
180 return pDiveState->warnings.ppO2Low + pDiveState->warnings.ppO2High; | |
181 } | |
182 | |
183 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
184 static int8_t check_O2_sensors(SDiveState * pDiveState) |
38 | 185 { |
186 pDiveState->warnings.sensorLinkLost = 0; | |
187 pDiveState->warnings.sensorOutOfBounds[0] = 0; | |
188 pDiveState->warnings.sensorOutOfBounds[1] = 0; | |
189 pDiveState->warnings.sensorOutOfBounds[2] = 0; | |
190 | |
662 | 191 if(isLoopMode(pDiveState->diveSettings.diveMode) && (pDiveState->diveSettings.CCR_Mode == CCRMODE_Sensors)) |
563 | 192 |
193 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) | |
194 { | |
195 { | |
196 if(!get_HUD_battery_voltage_V()) | |
197 pDiveState->warnings.sensorLinkLost = 1; | |
198 } | |
199 } | |
634 | 200 test_O2_sensor_values_outOfBounds(&pDiveState->warnings.sensorOutOfBounds[0], &pDiveState->warnings.sensorOutOfBounds[1], &pDiveState->warnings.sensorOutOfBounds[2]); |
38 | 201 return pDiveState->warnings.sensorLinkLost |
202 + pDiveState->warnings.sensorOutOfBounds[0] | |
203 + pDiveState->warnings.sensorOutOfBounds[1] | |
204 + pDiveState->warnings.sensorOutOfBounds[2]; | |
205 } | |
206 | |
207 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
208 static int8_t check_BetterGas(SDiveState * pDiveState) |
38 | 209 { |
210 if(stateUsed->mode != MODE_DIVE) | |
211 { | |
212 pDiveState->warnings.betterGas = 0; | |
213 betterGasId = 0; | |
214 return 0; | |
215 } | |
216 | |
217 uint8_t gasIdOffset; | |
218 uint8_t bestGasDepth, betterGasIdLocal; | |
219 | |
220 SLifeData* pLifeData = &pDiveState->lifeData; | |
221 SDiveSettings* pDiveSettings = &pDiveState->diveSettings; | |
222 | |
223 pDiveState->warnings.betterGas = 0; | |
224 betterGasId = 0; | |
225 betterGasIdLocal = pLifeData->actualGas.GasIdInSettings; | |
226 bestGasDepth = 255; | |
227 | |
662 | 228 if(isLoopMode(pDiveSettings->diveMode)) |
38 | 229 gasIdOffset = NUM_OFFSET_DILUENT; |
230 else | |
231 gasIdOffset = 0; | |
232 | |
233 /* life data is float, gas data is uint8 */ | |
234 if(actualLeftMaxDepth(pDiveState)) /* deco gases */ | |
235 { | |
236 for(int i=1+gasIdOffset; i<= 5+gasIdOffset; i++) | |
237 { | |
238 if( (pDiveSettings->gas[i].note.ub.active) | |
239 && (pDiveSettings->gas[i].note.ub.deco) | |
240 && (pDiveSettings->gas[i].depth_meter) | |
241 && (pDiveSettings->gas[i].depth_meter >= (pLifeData->depth_meter - 0.01f )) | |
242 && (pDiveSettings->gas[i].depth_meter <= bestGasDepth) | |
243 ) | |
244 { | |
245 betterGasIdLocal = i; | |
246 bestGasDepth = pDiveSettings->gas[i].depth_meter; | |
247 } | |
248 } | |
249 | |
250 if(betterGasIdLocal != pLifeData->actualGas.GasIdInSettings) | |
251 { | |
252 if(!check_helper_same_oxygen_and_helium_content(&pDiveSettings->gas[betterGasIdLocal], &pDiveSettings->gas[pLifeData->actualGas.GasIdInSettings])) | |
253 { | |
254 betterGasId = betterGasIdLocal; | |
255 pDiveState->warnings.betterGas = 1; | |
256 } | |
257 } | |
258 } | |
259 else /* travel gases */ | |
260 { | |
261 bestGasDepth = 0; | |
262 //check for travalgas | |
263 for(int i=1+gasIdOffset; i<= 5+gasIdOffset; i++) | |
264 { | |
265 if( (pDiveSettings->gas[i].note.ub.active) | |
266 && (pDiveSettings->gas[i].note.ub.travel) | |
267 && (pDiveSettings->gas[i].depth_meter_travel) | |
268 && (pDiveSettings->gas[i].depth_meter_travel <= (pLifeData->depth_meter + 0.01f )) | |
269 && (pDiveSettings->gas[i].depth_meter_travel >= bestGasDepth) | |
270 ) | |
271 { | |
272 betterGasIdLocal = i; | |
273 bestGasDepth = pDiveSettings->gas[i].depth_meter; | |
274 } | |
275 } | |
276 | |
277 if(betterGasIdLocal != pLifeData->actualGas.GasIdInSettings) | |
278 { | |
279 if(!check_helper_same_oxygen_and_helium_content(&pDiveSettings->gas[betterGasIdLocal], &pDiveSettings->gas[pLifeData->actualGas.GasIdInSettings])) | |
280 { | |
281 betterGasId = betterGasIdLocal; | |
282 pDiveState->warnings.betterGas = 1; | |
283 } | |
284 } | |
285 } | |
286 return pDiveState->warnings.betterGas; | |
287 } | |
288 | |
289 /* check for better travel!!! setpoint hw 151210 | |
290 */ | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
291 static int8_t check_BetterSetpoint(SDiveState * pDiveState) |
38 | 292 { |
293 pDiveState->warnings.betterSetpoint = 0; | |
294 betterSetpointId = 0; | |
295 uint8_t bestSetpointDepth = 0; // travel the deeper, the better | |
296 uint8_t betterSetpointIdLocal = 0; // nothing better | |
297 | |
662 | 298 |
299 if((stateUsed->mode == MODE_DIVE) && (pDiveState->diveSettings.diveMode == DIVEMODE_CCR)) | |
38 | 300 { |
662 | 301 if(!actualLeftMaxDepth(pDiveState)) /* travel gases */ |
38 | 302 { |
662 | 303 for(int i=1; i<=NUM_GASES; i++) |
304 { | |
305 if( (pDiveState->diveSettings.setpoint[i].note.ub.active) | |
306 && (pDiveState->diveSettings.setpoint[i].depth_meter) | |
307 && (pDiveState->diveSettings.setpoint[i].depth_meter <= ( pDiveState->lifeData.depth_meter + 0.01f )) | |
308 && (pDiveState->diveSettings.setpoint[i].depth_meter >= bestSetpointDepth) | |
309 ) | |
310 { | |
311 betterSetpointIdLocal = i; | |
312 bestSetpointDepth = pDiveState->diveSettings.setpoint[i].depth_meter; | |
313 } | |
314 } | |
315 if((betterSetpointIdLocal) && (pDiveState->diveSettings.setpoint[betterSetpointIdLocal].setpoint_cbar != pDiveState->lifeData.actualGas.setPoint_cbar)) | |
316 { | |
317 betterSetpointId = betterSetpointIdLocal; | |
318 pDiveState->warnings.betterSetpoint = 1; | |
319 } | |
38 | 320 } |
321 } | |
322 return pDiveState->warnings.betterSetpoint; | |
323 } | |
324 | |
325 | |
326 /* hw 151030 | |
327 */ | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
328 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2) |
38 | 329 { |
330 if(gas1->helium_percentage != gas2->helium_percentage) | |
331 return 0; | |
332 else | |
333 if(gas1->oxygen_percentage != gas2->oxygen_percentage) | |
334 return 0; | |
335 else | |
336 return 1; | |
337 } | |
338 | |
339 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
340 static int8_t check_CNS(SDiveState * pDiveState) |
38 | 341 { |
342 if(stateUsed->mode != MODE_DIVE) | |
343 { | |
344 pDiveState->warnings.cnsHigh = 0; | |
345 return 0; | |
346 } | |
347 | |
348 if(pDiveState->lifeData.cns >= (float)(settingsGetPointer()->CNS_max)) | |
349 pDiveState->warnings.cnsHigh = 1; | |
350 else | |
351 pDiveState->warnings.cnsHigh = 0; | |
352 return pDiveState->warnings.cnsHigh; | |
353 } | |
354 | |
355 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
356 static int8_t check_Battery(SDiveState * pDiveState) |
38 | 357 { |
671
b456be1e152d
Support of unknown charging counter values:
Ideenmodellierer
parents:
662
diff
changeset
|
358 if((pDiveState->lifeData.battery_charge > 0) && (pDiveState->lifeData.battery_charge < 10)) |
38 | 359 pDiveState->warnings.lowBattery = 1; |
360 else | |
361 pDiveState->warnings.lowBattery = 0; | |
362 | |
363 return pDiveState->warnings.lowBattery; | |
364 } | |
365 | |
366 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
367 static int8_t check_Deco(SDiveState * pDiveState) |
38 | 368 { |
369 if(stateUsed->mode != MODE_DIVE) | |
370 { | |
371 pDiveState->warnings.decoMissed = 0; | |
372 return 0; | |
373 } | |
374 | |
375 uint8_t depthNext = decom_get_actual_deco_stop(pDiveState); | |
376 | |
377 if(!depthNext) | |
378 pDiveState->warnings.decoMissed = 0; | |
379 else | |
380 if(pDiveState->lifeData.depth_meter + 0.1f < (float)depthNext) | |
381 pDiveState->warnings.decoMissed = 1; | |
382 else | |
383 pDiveState->warnings.decoMissed = 0; | |
384 | |
385 return pDiveState->warnings.decoMissed; | |
386 } | |
387 | |
388 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
389 static int8_t check_AscentRate(SDiveState * pDiveState) |
38 | 390 { |
391 if(stateUsed->mode != MODE_DIVE) | |
392 { | |
393 pDiveState->warnings.ascentRateHigh = 0; | |
394 return 0; | |
395 } | |
396 | |
397 float warnAscentRateFloat; | |
398 | |
399 warnAscentRateFloat = (float)(settingsGetPointer()->ascent_MeterPerMinute_max); | |
400 | |
401 if(pDiveState->lifeData.ascent_rate_meter_per_min >= warnAscentRateFloat) | |
402 pDiveState->warnings.ascentRateHigh = 1; | |
403 else | |
404 pDiveState->warnings.ascentRateHigh = 0; | |
405 return pDiveState->warnings.ascentRateHigh; | |
406 } | |
407 | |
408 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
409 static int8_t check_aGF(SDiveState * pDiveState) |
38 | 410 { |
411 if(stateUsed->mode != MODE_DIVE) | |
412 { | |
413 pDiveState->warnings.aGf = 0; | |
414 return 0; | |
415 } | |
416 | |
417 pDiveState->warnings.aGf = 0; | |
418 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE) | |
419 { | |
420 if((pDiveState->diveSettings.gf_high != settingsGetPointer()->GF_high) || (pDiveState->diveSettings.gf_low != settingsGetPointer()->GF_low)) | |
421 pDiveState->warnings.aGf = 1; | |
422 } | |
423 return pDiveState->warnings.aGf; | |
424 } | |
425 | |
478
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
426 #ifdef ENABLE_BOTTLE_SENSOR |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
427 static int8_t check_pressureSensor(SDiveState * pDiveState) |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
428 { |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
429 int8_t ret = 0; |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
430 if(pDiveState->lifeData.bottle_bar_age_MilliSeconds[pDiveState->lifeData.actualGas.GasIdInSettings] < 50) /* we received a new value */ |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
431 { |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
432 pDiveState->warnings.newPressure = stateUsed->lifeData.bottle_bar[stateUsed->lifeData.actualGas.GasIdInSettings]; |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
433 ret = 1; |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
434 } |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
435 else |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
436 { |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
437 pDiveState->warnings.newPressure = 0; |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
438 } |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
439 return ret; |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
440 } |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
441 #endif |
636 | 442 |
756 | 443 #ifdef ENABLE_CO2_SUPPORT |
444 static int8_t check_co2(SDiveState * pDiveState) | |
445 { | |
446 if(pDiveState->mode != MODE_DIVE) | |
447 { | |
448 pDiveState->warnings.co2High = 0; | |
449 } | |
450 else | |
451 { | |
452 if(pDiveState->lifeData.CO2_data.CO2_ppm > CO2_ALARM_LEVEL_PPM) | |
453 { | |
454 pDiveState->warnings.co2High = 1; | |
455 } | |
456 else | |
457 { | |
458 pDiveState->warnings.co2High = 0; | |
459 } | |
460 } | |
461 return pDiveState->warnings.co2High; | |
462 } | |
463 #endif | |
464 | |
636 | 465 uint8_t debounce_warning_fallback(uint16_t debounceStepms) |
466 { | |
467 uint8_t retVal = 0; | |
468 | |
469 debounceFallbackTimeMS += debounceStepms; | |
470 if(debounceFallbackTimeMS > DEBOUNCE_FALLBACK_TIME_MS) | |
471 { | |
472 debounceFallbackTimeMS = DEBOUNCE_FALLBACK_TIME_MS; | |
473 retVal = 1; | |
474 } | |
475 return retVal; | |
476 } | |
477 void reset_debounce_warning_fallback() | |
478 { | |
479 debounceFallbackTimeMS = 0; | |
480 } | |
38 | 481 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |
482 |