Mercurial > public > ostc4
annotate Discovery/Src/check_warning.c @ 771:29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
author | heinrichsweikamp |
---|---|
date | Fri, 21 Apr 2023 09:48:23 +0200 |
parents | 6de83d8205a0 |
children | 2c243233c999 |
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 | |
771
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
35 #include <stdbool.h> |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
36 |
38 | 37 #include "data_exchange.h" |
38 #include "check_warning.h" | |
39 #include "settings.h" | |
40 #include "decom.h" | |
41 #include "tCCR.h" | |
42 | |
636 | 43 |
44 #define DEBOUNCE_FALLBACK_TIME_MS (5000u) /* set warning after 5 seconds of pending error condition */ | |
45 | |
756 | 46 |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
47 /* Private variables with access ----------------------------------------------*/ |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
48 static uint8_t betterGasId = 0; |
771
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
49 static uint8_t betterSetpointId = 1; |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
50 static int8_t fallback = 0; |
636 | 51 static uint16_t debounceFallbackTimeMS = 0; |
38 | 52 |
53 /* Private function prototypes -----------------------------------------------*/ | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
54 static int8_t check_fallback(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
55 static int8_t check_ppO2(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
56 static int8_t check_O2_sensors(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
57 static int8_t check_CNS(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
58 static int8_t check_Deco(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
59 static int8_t check_AscentRate(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
60 static int8_t check_aGF(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
61 static int8_t check_BetterGas(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
62 static int8_t check_BetterSetpoint(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
63 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
|
64 #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
|
65 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
|
66 #endif |
756 | 67 #ifdef ENABLE_CO2_SUPPORT |
68 static int8_t check_co2(SDiveState * pDiveState); | |
69 #endif | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
70 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2); |
38 | 71 |
72 /* Exported functions --------------------------------------------------------*/ | |
73 | |
74 void check_warning(void) | |
75 { | |
272
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
268
diff
changeset
|
76 check_warning2(stateUsedWrite); |
38 | 77 } |
78 | |
79 | |
80 void check_warning2(SDiveState * pDiveState) | |
81 { | |
82 pDiveState->warnings.numWarnings = 0; | |
83 | |
84 pDiveState->warnings.numWarnings += check_aGF(pDiveState); | |
85 pDiveState->warnings.numWarnings += check_AscentRate(pDiveState); | |
86 pDiveState->warnings.numWarnings += check_CNS(pDiveState); | |
87 pDiveState->warnings.numWarnings += check_Deco(pDiveState); | |
88 pDiveState->warnings.numWarnings += check_ppO2(pDiveState); | |
89 pDiveState->warnings.numWarnings += check_O2_sensors(pDiveState); | |
90 pDiveState->warnings.numWarnings += check_BetterGas(pDiveState); | |
91 pDiveState->warnings.numWarnings += check_BetterSetpoint(pDiveState); | |
92 pDiveState->warnings.numWarnings += check_Battery(pDiveState); | |
93 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
|
94 #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
|
95 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
|
96 #endif |
756 | 97 #ifdef ENABLE_CO2_SUPPORT |
98 pDiveState->warnings.numWarnings += check_co2(pDiveState); | |
99 #endif | |
38 | 100 } |
101 | |
102 | |
103 void set_warning_fallback(void) | |
104 { | |
105 fallback = 1; | |
106 } | |
107 | |
108 | |
109 void clear_warning_fallback(void) | |
110 { | |
111 fallback = 0; | |
636 | 112 debounceFallbackTimeMS = 0; |
38 | 113 } |
114 | |
115 | |
116 uint8_t actualBetterGasId(void) | |
117 { | |
118 return betterGasId; | |
119 } | |
120 | |
121 | |
122 uint8_t actualBetterSetpointId(void) | |
123 { | |
124 return betterSetpointId; | |
125 } | |
126 | |
127 | |
128 uint8_t actualLeftMaxDepth(const SDiveState * pDiveState) | |
129 { | |
130 if(pDiveState->lifeData.depth_meter > (pDiveState->lifeData.max_depth_meter - 3.0f)) | |
131 return 0; | |
132 else | |
133 return 1; | |
134 } | |
135 | |
136 | |
137 /* Private functions ---------------------------------------------------------*/ | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
138 static int8_t check_fallback(SDiveState * pDiveState) |
38 | 139 { |
662 | 140 if(fallback && ((pDiveState->mode != MODE_DIVE) || (!isLoopMode(pDiveState->diveSettings.diveMode)))) |
38 | 141 fallback = 0; |
142 | |
143 pDiveState->warnings.fallback = fallback; | |
144 return pDiveState->warnings.fallback; | |
145 } | |
146 | |
147 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
148 static int8_t check_ppO2(SDiveState * pDiveState) |
38 | 149 { |
582
64bf41faab83
Show Fallback if no valid sensor value is available:
Ideenmodellierer
parents:
563
diff
changeset
|
150 if((pDiveState->mode != MODE_DIVE) || (pDiveState->warnings.fallback)) |
38 | 151 { |
152 pDiveState->warnings.ppO2Low = 0; | |
153 pDiveState->warnings.ppO2High = 0; | |
154 return 0; | |
155 } | |
156 | |
157 uint8_t localPPO2, testPPO2high; | |
158 | |
159 if(pDiveState->lifeData.ppO2 < 0) | |
160 localPPO2 = 0; | |
161 else | |
162 if(pDiveState->lifeData.ppO2 >= 2.5f) | |
163 localPPO2 = 255; | |
164 else | |
165 localPPO2 = (uint8_t)(pDiveState->lifeData.ppO2 * 100); | |
166 | |
167 if((localPPO2 + 1) <= settingsGetPointer()->ppO2_min) | |
168 pDiveState->warnings.ppO2Low = 1; | |
169 else | |
170 pDiveState->warnings.ppO2Low = 0; | |
171 | |
172 if(actualLeftMaxDepth(pDiveState)) | |
173 testPPO2high = settingsGetPointer()->ppO2_max_deco; | |
174 else | |
175 testPPO2high = settingsGetPointer()->ppO2_max_std; | |
176 | |
177 if(localPPO2 >= (testPPO2high + 1)) | |
178 pDiveState->warnings.ppO2High = 1; | |
179 else | |
180 pDiveState->warnings.ppO2High = 0; | |
181 | |
182 return pDiveState->warnings.ppO2Low + pDiveState->warnings.ppO2High; | |
183 } | |
184 | |
185 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
186 static int8_t check_O2_sensors(SDiveState * pDiveState) |
38 | 187 { |
188 pDiveState->warnings.sensorLinkLost = 0; | |
189 pDiveState->warnings.sensorOutOfBounds[0] = 0; | |
190 pDiveState->warnings.sensorOutOfBounds[1] = 0; | |
191 pDiveState->warnings.sensorOutOfBounds[2] = 0; | |
192 | |
662 | 193 if(isLoopMode(pDiveState->diveSettings.diveMode) && (pDiveState->diveSettings.CCR_Mode == CCRMODE_Sensors)) |
563 | 194 |
195 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) | |
196 { | |
197 { | |
198 if(!get_HUD_battery_voltage_V()) | |
199 pDiveState->warnings.sensorLinkLost = 1; | |
200 } | |
201 } | |
634 | 202 test_O2_sensor_values_outOfBounds(&pDiveState->warnings.sensorOutOfBounds[0], &pDiveState->warnings.sensorOutOfBounds[1], &pDiveState->warnings.sensorOutOfBounds[2]); |
38 | 203 return pDiveState->warnings.sensorLinkLost |
204 + pDiveState->warnings.sensorOutOfBounds[0] | |
205 + pDiveState->warnings.sensorOutOfBounds[1] | |
206 + pDiveState->warnings.sensorOutOfBounds[2]; | |
207 } | |
208 | |
209 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
210 static int8_t check_BetterGas(SDiveState * pDiveState) |
38 | 211 { |
212 if(stateUsed->mode != MODE_DIVE) | |
213 { | |
214 pDiveState->warnings.betterGas = 0; | |
215 betterGasId = 0; | |
216 return 0; | |
217 } | |
218 | |
219 uint8_t gasIdOffset; | |
220 uint8_t bestGasDepth, betterGasIdLocal; | |
221 | |
222 SLifeData* pLifeData = &pDiveState->lifeData; | |
223 SDiveSettings* pDiveSettings = &pDiveState->diveSettings; | |
224 | |
225 pDiveState->warnings.betterGas = 0; | |
226 betterGasId = 0; | |
227 betterGasIdLocal = pLifeData->actualGas.GasIdInSettings; | |
228 bestGasDepth = 255; | |
229 | |
662 | 230 if(isLoopMode(pDiveSettings->diveMode)) |
38 | 231 gasIdOffset = NUM_OFFSET_DILUENT; |
232 else | |
233 gasIdOffset = 0; | |
234 | |
235 /* life data is float, gas data is uint8 */ | |
236 if(actualLeftMaxDepth(pDiveState)) /* deco gases */ | |
237 { | |
238 for(int i=1+gasIdOffset; i<= 5+gasIdOffset; i++) | |
239 { | |
240 if( (pDiveSettings->gas[i].note.ub.active) | |
241 && (pDiveSettings->gas[i].note.ub.deco) | |
242 && (pDiveSettings->gas[i].depth_meter) | |
243 && (pDiveSettings->gas[i].depth_meter >= (pLifeData->depth_meter - 0.01f )) | |
244 && (pDiveSettings->gas[i].depth_meter <= bestGasDepth) | |
245 ) | |
246 { | |
247 betterGasIdLocal = i; | |
248 bestGasDepth = pDiveSettings->gas[i].depth_meter; | |
249 } | |
250 } | |
251 | |
252 if(betterGasIdLocal != pLifeData->actualGas.GasIdInSettings) | |
253 { | |
254 if(!check_helper_same_oxygen_and_helium_content(&pDiveSettings->gas[betterGasIdLocal], &pDiveSettings->gas[pLifeData->actualGas.GasIdInSettings])) | |
255 { | |
256 betterGasId = betterGasIdLocal; | |
257 pDiveState->warnings.betterGas = 1; | |
258 } | |
259 } | |
260 } | |
261 else /* travel gases */ | |
262 { | |
263 bestGasDepth = 0; | |
264 //check for travalgas | |
265 for(int i=1+gasIdOffset; i<= 5+gasIdOffset; i++) | |
266 { | |
267 if( (pDiveSettings->gas[i].note.ub.active) | |
268 && (pDiveSettings->gas[i].note.ub.travel) | |
269 && (pDiveSettings->gas[i].depth_meter_travel) | |
270 && (pDiveSettings->gas[i].depth_meter_travel <= (pLifeData->depth_meter + 0.01f )) | |
271 && (pDiveSettings->gas[i].depth_meter_travel >= bestGasDepth) | |
272 ) | |
273 { | |
274 betterGasIdLocal = i; | |
275 bestGasDepth = pDiveSettings->gas[i].depth_meter; | |
276 } | |
277 } | |
278 | |
279 if(betterGasIdLocal != pLifeData->actualGas.GasIdInSettings) | |
280 { | |
281 if(!check_helper_same_oxygen_and_helium_content(&pDiveSettings->gas[betterGasIdLocal], &pDiveSettings->gas[pLifeData->actualGas.GasIdInSettings])) | |
282 { | |
283 betterGasId = betterGasIdLocal; | |
284 pDiveState->warnings.betterGas = 1; | |
285 } | |
286 } | |
287 } | |
288 return pDiveState->warnings.betterGas; | |
289 } | |
290 | |
771
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
291 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
292 uint8_t getSetpointLowId(void) |
38 | 293 { |
771
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
294 uint8_t setpointLowId = 0; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
295 uint8_t setpointLowDepthM = UINT8_MAX; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
296 for (unsigned i = 1; i <= NUM_GASES; i++) { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
297 if (stateUsed->diveSettings.setpoint[i].depth_meter && stateUsed->diveSettings.setpoint[i].depth_meter < setpointLowDepthM) { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
298 setpointLowId = i; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
299 setpointLowDepthM = stateUsed->diveSettings.setpoint[i].depth_meter; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
300 } |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
301 } |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
302 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
303 return setpointLowId; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
304 } |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
305 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
306 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
307 uint8_t getSetpointHighId(void) |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
308 { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
309 uint8_t setpointHighId = 0; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
310 uint8_t setpointHighDepthM = 0; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
311 for (unsigned i = 1; i <= NUM_GASES; i++) { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
312 if (stateUsed->diveSettings.setpoint[i].depth_meter && stateUsed->diveSettings.setpoint[i].depth_meter >= setpointHighDepthM) { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
313 setpointHighId = i; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
314 setpointHighDepthM = stateUsed->diveSettings.setpoint[i].depth_meter; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
315 } |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
316 } |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
317 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
318 return setpointHighId; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
319 } |
38 | 320 |
662 | 321 |
771
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
322 /* check for better travel!!! setpoint hw 151210 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
323 */ |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
324 static int8_t check_BetterSetpoint(SDiveState *diveState) |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
325 { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
326 diveState->warnings.betterSetpoint = 0; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
327 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
328 if (stateUsed->mode != MODE_DIVE) { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
329 betterSetpointId = 1; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
330 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
331 return 0; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
332 } |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
333 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
334 SSettings *settings = settingsGetPointer(); |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
335 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
336 float currentDepthM = diveState->lifeData.depth_meter; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
337 if (settings->dive_mode == DIVEMODE_CCR && diveState->lifeData.lastSetpointChangeDepthM != currentDepthM) { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
338 float lastChangeDepthM = diveState->lifeData.lastSetpointChangeDepthM; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
339 bool descending = currentDepthM > lastChangeDepthM; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
340 uint8_t setpointLowId = getSetpointLowId(); |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
341 uint8_t setpointHighId = getSetpointHighId(); |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
342 uint8_t betterSetpointIdLocal = 0; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
343 uint8_t betterSetpointSwitchDepthM = descending ? 0 : UINT8_MAX; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
344 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
345 for (unsigned i = 1; i <= NUM_GASES; i++) { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
346 uint8_t switchDepthM = diveState->diveSettings.setpoint[i].depth_meter; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
347 if (!switchDepthM || (descending && i == setpointLowId) || (!descending && i == setpointHighId)) { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
348 continue; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
349 } |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
350 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
351 if ((descending && lastChangeDepthM < switchDepthM && switchDepthM < currentDepthM && switchDepthM > betterSetpointSwitchDepthM) |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
352 || (!descending && lastChangeDepthM > switchDepthM && switchDepthM > currentDepthM && switchDepthM <= betterSetpointSwitchDepthM)) { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
353 betterSetpointIdLocal = i; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
354 betterSetpointSwitchDepthM = switchDepthM; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
355 } |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
356 } |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
357 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
358 if (betterSetpointIdLocal) { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
359 betterSetpointId = betterSetpointIdLocal; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
360 if (diveState->diveSettings.diveMode == DIVEMODE_CCR && diveState->diveSettings.setpoint[betterSetpointIdLocal].setpoint_cbar != diveState->lifeData.actualGas.setPoint_cbar) { |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
361 diveState->warnings.betterSetpoint = 1; |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
362 } |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
363 } |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
364 } |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
365 |
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
756
diff
changeset
|
366 return diveState->warnings.betterSetpoint; |
38 | 367 } |
368 | |
369 | |
370 /* hw 151030 | |
371 */ | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
372 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2) |
38 | 373 { |
374 if(gas1->helium_percentage != gas2->helium_percentage) | |
375 return 0; | |
376 else | |
377 if(gas1->oxygen_percentage != gas2->oxygen_percentage) | |
378 return 0; | |
379 else | |
380 return 1; | |
381 } | |
382 | |
383 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
384 static int8_t check_CNS(SDiveState * pDiveState) |
38 | 385 { |
386 if(stateUsed->mode != MODE_DIVE) | |
387 { | |
388 pDiveState->warnings.cnsHigh = 0; | |
389 return 0; | |
390 } | |
391 | |
392 if(pDiveState->lifeData.cns >= (float)(settingsGetPointer()->CNS_max)) | |
393 pDiveState->warnings.cnsHigh = 1; | |
394 else | |
395 pDiveState->warnings.cnsHigh = 0; | |
396 return pDiveState->warnings.cnsHigh; | |
397 } | |
398 | |
399 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
400 static int8_t check_Battery(SDiveState * pDiveState) |
38 | 401 { |
671
b456be1e152d
Support of unknown charging counter values:
Ideenmodellierer
parents:
662
diff
changeset
|
402 if((pDiveState->lifeData.battery_charge > 0) && (pDiveState->lifeData.battery_charge < 10)) |
38 | 403 pDiveState->warnings.lowBattery = 1; |
404 else | |
405 pDiveState->warnings.lowBattery = 0; | |
406 | |
407 return pDiveState->warnings.lowBattery; | |
408 } | |
409 | |
410 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
411 static int8_t check_Deco(SDiveState * pDiveState) |
38 | 412 { |
413 if(stateUsed->mode != MODE_DIVE) | |
414 { | |
415 pDiveState->warnings.decoMissed = 0; | |
416 return 0; | |
417 } | |
418 | |
419 uint8_t depthNext = decom_get_actual_deco_stop(pDiveState); | |
420 | |
421 if(!depthNext) | |
422 pDiveState->warnings.decoMissed = 0; | |
423 else | |
424 if(pDiveState->lifeData.depth_meter + 0.1f < (float)depthNext) | |
425 pDiveState->warnings.decoMissed = 1; | |
426 else | |
427 pDiveState->warnings.decoMissed = 0; | |
428 | |
429 return pDiveState->warnings.decoMissed; | |
430 } | |
431 | |
432 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
433 static int8_t check_AscentRate(SDiveState * pDiveState) |
38 | 434 { |
435 if(stateUsed->mode != MODE_DIVE) | |
436 { | |
437 pDiveState->warnings.ascentRateHigh = 0; | |
438 return 0; | |
439 } | |
440 | |
441 float warnAscentRateFloat; | |
442 | |
443 warnAscentRateFloat = (float)(settingsGetPointer()->ascent_MeterPerMinute_max); | |
444 | |
445 if(pDiveState->lifeData.ascent_rate_meter_per_min >= warnAscentRateFloat) | |
446 pDiveState->warnings.ascentRateHigh = 1; | |
447 else | |
448 pDiveState->warnings.ascentRateHigh = 0; | |
449 return pDiveState->warnings.ascentRateHigh; | |
450 } | |
451 | |
452 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
453 static int8_t check_aGF(SDiveState * pDiveState) |
38 | 454 { |
455 if(stateUsed->mode != MODE_DIVE) | |
456 { | |
457 pDiveState->warnings.aGf = 0; | |
458 return 0; | |
459 } | |
460 | |
461 pDiveState->warnings.aGf = 0; | |
462 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE) | |
463 { | |
464 if((pDiveState->diveSettings.gf_high != settingsGetPointer()->GF_high) || (pDiveState->diveSettings.gf_low != settingsGetPointer()->GF_low)) | |
465 pDiveState->warnings.aGf = 1; | |
466 } | |
467 return pDiveState->warnings.aGf; | |
468 } | |
469 | |
478
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
470 #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
|
471 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
|
472 { |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
473 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
|
474 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
|
475 { |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
476 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
|
477 ret = 1; |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
478 } |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
479 else |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
480 { |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
481 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
|
482 } |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
483 return ret; |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
484 } |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
485 #endif |
636 | 486 |
756 | 487 #ifdef ENABLE_CO2_SUPPORT |
488 static int8_t check_co2(SDiveState * pDiveState) | |
489 { | |
490 if(pDiveState->mode != MODE_DIVE) | |
491 { | |
492 pDiveState->warnings.co2High = 0; | |
493 } | |
494 else | |
495 { | |
496 if(pDiveState->lifeData.CO2_data.CO2_ppm > CO2_ALARM_LEVEL_PPM) | |
497 { | |
498 pDiveState->warnings.co2High = 1; | |
499 } | |
500 else | |
501 { | |
502 pDiveState->warnings.co2High = 0; | |
503 } | |
504 } | |
505 return pDiveState->warnings.co2High; | |
506 } | |
507 #endif | |
508 | |
636 | 509 uint8_t debounce_warning_fallback(uint16_t debounceStepms) |
510 { | |
511 uint8_t retVal = 0; | |
512 | |
513 debounceFallbackTimeMS += debounceStepms; | |
514 if(debounceFallbackTimeMS > DEBOUNCE_FALLBACK_TIME_MS) | |
515 { | |
516 debounceFallbackTimeMS = DEBOUNCE_FALLBACK_TIME_MS; | |
517 retVal = 1; | |
518 } | |
519 return retVal; | |
520 } | |
521 void reset_debounce_warning_fallback() | |
522 { | |
523 debounceFallbackTimeMS = 0; | |
524 } | |
38 | 525 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |
526 |