annotate Discovery/Src/check_warning.c @ 802:91d5ef16f1fd

Removed dependency to protocol setting: In the first implementation sensors had been selected by switching protocol options. With introduction of the autodetection and sensor map this approach has become obsolete => Removed actions which were derived using the protocol setting.
author Ideenmodellierer
date Thu, 10 Aug 2023 21:27:58 +0200
parents 4abfb8a2a435
children da632300e7d4 fa431d42b5fb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file check_warning.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @date 17-Nov-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @since 17-Nov-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * @brief check and set warnings for warnings
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ##### How to use #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 OSTC3 Warnings:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 niedriger Batteriezustand (
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 zu hoher oder zu niedriger Sauerstoffpartialdruck (ppO2) 0.2 - 1.6
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 zu hoher CNS (Gefahr der Sauerstoffvergiftung) 90%
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 zu hohe Gradientenfaktoren 90 - 90
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 Missachtung der Dekostopps (der �berschrittene Dekostopp wird rot angezeigt) 0 m
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 zu hohe Aufstiegsgeschwindigkeit 30 m/min
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 aGF-Warnung: die Berechnung der Dekompression wird �ber alternative GF-Werte durchgef�hrt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 Fallback-Warnung bei ausgefallenem Sensor
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 * <h2><center>&copy; COPYRIGHT(c) 2014 heinrichs weikamp</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 #include "data_exchange.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 #include "check_warning.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 #include "settings.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 #include "decom.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
44
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
45 #define DEBOUNCE_FALLBACK_TIME_MS (5000u) /* set warning after 5 seconds of pending error condition */
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
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
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
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
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
55 static uint16_t debounceFallbackTimeMS = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
71 #ifdef ENABLE_CO2_SUPPORT
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
72 static int8_t check_co2(SDiveState * pDiveState);
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
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);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 void check_warning(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 {
272
74a8296a2318 cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents: 268
diff changeset
80 check_warning2(stateUsedWrite);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 void check_warning2(SDiveState * pDiveState)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 pDiveState->warnings.numWarnings = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 pDiveState->warnings.numWarnings += check_aGF(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 pDiveState->warnings.numWarnings += check_AscentRate(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 pDiveState->warnings.numWarnings += check_CNS(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 pDiveState->warnings.numWarnings += check_Deco(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 pDiveState->warnings.numWarnings += check_ppO2(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 pDiveState->warnings.numWarnings += check_O2_sensors(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 pDiveState->warnings.numWarnings += check_BetterGas(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 pDiveState->warnings.numWarnings += check_BetterSetpoint(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 pDiveState->warnings.numWarnings += check_Battery(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 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
98 #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
99 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
100 #endif
756
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
101 #ifdef ENABLE_CO2_SUPPORT
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
102 pDiveState->warnings.numWarnings += check_co2(pDiveState);
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
103 #endif
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 void set_warning_fallback(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 fallback = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 void clear_warning_fallback(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 fallback = 0;
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
116 debounceFallbackTimeMS = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 uint8_t actualBetterGasId(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 return betterGasId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
126 uint8_t actualBetterBailoutGasId(void)
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
127 {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
128 return betterBailoutGasId;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
129 }
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
130
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
131
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 uint8_t actualBetterSetpointId(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 return betterSetpointId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 uint8_t actualLeftMaxDepth(const SDiveState * pDiveState)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 if(pDiveState->lifeData.depth_meter > (pDiveState->lifeData.max_depth_meter - 3.0f))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 /* Private functions ---------------------------------------------------------*/
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
148 static int8_t check_fallback(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 {
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
150 if(fallback && ((pDiveState->mode != MODE_DIVE) || (!isLoopMode(pDiveState->diveSettings.diveMode))))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 fallback = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 pDiveState->warnings.fallback = fallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 return pDiveState->warnings.fallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
158 static int8_t check_ppO2(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 {
582
64bf41faab83 Show Fallback if no valid sensor value is available:
Ideenmodellierer
parents: 563
diff changeset
160 if((pDiveState->mode != MODE_DIVE) || (pDiveState->warnings.fallback))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 pDiveState->warnings.ppO2Low = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 pDiveState->warnings.ppO2High = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 uint8_t localPPO2, testPPO2high;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 if(pDiveState->lifeData.ppO2 < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 localPPO2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 if(pDiveState->lifeData.ppO2 >= 2.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 localPPO2 = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 localPPO2 = (uint8_t)(pDiveState->lifeData.ppO2 * 100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 if((localPPO2 + 1) <= settingsGetPointer()->ppO2_min)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 pDiveState->warnings.ppO2Low = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 pDiveState->warnings.ppO2Low = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 if(actualLeftMaxDepth(pDiveState))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 testPPO2high = settingsGetPointer()->ppO2_max_deco;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 testPPO2high = settingsGetPointer()->ppO2_max_std;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 if(localPPO2 >= (testPPO2high + 1))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 pDiveState->warnings.ppO2High = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 pDiveState->warnings.ppO2High = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 return pDiveState->warnings.ppO2Low + pDiveState->warnings.ppO2High;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
196 static int8_t check_O2_sensors(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 pDiveState->warnings.sensorLinkLost = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 pDiveState->warnings.sensorOutOfBounds[0] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 pDiveState->warnings.sensorOutOfBounds[1] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 pDiveState->warnings.sensorOutOfBounds[2] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
203 if(isLoopMode(pDiveState->diveSettings.diveMode) && (pDiveState->diveSettings.CCR_Mode == CCRMODE_Sensors))
563
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
204
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
205 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
206 {
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
207 {
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
208 if(!get_HUD_battery_voltage_V())
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
209 pDiveState->warnings.sensorLinkLost = 1;
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
210 }
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
211 }
634
7c73f066cd16 Enable sensor check for Analog PPO2 mode:
Ideenmodellierer
parents: 582
diff changeset
212 test_O2_sensor_values_outOfBounds(&pDiveState->warnings.sensorOutOfBounds[0], &pDiveState->warnings.sensorOutOfBounds[1], &pDiveState->warnings.sensorOutOfBounds[2]);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 return pDiveState->warnings.sensorLinkLost
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 + pDiveState->warnings.sensorOutOfBounds[0]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 + pDiveState->warnings.sensorOutOfBounds[1]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 + pDiveState->warnings.sensorOutOfBounds[2];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
220 static uint8_t getBetterGasId(bool getDiluent, uint8_t startingGasId, SDiveState *diveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 {
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
222 SDiveSettings diveSettings = diveState->diveSettings;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
224 uint8_t betterGasIdLocal = startingGasId;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
225 uint8_t bestGasDepth = 255;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
227 uint8_t gasIdOffset;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
228 if (getDiluent) {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
229 gasIdOffset = NUM_OFFSET_DILUENT;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
230 } else {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
231 gasIdOffset = 0;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
232 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 /* 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
235 if (actualLeftMaxDepth(diveState)) { /* deco gases */
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
236 for (int i=1+gasIdOffset; i<= 5+gasIdOffset; i++) {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
237 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
238 && (diveSettings.gas[i].note.ub.deco)
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
239 && (diveSettings.gas[i].depth_meter)
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
240 && (diveSettings.gas[i].depth_meter >= (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
241 && (diveSettings.gas[i].depth_meter <= bestGasDepth)) {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
242 betterGasIdLocal = i;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
243 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
244 }
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
245 }
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
246 } else { /* travel gases */
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
247 bestGasDepth = 0;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
248 //check for travalgas
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
249 for (int i = 1 + gasIdOffset; i <= 5 + gasIdOffset; i++) {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
250 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
251 && (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
252 && (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
253 && (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
254 && (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
255 betterGasIdLocal = i;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
256 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
257 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
261 return betterGasIdLocal;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
262 }
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
263
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
264
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
265 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
266 {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
267 diveState->warnings.betterGas = 0;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
268
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
269 if (stateUsed->mode != MODE_DIVE) {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
270 betterGasId = 0;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
271
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
272 return 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 }
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
274
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
275 SDiveSettings diveSettings = diveState->diveSettings;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
276 SLifeData lifeData = diveState->lifeData;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
277
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
278 if (isLoopMode(diveSettings.diveMode)) {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
279 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
280 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
281 } else {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
282 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
283 }
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
284
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
285 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
286 diveState->warnings.betterGas = 1;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
287 }
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
288
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
289 return diveState->warnings.betterGas;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291
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
292
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
293 uint8_t getSetpointLowId(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 {
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
295 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
296
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
297 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
298 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
299 }
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
300
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
301 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
302 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
303 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
304 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
305 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
306 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
307 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
308 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
309
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
310 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
311 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
312
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
313
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
314 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
315 {
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
316 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
317
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
318 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
319 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
320 }
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
321
771
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
322 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
323 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
324 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
325 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
326 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
327 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
328 }
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 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
330
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
331 return 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
332 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
334
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
335 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
336 {
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
337 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
338
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
339 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
340 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
341 }
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
342
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 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
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
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
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
347 /* 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
348 */
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 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
350 {
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
351 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
352
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 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
354 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
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 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
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
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 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
360
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
361 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
362 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
363 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
364 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
365 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
366
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
367 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
368 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
369 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
370 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
371 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
372 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
373
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
374 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
375 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
376 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
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
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
379 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
380 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
381
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
382 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
383 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
384 }
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
385 } 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
386 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
387
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
388 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
389 // 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
390 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
391 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
392 } 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
393 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
394 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
395 } 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
396 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
397 }
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 }
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 }
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 (!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
402 // 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
403 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
404
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
405 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
406 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
407 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
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 }
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 } 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
411 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
412 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
413 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
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 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
416 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
417 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
418 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
419 }
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
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 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
422 || (!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
423 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
424 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
425 }
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
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
parents: 756
diff changeset
427 }
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
428
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
429 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
430 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
431 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
432 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
433 }
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
434 }
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
435 }
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
436
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
437 return diveState->warnings.betterSetpoint;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 /* hw 151030
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 */
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
443 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 if(gas1->helium_percentage != gas2->helium_percentage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 if(gas1->oxygen_percentage != gas2->oxygen_percentage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
455 static int8_t check_CNS(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 pDiveState->warnings.cnsHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 if(pDiveState->lifeData.cns >= (float)(settingsGetPointer()->CNS_max))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 pDiveState->warnings.cnsHigh = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 pDiveState->warnings.cnsHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 return pDiveState->warnings.cnsHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
471 static int8_t check_Battery(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 {
671
b456be1e152d Support of unknown charging counter values:
Ideenmodellierer
parents: 662
diff changeset
473 if((pDiveState->lifeData.battery_charge > 0) && (pDiveState->lifeData.battery_charge < 10))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 pDiveState->warnings.lowBattery = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 pDiveState->warnings.lowBattery = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 return pDiveState->warnings.lowBattery;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
482 static int8_t check_Deco(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 uint8_t depthNext = decom_get_actual_deco_stop(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 if(!depthNext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 if(pDiveState->lifeData.depth_meter + 0.1f < (float)depthNext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 pDiveState->warnings.decoMissed = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 return pDiveState->warnings.decoMissed;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
504 static int8_t check_AscentRate(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 pDiveState->warnings.ascentRateHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 float warnAscentRateFloat;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 warnAscentRateFloat = (float)(settingsGetPointer()->ascent_MeterPerMinute_max);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 if(pDiveState->lifeData.ascent_rate_meter_per_min >= warnAscentRateFloat)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 pDiveState->warnings.ascentRateHigh = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 pDiveState->warnings.ascentRateHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 return pDiveState->warnings.ascentRateHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
524 static int8_t check_aGF(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 pDiveState->warnings.aGf = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 pDiveState->warnings.aGf = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 if((pDiveState->diveSettings.gf_high != settingsGetPointer()->GF_high) || (pDiveState->diveSettings.gf_low != settingsGetPointer()->GF_low))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 pDiveState->warnings.aGf = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 return pDiveState->warnings.aGf;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540
478
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
541 #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
542 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
543 {
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
544 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
545 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
546 {
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
547 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
548 ret = 1;
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
549 }
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
550 else
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
551 {
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
552 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
553 }
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
554 return ret;
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
555 }
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
556 #endif
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
557
756
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
558 #ifdef ENABLE_CO2_SUPPORT
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
559 static int8_t check_co2(SDiveState * pDiveState)
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
560 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
561 if(pDiveState->mode != MODE_DIVE)
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
562 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
563 pDiveState->warnings.co2High = 0;
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
564 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
565 else
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
566 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
567 if(pDiveState->lifeData.CO2_data.CO2_ppm > CO2_ALARM_LEVEL_PPM)
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
568 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
569 pDiveState->warnings.co2High = 1;
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
570 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
571 else
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
572 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
573 pDiveState->warnings.co2High = 0;
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
574 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
575 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
576 return pDiveState->warnings.co2High;
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
577 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
578 #endif
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
579
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
580 uint8_t debounce_warning_fallback(uint16_t debounceStepms)
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
581 {
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
582 uint8_t retVal = 0;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
583
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
584 debounceFallbackTimeMS += debounceStepms;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
585 if(debounceFallbackTimeMS > DEBOUNCE_FALLBACK_TIME_MS)
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
586 {
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
587 debounceFallbackTimeMS = DEBOUNCE_FALLBACK_TIME_MS;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
588 retVal = 1;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
589 }
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
590 return retVal;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
591 }
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
592 void reset_debounce_warning_fallback()
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
593 {
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
594 debounceFallbackTimeMS = 0;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
595 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597