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
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
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
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 */
952
+ − 46 #define GUI_BUZZER_TIMEOUT_MS (200u) /* the buzzer should be active while Warning string is shown, but diver may be in a menu... */
636
+ − 47
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
diff
changeset
+ − 48 #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
diff
changeset
+ − 49 #define SWITCH_DEPTH_LOW_MINIMUM_M 1.0
756
+ − 50
268
+ − 51 /* Private variables with access ----------------------------------------------*/
+ − 52 static uint8_t betterGasId = 0;
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 53 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
diff
changeset
+ − 54 static uint8_t betterSetpointId = 1;
268
+ − 55 static int8_t fallback = 0;
636
+ − 56 static uint16_t debounceFallbackTimeMS = 0;
952
+ − 57 static uint8_t buzzerRequestActive = 0;
38
+ − 58
+ − 59 /* Private function prototypes -----------------------------------------------*/
268
+ − 60 static int8_t check_fallback(SDiveState * pDiveState);
+ − 61 static int8_t check_ppO2(SDiveState * pDiveState);
+ − 62 static int8_t check_O2_sensors(SDiveState * pDiveState);
+ − 63 static int8_t check_CNS(SDiveState * pDiveState);
+ − 64 static int8_t check_Deco(SDiveState * pDiveState);
+ − 65 static int8_t check_AscentRate(SDiveState * pDiveState);
+ − 66 static int8_t check_aGF(SDiveState * pDiveState);
+ − 67 static int8_t check_BetterGas(SDiveState * pDiveState);
+ − 68 static int8_t check_BetterSetpoint(SDiveState * pDiveState);
+ − 69 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
diff
changeset
+ − 70 #ifdef ENABLE_BOTTLE_SENSOR
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 71 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
diff
changeset
+ − 72 #endif
756
+ − 73 #ifdef ENABLE_CO2_SUPPORT
+ − 74 static int8_t check_co2(SDiveState * pDiveState);
+ − 75 #endif
268
+ − 76 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2);
857
+ − 77 #ifdef HAVE_DEBUG_WARNINGS
+ − 78 static int8_t check_debug(SDiveState * pDiveState);
+ − 79 #endif
952
+ − 80 static uint8_t buzzerOn = 0; /* current state of the buzzer */
857
+ − 81
952
+ − 82 static void setBuzzer(int8_t warningActive);
+ − 83 /* Exported functions --------------------------------------------------------*/
+ − 84
+ − 85 void requestBuzzerActivation(uint8_t active)
+ − 86 {
+ − 87 buzzerRequestActive = active;
+ − 88 }
+ − 89
+ − 90 uint8_t getBuzzerActivationState()
+ − 91 {
+ − 92 return buzzerOn;
+ − 93 }
+ − 94
+ − 95 static void setBuzzer(int8_t warningActive)
+ − 96 {
+ − 97 static uint32_t guiTimeoutCnt = 0; /* max delay till buzzer will be activated independend from gui request */
+ − 98 static uint32_t stateTick = 0; /* activation tick of current state */
+ − 99 static uint8_t lastWarningState = 0; /* the parameter value of the last call*/
+ − 100
+ − 101 uint32_t tick = HAL_GetTick();
38
+ − 102
952
+ − 103 if(warningActive)
+ − 104 {
+ − 105 if(!lastWarningState) /* init structures */
+ − 106 {
+ − 107 guiTimeoutCnt = tick;
+ − 108 stateTick = tick;
+ − 109 }
+ − 110 if(buzzerOn)
+ − 111 {
+ − 112 if(time_elapsed_ms(stateTick, tick) > EXT_INTERFACE_BUZZER_STABLE_TIME_MS) /* buzzer has to be on for a certain time */
+ − 113 {
+ − 114 if((!buzzerRequestActive) || (time_elapsed_ms(stateTick, tick) > EXT_INTERFACE_BUZZER_ON_TIME_MS))
+ − 115 {
+ − 116 buzzerOn = 0;
+ − 117 stateTick = tick;
+ − 118 guiTimeoutCnt = tick;
+ − 119 }
+ − 120 }
+ − 121 }
+ − 122 else
+ − 123 {
+ − 124 if(time_elapsed_ms(stateTick, tick) > EXT_INTERFACE_BUZZER_STABLE_TIME_MS) /* buzzer has to be off for a certain time */
+ − 125 {
+ − 126 if((buzzerRequestActive) || (time_elapsed_ms(guiTimeoutCnt, tick) > EXT_INTERFACE_BUZZER_ON_TIME_MS + GUI_BUZZER_TIMEOUT_MS))
+ − 127 {
+ − 128 buzzerOn = 1;
+ − 129 stateTick = tick;
+ − 130 }
+ − 131 }
+ − 132 }
+ − 133 }
+ − 134 else
+ − 135 {
+ − 136 buzzerOn = 0;
+ − 137 }
+ − 138 lastWarningState = warningActive;
+ − 139 }
38
+ − 140
+ − 141 void check_warning(void)
+ − 142 {
272
+ − 143 check_warning2(stateUsedWrite);
38
+ − 144 }
+ − 145
+ − 146
+ − 147 void check_warning2(SDiveState * pDiveState)
+ − 148 {
+ − 149 pDiveState->warnings.numWarnings = 0;
+ − 150
952
+ − 151 /* Warnings checked before the SetBuzzer call will activate the buzzer */
38
+ − 152 pDiveState->warnings.numWarnings += check_AscentRate(pDiveState);
+ − 153 pDiveState->warnings.numWarnings += check_Deco(pDiveState);
+ − 154 pDiveState->warnings.numWarnings += check_ppO2(pDiveState);
+ − 155 pDiveState->warnings.numWarnings += check_O2_sensors(pDiveState);
952
+ − 156 pDiveState->warnings.numWarnings += check_fallback(pDiveState);
+ − 157 #ifdef ENABLE_CO2_SUPPORT
+ − 158 pDiveState->warnings.numWarnings += check_co2(pDiveState);
+ − 159 #endif
+ − 160
+ − 161 if(settingsGetPointer()->warningBuzzer)
+ − 162 {
+ − 163 setBuzzer(pDiveState->warnings.numWarnings);
+ − 164 }
+ − 165
+ − 166 /* Warnings checked after this line will not cause activation of the buzzer */
+ − 167 pDiveState->warnings.numWarnings += check_aGF(pDiveState);
+ − 168 pDiveState->warnings.numWarnings += check_CNS(pDiveState);
38
+ − 169 pDiveState->warnings.numWarnings += check_BetterGas(pDiveState);
+ − 170 pDiveState->warnings.numWarnings += check_BetterSetpoint(pDiveState);
+ − 171 pDiveState->warnings.numWarnings += check_Battery(pDiveState);
478
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 172 #ifdef ENABLE_BOTTLE_SENSOR
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 173 pDiveState->warnings.numWarnings += check_pressureSensor(pDiveState);
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 174 #endif
952
+ − 175
857
+ − 176 #ifdef HAVE_DEBUG_WARNINGS
+ − 177 pDiveState->warnings.numWarnings += check_debug(pDiveState);
+ − 178 #endif
38
+ − 179 }
+ − 180
+ − 181
+ − 182 void set_warning_fallback(void)
+ − 183 {
+ − 184 fallback = 1;
+ − 185 }
+ − 186
+ − 187
+ − 188 void clear_warning_fallback(void)
+ − 189 {
+ − 190 fallback = 0;
636
+ − 191 debounceFallbackTimeMS = 0;
38
+ − 192 }
+ − 193
+ − 194
+ − 195 uint8_t actualBetterGasId(void)
+ − 196 {
+ − 197 return betterGasId;
+ − 198 }
+ − 199
+ − 200
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 201 uint8_t actualBetterBailoutGasId(void)
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 202 {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 203 return betterBailoutGasId;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 204 }
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 205
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 206
38
+ − 207 uint8_t actualBetterSetpointId(void)
+ − 208 {
+ − 209 return betterSetpointId;
+ − 210 }
+ − 211
+ − 212
+ − 213 uint8_t actualLeftMaxDepth(const SDiveState * pDiveState)
+ − 214 {
+ − 215 if(pDiveState->lifeData.depth_meter > (pDiveState->lifeData.max_depth_meter - 3.0f))
+ − 216 return 0;
+ − 217 else
+ − 218 return 1;
+ − 219 }
+ − 220
+ − 221
+ − 222 /* Private functions ---------------------------------------------------------*/
268
+ − 223 static int8_t check_fallback(SDiveState * pDiveState)
38
+ − 224 {
662
+ − 225 if(fallback && ((pDiveState->mode != MODE_DIVE) || (!isLoopMode(pDiveState->diveSettings.diveMode))))
38
+ − 226 fallback = 0;
+ − 227
+ − 228 pDiveState->warnings.fallback = fallback;
+ − 229 return pDiveState->warnings.fallback;
+ − 230 }
+ − 231
+ − 232
268
+ − 233 static int8_t check_ppO2(SDiveState * pDiveState)
38
+ − 234 {
952
+ − 235 if((pDiveState->mode != MODE_DIVE) || ((isLoopMode(pDiveState->diveSettings.diveMode) && (pDiveState->warnings.fallback))))
38
+ − 236 {
+ − 237 pDiveState->warnings.ppO2Low = 0;
+ − 238 pDiveState->warnings.ppO2High = 0;
+ − 239 return 0;
+ − 240 }
+ − 241
+ − 242 uint8_t localPPO2, testPPO2high;
+ − 243
+ − 244 if(pDiveState->lifeData.ppO2 < 0)
+ − 245 localPPO2 = 0;
+ − 246 else
+ − 247 if(pDiveState->lifeData.ppO2 >= 2.5f)
+ − 248 localPPO2 = 255;
+ − 249 else
+ − 250 localPPO2 = (uint8_t)(pDiveState->lifeData.ppO2 * 100);
+ − 251
+ − 252 if((localPPO2 + 1) <= settingsGetPointer()->ppO2_min)
+ − 253 pDiveState->warnings.ppO2Low = 1;
+ − 254 else
+ − 255 pDiveState->warnings.ppO2Low = 0;
+ − 256
+ − 257 if(actualLeftMaxDepth(pDiveState))
+ − 258 testPPO2high = settingsGetPointer()->ppO2_max_deco;
+ − 259 else
+ − 260 testPPO2high = settingsGetPointer()->ppO2_max_std;
+ − 261
+ − 262 if(localPPO2 >= (testPPO2high + 1))
+ − 263 pDiveState->warnings.ppO2High = 1;
+ − 264 else
+ − 265 pDiveState->warnings.ppO2High = 0;
+ − 266
+ − 267 return pDiveState->warnings.ppO2Low + pDiveState->warnings.ppO2High;
+ − 268 }
+ − 269
+ − 270
268
+ − 271 static int8_t check_O2_sensors(SDiveState * pDiveState)
38
+ − 272 {
+ − 273 pDiveState->warnings.sensorLinkLost = 0;
+ − 274 pDiveState->warnings.sensorOutOfBounds[0] = 0;
+ − 275 pDiveState->warnings.sensorOutOfBounds[1] = 0;
+ − 276 pDiveState->warnings.sensorOutOfBounds[2] = 0;
+ − 277
662
+ − 278 if(isLoopMode(pDiveState->diveSettings.diveMode) && (pDiveState->diveSettings.CCR_Mode == CCRMODE_Sensors))
952
+ − 279 {
563
+ − 280 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
+ − 281 {
+ − 282 {
+ − 283 if(!get_HUD_battery_voltage_V())
+ − 284 pDiveState->warnings.sensorLinkLost = 1;
+ − 285 }
+ − 286 }
952
+ − 287 test_O2_sensor_values_outOfBounds(&pDiveState->warnings.sensorOutOfBounds[0], &pDiveState->warnings.sensorOutOfBounds[1], &pDiveState->warnings.sensorOutOfBounds[2]);
+ − 288 }
38
+ − 289 return pDiveState->warnings.sensorLinkLost
+ − 290 + pDiveState->warnings.sensorOutOfBounds[0]
+ − 291 + pDiveState->warnings.sensorOutOfBounds[1]
+ − 292 + pDiveState->warnings.sensorOutOfBounds[2];
+ − 293 }
+ − 294
+ − 295
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 296 static uint8_t getBetterGasId(bool getDiluent, uint8_t startingGasId, SDiveState *diveState)
38
+ − 297 {
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 298 SDiveSettings diveSettings = diveState->diveSettings;
831
+ − 299 SGasLine localGas;
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 300 uint8_t betterGasIdLocal = startingGasId;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 301 uint8_t bestGasDepth = 255;
831
+ − 302 uint8_t i;
38
+ − 303
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 304 uint8_t gasIdOffset;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 305 if (getDiluent) {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 306 gasIdOffset = NUM_OFFSET_DILUENT;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 307 } else {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 308 gasIdOffset = 0;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 309 }
38
+ − 310
+ − 311 /* life data is float, gas data is uint8 */
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 312 if (actualLeftMaxDepth(diveState)) { /* deco gases */
831
+ − 313 for (i=1+gasIdOffset; i<= 5+gasIdOffset; i++) {
+ − 314 memcpy(&localGas,&diveSettings.gas[i],sizeof(SGasLine));
+ − 315 if((localGas.note.ub.first) && (diveSettings.diveMode == DIVEMODE_PSCR)) /* handle first gas as if it would be a deco gas set to MOD */
+ − 316 {
+ − 317 localGas.note.ub.active = 1;
+ − 318 localGas.note.ub.deco = 1;
+ − 319 localGas.depth_meter = calc_MOD(i);
+ − 320 }
+ − 321 if ((localGas.note.ub.active)
+ − 322 && (localGas.note.ub.deco)
+ − 323 && (localGas.depth_meter)
913
+ − 324 && (localGas.depth_meter >= (diveState->lifeData.depth_meter - 0.9f ))
831
+ − 325 && (localGas.depth_meter <= bestGasDepth)) {
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 326 betterGasIdLocal = i;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 327 bestGasDepth = diveSettings.gas[i].depth_meter;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 328 }
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 329 }
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 330 } else { /* travel gases */
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 331 bestGasDepth = 0;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 332 //check for travalgas
831
+ − 333 for (i = 1 + gasIdOffset; i <= 5 + gasIdOffset; i++) {
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 334 if ((diveSettings.gas[i].note.ub.active)
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 335 && (diveSettings.gas[i].note.ub.travel)
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 336 && (diveSettings.gas[i].depth_meter_travel)
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 337 && (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
diff
changeset
+ − 338 && (diveSettings.gas[i].depth_meter_travel >= bestGasDepth)) {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 339 betterGasIdLocal = i;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 340 bestGasDepth = diveSettings.gas[i].depth_meter;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 341 }
38
+ − 342 }
+ − 343 }
831
+ − 344 if((!getDiluent) && (betterGasIdLocal > NUM_OFFSET_DILUENT)) /* an OC gas was requested but Id is pointing to a diluent => return first OC */
+ − 345 {
+ − 346 for (i = 1 ; i <= NUM_OFFSET_DILUENT; i++)
+ − 347 {
+ − 348 if(diveSettings.gas[i].note.ub.first)
+ − 349 {
+ − 350 betterGasIdLocal = i;
+ − 351 break;
+ − 352 }
+ − 353 }
+ − 354 }
+ − 355
38
+ − 356
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 357 return betterGasIdLocal;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 358 }
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 359
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 360
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 361 static int8_t check_BetterGas(SDiveState *diveState)
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 362 {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 363 diveState->warnings.betterGas = 0;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 364
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 365 if (stateUsed->mode != MODE_DIVE) {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 366 betterGasId = 0;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 367
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 368 return 0;
38
+ − 369 }
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 370
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 371 SDiveSettings diveSettings = diveState->diveSettings;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 372 SLifeData lifeData = diveState->lifeData;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 373
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 374 if (isLoopMode(diveSettings.diveMode)) {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 375 betterGasId = getBetterGasId(true, lifeData.actualGas.GasIdInSettings, diveState);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 376 betterBailoutGasId = getBetterGasId(false, lifeData.lastDiluent_GasIdInSettings, diveState);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 377 } else {
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 378 betterGasId = getBetterGasId(false, lifeData.actualGas.GasIdInSettings, diveState);
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 379 }
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 380
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 381 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
diff
changeset
+ − 382 diveState->warnings.betterGas = 1;
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 383 }
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 384
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
diff
changeset
+ − 385 return diveState->warnings.betterGas;
38
+ − 386 }
+ − 387
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
diff
changeset
+ − 388
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
diff
changeset
+ − 389 uint8_t getSetpointLowId(void)
38
+ − 390 {
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
diff
changeset
+ − 391 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
diff
changeset
+ − 392
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
diff
changeset
+ − 393 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
diff
changeset
+ − 394 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
diff
changeset
+ − 395 }
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
diff
changeset
+ − 396
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
diff
changeset
+ − 397 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
diff
changeset
+ − 398 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
diff
changeset
+ − 399 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
diff
changeset
+ − 400 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
diff
changeset
+ − 401 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
diff
changeset
+ − 402 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
diff
changeset
+ − 403 }
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
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
diff
changeset
+ − 405
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
diff
changeset
+ − 406 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
diff
changeset
+ − 407 }
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
diff
changeset
+ − 408
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
diff
changeset
+ − 409
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
diff
changeset
+ − 410 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
diff
changeset
+ − 411 {
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
diff
changeset
+ − 412 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
diff
changeset
+ − 413
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
diff
changeset
+ − 414 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
diff
changeset
+ − 415 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
diff
changeset
+ − 416 }
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
diff
changeset
+ − 417
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
diff
changeset
+ − 418 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
diff
changeset
+ − 419 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
diff
changeset
+ − 420 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
diff
changeset
+ − 421 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
diff
changeset
+ − 422 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
diff
changeset
+ − 423 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
diff
changeset
+ − 424 }
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
diff
changeset
+ − 425 }
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
diff
changeset
+ − 426
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
diff
changeset
+ − 427 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
diff
changeset
+ − 428 }
38
+ − 429
662
+ − 430
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
diff
changeset
+ − 431 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
diff
changeset
+ − 432 {
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
diff
changeset
+ − 433 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
diff
changeset
+ − 434
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
diff
changeset
+ − 435 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
diff
changeset
+ − 436 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
diff
changeset
+ − 437 }
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
diff
changeset
+ − 438
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
diff
changeset
+ − 439 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
diff
changeset
+ − 440 }
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
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
diff
changeset
+ − 442
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
diff
changeset
+ − 443 /* 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
diff
changeset
+ − 444 */
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
diff
changeset
+ − 445 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
diff
changeset
+ − 446 {
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
diff
changeset
+ − 447 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
diff
changeset
+ − 448
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
diff
changeset
+ − 449 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
diff
changeset
+ − 450 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
diff
changeset
+ − 451
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
diff
changeset
+ − 452 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
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
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
diff
changeset
+ − 455 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
diff
changeset
+ − 456
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
diff
changeset
+ − 457 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
diff
changeset
+ − 458 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
diff
changeset
+ − 459 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
diff
changeset
+ − 460 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
diff
changeset
+ − 461 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
diff
changeset
+ − 462
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
diff
changeset
+ − 463 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
diff
changeset
+ − 464 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
diff
changeset
+ − 465 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
diff
changeset
+ − 466 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
diff
changeset
+ − 467 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
diff
changeset
+ − 468 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
diff
changeset
+ − 469
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
diff
changeset
+ − 470 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
diff
changeset
+ − 471 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
diff
changeset
+ − 472 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
diff
changeset
+ − 473 }
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
diff
changeset
+ − 474
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
diff
changeset
+ − 475 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
diff
changeset
+ − 476 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
diff
changeset
+ − 477
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
diff
changeset
+ − 478 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
diff
changeset
+ − 479 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
diff
changeset
+ − 480 }
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
diff
changeset
+ − 481 } 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
diff
changeset
+ − 482 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
diff
changeset
+ − 483
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
diff
changeset
+ − 484 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
diff
changeset
+ − 485 // 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
diff
changeset
+ − 486 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
diff
changeset
+ − 487 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
diff
changeset
+ − 488 } 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
diff
changeset
+ − 489 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
diff
changeset
+ − 490 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
diff
changeset
+ − 491 } 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
diff
changeset
+ − 492 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
diff
changeset
+ − 493 }
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
diff
changeset
+ − 494 }
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
diff
changeset
+ − 495 }
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
diff
changeset
+ − 496
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
diff
changeset
+ − 497 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
diff
changeset
+ − 498 // 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
diff
changeset
+ − 499 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
diff
changeset
+ − 500
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
diff
changeset
+ − 501 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
diff
changeset
+ − 502 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
diff
changeset
+ − 503 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
diff
changeset
+ − 504 }
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
diff
changeset
+ − 505 }
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
diff
changeset
+ − 506 } 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
diff
changeset
+ − 507 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
diff
changeset
+ − 508 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
diff
changeset
+ − 509 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
diff
changeset
+ − 510
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
diff
changeset
+ − 511 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
diff
changeset
+ − 512 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
diff
changeset
+ − 513 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
diff
changeset
+ − 514 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
diff
changeset
+ − 515 }
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
diff
changeset
+ − 516
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
diff
changeset
+ − 517 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
diff
changeset
+ − 518 || (!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
diff
changeset
+ − 519 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
diff
changeset
+ − 520 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
diff
changeset
+ − 521 }
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
diff
changeset
+ − 522 }
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
diff
changeset
+ − 523 }
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
diff
changeset
+ − 524
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
diff
changeset
+ − 525 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
diff
changeset
+ − 526 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
diff
changeset
+ − 527 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
diff
changeset
+ − 528 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
diff
changeset
+ − 529 }
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
diff
changeset
+ − 530 }
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
diff
changeset
+ − 531 }
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
diff
changeset
+ − 532
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
diff
changeset
+ − 533 return diveState->warnings.betterSetpoint;
38
+ − 534 }
+ − 535
+ − 536
+ − 537 /* hw 151030
+ − 538 */
268
+ − 539 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2)
38
+ − 540 {
+ − 541 if(gas1->helium_percentage != gas2->helium_percentage)
+ − 542 return 0;
+ − 543 else
+ − 544 if(gas1->oxygen_percentage != gas2->oxygen_percentage)
+ − 545 return 0;
+ − 546 else
+ − 547 return 1;
+ − 548 }
+ − 549
+ − 550
268
+ − 551 static int8_t check_CNS(SDiveState * pDiveState)
38
+ − 552 {
+ − 553 if(stateUsed->mode != MODE_DIVE)
+ − 554 {
+ − 555 pDiveState->warnings.cnsHigh = 0;
+ − 556 return 0;
+ − 557 }
+ − 558
+ − 559 if(pDiveState->lifeData.cns >= (float)(settingsGetPointer()->CNS_max))
+ − 560 pDiveState->warnings.cnsHigh = 1;
+ − 561 else
+ − 562 pDiveState->warnings.cnsHigh = 0;
+ − 563 return pDiveState->warnings.cnsHigh;
+ − 564 }
+ − 565
+ − 566
268
+ − 567 static int8_t check_Battery(SDiveState * pDiveState)
38
+ − 568 {
671
+ − 569 if((pDiveState->lifeData.battery_charge > 0) && (pDiveState->lifeData.battery_charge < 10))
38
+ − 570 pDiveState->warnings.lowBattery = 1;
+ − 571 else
+ − 572 pDiveState->warnings.lowBattery = 0;
+ − 573
+ − 574 return pDiveState->warnings.lowBattery;
+ − 575 }
+ − 576
+ − 577
268
+ − 578 static int8_t check_Deco(SDiveState * pDiveState)
38
+ − 579 {
+ − 580 if(stateUsed->mode != MODE_DIVE)
+ − 581 {
+ − 582 pDiveState->warnings.decoMissed = 0;
+ − 583 return 0;
+ − 584 }
+ − 585
+ − 586 uint8_t depthNext = decom_get_actual_deco_stop(pDiveState);
+ − 587
+ − 588 if(!depthNext)
+ − 589 pDiveState->warnings.decoMissed = 0;
+ − 590 else
+ − 591 if(pDiveState->lifeData.depth_meter + 0.1f < (float)depthNext)
+ − 592 pDiveState->warnings.decoMissed = 1;
+ − 593 else
+ − 594 pDiveState->warnings.decoMissed = 0;
+ − 595
+ − 596 return pDiveState->warnings.decoMissed;
+ − 597 }
+ − 598
+ − 599
268
+ − 600 static int8_t check_AscentRate(SDiveState * pDiveState)
38
+ − 601 {
+ − 602 if(stateUsed->mode != MODE_DIVE)
+ − 603 {
+ − 604 pDiveState->warnings.ascentRateHigh = 0;
+ − 605 return 0;
+ − 606 }
+ − 607
+ − 608 float warnAscentRateFloat;
+ − 609
+ − 610 warnAscentRateFloat = (float)(settingsGetPointer()->ascent_MeterPerMinute_max);
+ − 611
+ − 612 if(pDiveState->lifeData.ascent_rate_meter_per_min >= warnAscentRateFloat)
+ − 613 pDiveState->warnings.ascentRateHigh = 1;
+ − 614 else
+ − 615 pDiveState->warnings.ascentRateHigh = 0;
+ − 616 return pDiveState->warnings.ascentRateHigh;
+ − 617 }
+ − 618
+ − 619
268
+ − 620 static int8_t check_aGF(SDiveState * pDiveState)
38
+ − 621 {
+ − 622 if(stateUsed->mode != MODE_DIVE)
+ − 623 {
+ − 624 pDiveState->warnings.aGf = 0;
+ − 625 return 0;
+ − 626 }
+ − 627
+ − 628 pDiveState->warnings.aGf = 0;
+ − 629 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE)
+ − 630 {
+ − 631 if((pDiveState->diveSettings.gf_high != settingsGetPointer()->GF_high) || (pDiveState->diveSettings.gf_low != settingsGetPointer()->GF_low))
+ − 632 pDiveState->warnings.aGf = 1;
+ − 633 }
+ − 634 return pDiveState->warnings.aGf;
+ − 635 }
+ − 636
478
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 637 #ifdef ENABLE_BOTTLE_SENSOR
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 638 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
diff
changeset
+ − 639 {
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 640 int8_t ret = 0;
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 641 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
diff
changeset
+ − 642 {
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 643 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
diff
changeset
+ − 644 ret = 1;
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 645 }
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 646 else
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 647 {
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 648 pDiveState->warnings.newPressure = 0;
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 649 }
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 650 return ret;
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 651 }
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
diff
changeset
+ − 652 #endif
636
+ − 653
756
+ − 654 #ifdef ENABLE_CO2_SUPPORT
+ − 655 static int8_t check_co2(SDiveState * pDiveState)
+ − 656 {
831
+ − 657 if((pDiveState->mode != MODE_DIVE) || (settingsGetPointer()->co2_sensor_active == 0))
756
+ − 658 {
+ − 659 pDiveState->warnings.co2High = 0;
+ − 660 }
+ − 661 else
+ − 662 {
+ − 663 if(pDiveState->lifeData.CO2_data.CO2_ppm > CO2_ALARM_LEVEL_PPM)
+ − 664 {
+ − 665 pDiveState->warnings.co2High = 1;
+ − 666 }
+ − 667 else
+ − 668 {
+ − 669 pDiveState->warnings.co2High = 0;
+ − 670 }
+ − 671 }
+ − 672 return pDiveState->warnings.co2High;
+ − 673 }
+ − 674 #endif
+ − 675
857
+ − 676 #ifdef HAVE_DEBUG_WARNINGS
+ − 677 static int8_t check_debug(SDiveState * pDiveState)
+ − 678 {
+ − 679 uint8_t index = 0;
+ − 680
+ − 681 pDiveState->warnings.debug = 0;
+ − 682
+ − 683 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG))
+ − 684 {
+ − 685 for(index=0; index<3; index++)
+ − 686 {
+ − 687 if(((pDiveState->lifeData.extIf_sensor_map[index] == SENSOR_DIGO2M) && (((SSensorDataDiveO2*)(stateUsed->lifeData.extIf_sensor_data[index]))->status & DVO2_FATAL_ERROR)))
+ − 688 {
+ − 689 pDiveState->warnings.debug = 1;
+ − 690 }
+ − 691 }
+ − 692 }
+ − 693 return pDiveState->warnings.debug;
+ − 694 }
+ − 695 #endif
+ − 696
636
+ − 697 uint8_t debounce_warning_fallback(uint16_t debounceStepms)
+ − 698 {
+ − 699 uint8_t retVal = 0;
+ − 700
+ − 701 debounceFallbackTimeMS += debounceStepms;
+ − 702 if(debounceFallbackTimeMS > DEBOUNCE_FALLBACK_TIME_MS)
+ − 703 {
+ − 704 debounceFallbackTimeMS = DEBOUNCE_FALLBACK_TIME_MS;
+ − 705 retVal = 1;
+ − 706 }
+ − 707 return retVal;
+ − 708 }
+ − 709 void reset_debounce_warning_fallback()
+ − 710 {
+ − 711 debounceFallbackTimeMS = 0;
+ − 712 }
38
+ − 713 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
+ − 714