Mercurial > public > ostc4
annotate Discovery/Src/check_warning.c @ 862:974648b5ccfe Evo_2_23
Only use deco gas for calculation if option is enabled:
The gas menu meanwhile provides the possibility to select a gas for deco (having the gas switching reminder visible) without the need to visualize the reduced deco time. If the visualization of the deco considering all gas changes is wanted then this may be enabled by selecting the gas additionaly for deco calculation.
author | Ideenmodellierer |
---|---|
date | Tue, 02 Jul 2024 19:24:03 +0200 |
parents | ba1aebc6d5af |
children | e373e90a48db |
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" | |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
42 #include "tHome.h" |
38 | 43 |
636 | 44 |
45 #define DEBOUNCE_FALLBACK_TIME_MS (5000u) /* set warning after 5 seconds of pending error condition */ | |
46 | |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
47 #define SETPOINT_DECO_START_RANGE_M 3.0 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
48 #define SWITCH_DEPTH_LOW_MINIMUM_M 1.0 |
756 | 49 |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
50 /* Private variables with access ----------------------------------------------*/ |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
51 static uint8_t betterGasId = 0; |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
52 static uint8_t betterBailoutGasId = 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
|
53 static uint8_t betterSetpointId = 1; |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
54 static int8_t fallback = 0; |
636 | 55 static uint16_t debounceFallbackTimeMS = 0; |
38 | 56 |
57 /* Private function prototypes -----------------------------------------------*/ | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
58 static int8_t check_fallback(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
59 static int8_t check_ppO2(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
60 static int8_t check_O2_sensors(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
61 static int8_t check_CNS(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
62 static int8_t check_Deco(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
63 static int8_t check_AscentRate(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
64 static int8_t check_aGF(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
65 static int8_t check_BetterGas(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
66 static int8_t check_BetterSetpoint(SDiveState * pDiveState); |
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
67 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
|
68 #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
|
69 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
|
70 #endif |
756 | 71 #ifdef ENABLE_CO2_SUPPORT |
72 static int8_t check_co2(SDiveState * pDiveState); | |
73 #endif | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
74 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2); |
857 | 75 #ifdef HAVE_DEBUG_WARNINGS |
76 static int8_t check_debug(SDiveState * pDiveState); | |
77 #endif | |
78 | |
38 | 79 |
80 /* Exported functions --------------------------------------------------------*/ | |
81 | |
82 void check_warning(void) | |
83 { | |
272
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
268
diff
changeset
|
84 check_warning2(stateUsedWrite); |
38 | 85 } |
86 | |
87 | |
88 void check_warning2(SDiveState * pDiveState) | |
89 { | |
90 pDiveState->warnings.numWarnings = 0; | |
91 | |
92 pDiveState->warnings.numWarnings += check_aGF(pDiveState); | |
93 pDiveState->warnings.numWarnings += check_AscentRate(pDiveState); | |
94 pDiveState->warnings.numWarnings += check_CNS(pDiveState); | |
95 pDiveState->warnings.numWarnings += check_Deco(pDiveState); | |
96 pDiveState->warnings.numWarnings += check_ppO2(pDiveState); | |
97 pDiveState->warnings.numWarnings += check_O2_sensors(pDiveState); | |
98 pDiveState->warnings.numWarnings += check_BetterGas(pDiveState); | |
99 pDiveState->warnings.numWarnings += check_BetterSetpoint(pDiveState); | |
100 pDiveState->warnings.numWarnings += check_Battery(pDiveState); | |
101 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
|
102 #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
|
103 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
|
104 #endif |
756 | 105 #ifdef ENABLE_CO2_SUPPORT |
106 pDiveState->warnings.numWarnings += check_co2(pDiveState); | |
107 #endif | |
857 | 108 #ifdef HAVE_DEBUG_WARNINGS |
109 pDiveState->warnings.numWarnings += check_debug(pDiveState); | |
110 #endif | |
38 | 111 } |
112 | |
113 | |
114 void set_warning_fallback(void) | |
115 { | |
116 fallback = 1; | |
117 } | |
118 | |
119 | |
120 void clear_warning_fallback(void) | |
121 { | |
122 fallback = 0; | |
636 | 123 debounceFallbackTimeMS = 0; |
38 | 124 } |
125 | |
126 | |
127 uint8_t actualBetterGasId(void) | |
128 { | |
129 return betterGasId; | |
130 } | |
131 | |
132 | |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
133 uint8_t actualBetterBailoutGasId(void) |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
134 { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
135 return betterBailoutGasId; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
136 } |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
137 |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
138 |
38 | 139 uint8_t actualBetterSetpointId(void) |
140 { | |
141 return betterSetpointId; | |
142 } | |
143 | |
144 | |
145 uint8_t actualLeftMaxDepth(const SDiveState * pDiveState) | |
146 { | |
147 if(pDiveState->lifeData.depth_meter > (pDiveState->lifeData.max_depth_meter - 3.0f)) | |
148 return 0; | |
149 else | |
150 return 1; | |
151 } | |
152 | |
153 | |
154 /* Private functions ---------------------------------------------------------*/ | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
155 static int8_t check_fallback(SDiveState * pDiveState) |
38 | 156 { |
662 | 157 if(fallback && ((pDiveState->mode != MODE_DIVE) || (!isLoopMode(pDiveState->diveSettings.diveMode)))) |
38 | 158 fallback = 0; |
159 | |
160 pDiveState->warnings.fallback = fallback; | |
161 return pDiveState->warnings.fallback; | |
162 } | |
163 | |
164 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
165 static int8_t check_ppO2(SDiveState * pDiveState) |
38 | 166 { |
582
64bf41faab83
Show Fallback if no valid sensor value is available:
Ideenmodellierer
parents:
563
diff
changeset
|
167 if((pDiveState->mode != MODE_DIVE) || (pDiveState->warnings.fallback)) |
38 | 168 { |
169 pDiveState->warnings.ppO2Low = 0; | |
170 pDiveState->warnings.ppO2High = 0; | |
171 return 0; | |
172 } | |
173 | |
174 uint8_t localPPO2, testPPO2high; | |
175 | |
176 if(pDiveState->lifeData.ppO2 < 0) | |
177 localPPO2 = 0; | |
178 else | |
179 if(pDiveState->lifeData.ppO2 >= 2.5f) | |
180 localPPO2 = 255; | |
181 else | |
182 localPPO2 = (uint8_t)(pDiveState->lifeData.ppO2 * 100); | |
183 | |
184 if((localPPO2 + 1) <= settingsGetPointer()->ppO2_min) | |
185 pDiveState->warnings.ppO2Low = 1; | |
186 else | |
187 pDiveState->warnings.ppO2Low = 0; | |
188 | |
189 if(actualLeftMaxDepth(pDiveState)) | |
190 testPPO2high = settingsGetPointer()->ppO2_max_deco; | |
191 else | |
192 testPPO2high = settingsGetPointer()->ppO2_max_std; | |
193 | |
194 if(localPPO2 >= (testPPO2high + 1)) | |
195 pDiveState->warnings.ppO2High = 1; | |
196 else | |
197 pDiveState->warnings.ppO2High = 0; | |
198 | |
199 return pDiveState->warnings.ppO2Low + pDiveState->warnings.ppO2High; | |
200 } | |
201 | |
202 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
203 static int8_t check_O2_sensors(SDiveState * pDiveState) |
38 | 204 { |
205 pDiveState->warnings.sensorLinkLost = 0; | |
206 pDiveState->warnings.sensorOutOfBounds[0] = 0; | |
207 pDiveState->warnings.sensorOutOfBounds[1] = 0; | |
208 pDiveState->warnings.sensorOutOfBounds[2] = 0; | |
209 | |
662 | 210 if(isLoopMode(pDiveState->diveSettings.diveMode) && (pDiveState->diveSettings.CCR_Mode == CCRMODE_Sensors)) |
563 | 211 |
212 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) | |
213 { | |
214 { | |
215 if(!get_HUD_battery_voltage_V()) | |
216 pDiveState->warnings.sensorLinkLost = 1; | |
217 } | |
218 } | |
634 | 219 test_O2_sensor_values_outOfBounds(&pDiveState->warnings.sensorOutOfBounds[0], &pDiveState->warnings.sensorOutOfBounds[1], &pDiveState->warnings.sensorOutOfBounds[2]); |
38 | 220 return pDiveState->warnings.sensorLinkLost |
221 + pDiveState->warnings.sensorOutOfBounds[0] | |
222 + pDiveState->warnings.sensorOutOfBounds[1] | |
223 + pDiveState->warnings.sensorOutOfBounds[2]; | |
224 } | |
225 | |
226 | |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
227 static uint8_t getBetterGasId(bool getDiluent, uint8_t startingGasId, SDiveState *diveState) |
38 | 228 { |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
229 SDiveSettings diveSettings = diveState->diveSettings; |
831 | 230 SGasLine localGas; |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
231 uint8_t betterGasIdLocal = startingGasId; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
232 uint8_t bestGasDepth = 255; |
831 | 233 uint8_t i; |
38 | 234 |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
235 uint8_t gasIdOffset; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
236 if (getDiluent) { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
237 gasIdOffset = NUM_OFFSET_DILUENT; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
238 } else { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
239 gasIdOffset = 0; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
240 } |
38 | 241 |
242 /* life data is float, gas data is uint8 */ | |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
243 if (actualLeftMaxDepth(diveState)) { /* deco gases */ |
831 | 244 for (i=1+gasIdOffset; i<= 5+gasIdOffset; i++) { |
245 memcpy(&localGas,&diveSettings.gas[i],sizeof(SGasLine)); | |
246 if((localGas.note.ub.first) && (diveSettings.diveMode == DIVEMODE_PSCR)) /* handle first gas as if it would be a deco gas set to MOD */ | |
247 { | |
248 localGas.note.ub.active = 1; | |
249 localGas.note.ub.deco = 1; | |
250 localGas.depth_meter = calc_MOD(i); | |
251 } | |
252 if ((localGas.note.ub.active) | |
253 && (localGas.note.ub.deco) | |
254 && (localGas.depth_meter) | |
255 && (localGas.depth_meter >= (diveState->lifeData.depth_meter - 0.01f )) | |
256 && (localGas.depth_meter <= bestGasDepth)) { | |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
257 betterGasIdLocal = i; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
258 bestGasDepth = diveSettings.gas[i].depth_meter; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
259 } |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
260 } |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
261 } else { /* travel gases */ |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
262 bestGasDepth = 0; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
263 //check for travalgas |
831 | 264 for (i = 1 + gasIdOffset; i <= 5 + gasIdOffset; i++) { |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
265 if ((diveSettings.gas[i].note.ub.active) |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
266 && (diveSettings.gas[i].note.ub.travel) |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
267 && (diveSettings.gas[i].depth_meter_travel) |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
268 && (diveSettings.gas[i].depth_meter_travel <= (diveState->lifeData.depth_meter + 0.01f )) |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
269 && (diveSettings.gas[i].depth_meter_travel >= bestGasDepth)) { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
270 betterGasIdLocal = i; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
271 bestGasDepth = diveSettings.gas[i].depth_meter; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
272 } |
38 | 273 } |
274 } | |
831 | 275 if((!getDiluent) && (betterGasIdLocal > NUM_OFFSET_DILUENT)) /* an OC gas was requested but Id is pointing to a diluent => return first OC */ |
276 { | |
277 for (i = 1 ; i <= NUM_OFFSET_DILUENT; i++) | |
278 { | |
279 if(diveSettings.gas[i].note.ub.first) | |
280 { | |
281 betterGasIdLocal = i; | |
282 break; | |
283 } | |
284 } | |
285 } | |
286 | |
38 | 287 |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
288 return betterGasIdLocal; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
289 } |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
290 |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
291 |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
292 static int8_t check_BetterGas(SDiveState *diveState) |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
293 { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
294 diveState->warnings.betterGas = 0; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
295 |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
296 if (stateUsed->mode != MODE_DIVE) { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
297 betterGasId = 0; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
298 |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
299 return 0; |
38 | 300 } |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
301 |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
302 SDiveSettings diveSettings = diveState->diveSettings; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
303 SLifeData lifeData = diveState->lifeData; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
304 |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
305 if (isLoopMode(diveSettings.diveMode)) { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
306 betterGasId = getBetterGasId(true, lifeData.actualGas.GasIdInSettings, diveState); |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
307 betterBailoutGasId = getBetterGasId(false, lifeData.lastDiluent_GasIdInSettings, diveState); |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
308 } else { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
309 betterGasId = getBetterGasId(false, lifeData.actualGas.GasIdInSettings, diveState); |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
310 } |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
311 |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
312 if (betterGasId != lifeData.actualGas.GasIdInSettings && !check_helper_same_oxygen_and_helium_content(&diveSettings.gas[betterGasId], &diveSettings.gas[lifeData.actualGas.GasIdInSettings])) { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
313 diveState->warnings.betterGas = 1; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
314 } |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
315 |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
316 return diveState->warnings.betterGas; |
38 | 317 } |
318 | |
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
|
319 |
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
|
320 uint8_t getSetpointLowId(void) |
38 | 321 { |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
322 SSettings *settings = settingsGetPointer(); |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
323 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
324 if (settings->autoSetpoint) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
325 return SETPOINT_INDEX_AUTO_LOW; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
326 } |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
327 |
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
|
328 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
|
329 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
|
330 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
|
331 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
|
332 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
|
333 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
|
334 } |
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 |
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 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
|
338 } |
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 |
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 |
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 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
|
342 { |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
343 SSettings *settings = settingsGetPointer(); |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
344 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
345 if (settings->autoSetpoint) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
346 return SETPOINT_INDEX_AUTO_HIGH; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
347 } |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
348 |
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
|
349 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
|
350 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
|
351 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
|
352 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
|
353 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
|
354 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
|
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 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
|
359 } |
38 | 360 |
662 | 361 |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
362 uint8_t getSetpointDecoId(void) |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
363 { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
364 SSettings *settings = settingsGetPointer(); |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
365 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
366 if (settings->autoSetpoint && stateUsed->diveSettings.setpoint[SETPOINT_INDEX_AUTO_DECO].note.ub.active) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
367 return SETPOINT_INDEX_AUTO_DECO; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
368 } |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
369 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
370 return 0; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
371 } |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
372 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
373 |
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
|
374 /* 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
|
375 */ |
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
|
376 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
|
377 { |
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
|
378 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
|
379 |
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
|
380 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
|
381 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
|
382 |
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
|
383 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
|
384 } |
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
|
385 |
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
|
386 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
|
387 |
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
|
388 float currentDepthM = diveState->lifeData.depth_meter; |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
389 float lastChangeDepthM = diveState->lifeData.lastSetpointChangeDepthM; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
390 if (settings->dive_mode == DIVEMODE_CCR && lastChangeDepthM != currentDepthM) { |
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
|
391 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
|
392 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
|
393 |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
394 if (settings->autoSetpoint) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
395 bool decoSetpointEnabled = diveState->diveSettings.setpoint[SETPOINT_INDEX_AUTO_DECO].note.ub.active; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
396 const SDecoinfo *decoInfo = getDecoInfo(); |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
397 uint8_t nextDecoStopDepthM; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
398 uint16_t nextDecoStopTimeRemainingS; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
399 tHome_findNextStop(decoInfo->output_stop_length_seconds, &nextDecoStopDepthM, &nextDecoStopTimeRemainingS); |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
400 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
401 if (decoSetpointEnabled && nextDecoStopDepthM && currentDepthM < nextDecoStopDepthM + SETPOINT_DECO_START_RANGE_M && !diveState->lifeData.setpointDecoActivated) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
402 betterSetpointIdLocal = SETPOINT_INDEX_AUTO_DECO; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
403 diveState->lifeData.setpointDecoActivated = true; |
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
|
404 } |
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
|
405 |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
406 if (descending) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
407 uint8_t switchDepthHighM = diveState->diveSettings.setpoint[SETPOINT_INDEX_AUTO_HIGH].depth_meter; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
408 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
409 if (lastChangeDepthM < switchDepthHighM && switchDepthHighM < currentDepthM && !diveState->lifeData.setpointDecoActivated) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
410 betterSetpointIdLocal = SETPOINT_INDEX_AUTO_HIGH; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
411 } |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
412 } else { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
413 uint8_t switchDepthLowM = diveState->diveSettings.setpoint[SETPOINT_INDEX_AUTO_LOW].depth_meter; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
414 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
415 if (lastChangeDepthM > SWITCH_DEPTH_LOW_MINIMUM_M && SWITCH_DEPTH_LOW_MINIMUM_M > currentDepthM) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
416 // Avoid draining the oxygen supply by surfacing with a setpoint >= 1.0 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
417 betterSetpointIdLocal = SETPOINT_INDEX_AUTO_LOW; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
418 diveState->lifeData.setpointLowDelayed = false; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
419 } else if (lastChangeDepthM > switchDepthLowM && switchDepthLowM > currentDepthM) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
420 if (nextDecoStopDepthM && settings->delaySetpointLow) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
421 diveState->lifeData.setpointLowDelayed = true; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
422 } else { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
423 betterSetpointIdLocal = SETPOINT_INDEX_AUTO_LOW; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
424 } |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
425 } |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
426 } |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
427 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
428 if (!nextDecoStopDepthM) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
429 // Update the state when the decompression obligation ends |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
430 diveState->lifeData.setpointDecoActivated = false; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
431 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
432 if (diveState->lifeData.setpointLowDelayed) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
433 betterSetpointIdLocal = SETPOINT_INDEX_AUTO_LOW; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
434 diveState->lifeData.setpointLowDelayed = false; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
435 } |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
436 } |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
437 } else { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
438 uint8_t setpointLowId = getSetpointLowId(); |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
439 uint8_t setpointHighId = getSetpointHighId(); |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
440 uint8_t betterSetpointSwitchDepthM = descending ? 0 : UINT8_MAX; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
441 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
442 for (unsigned i = 1; i <= NUM_GASES; i++) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
443 uint8_t switchDepthM = diveState->diveSettings.setpoint[i].depth_meter; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
444 if (!switchDepthM || (descending && i == setpointLowId) || (!descending && i == setpointHighId)) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
445 continue; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
446 } |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
447 |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
448 if ((descending && lastChangeDepthM < switchDepthM && switchDepthM < currentDepthM && switchDepthM > betterSetpointSwitchDepthM) |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
449 || (!descending && lastChangeDepthM > switchDepthM && switchDepthM > currentDepthM && switchDepthM <= betterSetpointSwitchDepthM)) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
450 betterSetpointIdLocal = i; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
451 betterSetpointSwitchDepthM = switchDepthM; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
773
diff
changeset
|
452 } |
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
|
453 } |
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
|
454 } |
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
|
455 |
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
|
456 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
|
457 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
|
458 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
|
459 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
|
460 } |
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
|
461 } |
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
|
462 } |
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
|
463 |
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
|
464 return diveState->warnings.betterSetpoint; |
38 | 465 } |
466 | |
467 | |
468 /* hw 151030 | |
469 */ | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
470 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2) |
38 | 471 { |
472 if(gas1->helium_percentage != gas2->helium_percentage) | |
473 return 0; | |
474 else | |
475 if(gas1->oxygen_percentage != gas2->oxygen_percentage) | |
476 return 0; | |
477 else | |
478 return 1; | |
479 } | |
480 | |
481 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
482 static int8_t check_CNS(SDiveState * pDiveState) |
38 | 483 { |
484 if(stateUsed->mode != MODE_DIVE) | |
485 { | |
486 pDiveState->warnings.cnsHigh = 0; | |
487 return 0; | |
488 } | |
489 | |
490 if(pDiveState->lifeData.cns >= (float)(settingsGetPointer()->CNS_max)) | |
491 pDiveState->warnings.cnsHigh = 1; | |
492 else | |
493 pDiveState->warnings.cnsHigh = 0; | |
494 return pDiveState->warnings.cnsHigh; | |
495 } | |
496 | |
497 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
498 static int8_t check_Battery(SDiveState * pDiveState) |
38 | 499 { |
671
b456be1e152d
Support of unknown charging counter values:
Ideenmodellierer
parents:
662
diff
changeset
|
500 if((pDiveState->lifeData.battery_charge > 0) && (pDiveState->lifeData.battery_charge < 10)) |
38 | 501 pDiveState->warnings.lowBattery = 1; |
502 else | |
503 pDiveState->warnings.lowBattery = 0; | |
504 | |
505 return pDiveState->warnings.lowBattery; | |
506 } | |
507 | |
508 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
509 static int8_t check_Deco(SDiveState * pDiveState) |
38 | 510 { |
511 if(stateUsed->mode != MODE_DIVE) | |
512 { | |
513 pDiveState->warnings.decoMissed = 0; | |
514 return 0; | |
515 } | |
516 | |
517 uint8_t depthNext = decom_get_actual_deco_stop(pDiveState); | |
518 | |
519 if(!depthNext) | |
520 pDiveState->warnings.decoMissed = 0; | |
521 else | |
522 if(pDiveState->lifeData.depth_meter + 0.1f < (float)depthNext) | |
523 pDiveState->warnings.decoMissed = 1; | |
524 else | |
525 pDiveState->warnings.decoMissed = 0; | |
526 | |
527 return pDiveState->warnings.decoMissed; | |
528 } | |
529 | |
530 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
531 static int8_t check_AscentRate(SDiveState * pDiveState) |
38 | 532 { |
533 if(stateUsed->mode != MODE_DIVE) | |
534 { | |
535 pDiveState->warnings.ascentRateHigh = 0; | |
536 return 0; | |
537 } | |
538 | |
539 float warnAscentRateFloat; | |
540 | |
541 warnAscentRateFloat = (float)(settingsGetPointer()->ascent_MeterPerMinute_max); | |
542 | |
543 if(pDiveState->lifeData.ascent_rate_meter_per_min >= warnAscentRateFloat) | |
544 pDiveState->warnings.ascentRateHigh = 1; | |
545 else | |
546 pDiveState->warnings.ascentRateHigh = 0; | |
547 return pDiveState->warnings.ascentRateHigh; | |
548 } | |
549 | |
550 | |
268
1b9847d40e81
cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
551 static int8_t check_aGF(SDiveState * pDiveState) |
38 | 552 { |
553 if(stateUsed->mode != MODE_DIVE) | |
554 { | |
555 pDiveState->warnings.aGf = 0; | |
556 return 0; | |
557 } | |
558 | |
559 pDiveState->warnings.aGf = 0; | |
560 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE) | |
561 { | |
562 if((pDiveState->diveSettings.gf_high != settingsGetPointer()->GF_high) || (pDiveState->diveSettings.gf_low != settingsGetPointer()->GF_low)) | |
563 pDiveState->warnings.aGf = 1; | |
564 } | |
565 return pDiveState->warnings.aGf; | |
566 } | |
567 | |
478
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
568 #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
|
569 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
|
570 { |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
571 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
|
572 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
|
573 { |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
574 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
|
575 ret = 1; |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
576 } |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
577 else |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
578 { |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
579 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
|
580 } |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
581 return ret; |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
582 } |
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
272
diff
changeset
|
583 #endif |
636 | 584 |
756 | 585 #ifdef ENABLE_CO2_SUPPORT |
586 static int8_t check_co2(SDiveState * pDiveState) | |
587 { | |
831 | 588 if((pDiveState->mode != MODE_DIVE) || (settingsGetPointer()->co2_sensor_active == 0)) |
756 | 589 { |
590 pDiveState->warnings.co2High = 0; | |
591 } | |
592 else | |
593 { | |
594 if(pDiveState->lifeData.CO2_data.CO2_ppm > CO2_ALARM_LEVEL_PPM) | |
595 { | |
596 pDiveState->warnings.co2High = 1; | |
597 } | |
598 else | |
599 { | |
600 pDiveState->warnings.co2High = 0; | |
601 } | |
602 } | |
603 return pDiveState->warnings.co2High; | |
604 } | |
605 #endif | |
606 | |
857 | 607 #ifdef HAVE_DEBUG_WARNINGS |
608 static int8_t check_debug(SDiveState * pDiveState) | |
609 { | |
610 uint8_t index = 0; | |
611 | |
612 pDiveState->warnings.debug = 0; | |
613 | |
614 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)) | |
615 { | |
616 for(index=0; index<3; index++) | |
617 { | |
618 if(((pDiveState->lifeData.extIf_sensor_map[index] == SENSOR_DIGO2M) && (((SSensorDataDiveO2*)(stateUsed->lifeData.extIf_sensor_data[index]))->status & DVO2_FATAL_ERROR))) | |
619 { | |
620 pDiveState->warnings.debug = 1; | |
621 } | |
622 } | |
623 } | |
624 return pDiveState->warnings.debug; | |
625 } | |
626 #endif | |
627 | |
636 | 628 uint8_t debounce_warning_fallback(uint16_t debounceStepms) |
629 { | |
630 uint8_t retVal = 0; | |
631 | |
632 debounceFallbackTimeMS += debounceStepms; | |
633 if(debounceFallbackTimeMS > DEBOUNCE_FALLBACK_TIME_MS) | |
634 { | |
635 debounceFallbackTimeMS = DEBOUNCE_FALLBACK_TIME_MS; | |
636 retVal = 1; | |
637 } | |
638 return retVal; | |
639 } | |
640 void reset_debounce_warning_fallback() | |
641 { | |
642 debounceFallbackTimeMS = 0; | |
643 } | |
38 | 644 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |
645 |