annotate Discovery/Src/check_warning.c @ 414:6886aeeca454 Improment_NVM

Added compile switch for restoring of last known date after power lost: In case timing date was lost the RTC has to be set to a proper time anyhow. Maybe this function does not add as much value as expected... => Added compile switch (deactivated) to allow easy reactivation if this function is wanted.
author ideenmodellierer
date Tue, 14 Jan 2020 21:38:45 +0100
parents 74a8296a2318
children 58200d756365
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 #include "data_exchange.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 #include "check_warning.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 #include "settings.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 #include "decom.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 #include "tCCR.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
41 /* Private variables with access ----------------------------------------------*/
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
42 static uint8_t betterGasId = 0;
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
43 static uint8_t betterSetpointId = 0;
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
44 static int8_t fallback = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 /* Private function prototypes -----------------------------------------------*/
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
47 static int8_t check_fallback(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
48 static int8_t check_ppO2(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
49 static int8_t check_O2_sensors(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
50 static int8_t check_CNS(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
51 static int8_t check_Deco(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
52 static int8_t check_AscentRate(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
53 static int8_t check_aGF(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
54 static int8_t check_BetterGas(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
55 static int8_t check_BetterSetpoint(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
56 static int8_t check_Battery(SDiveState * pDiveState);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
58 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 void check_warning(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 {
272
74a8296a2318 cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents: 268
diff changeset
64 check_warning2(stateUsedWrite);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 void check_warning2(SDiveState * pDiveState)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 pDiveState->warnings.numWarnings = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 pDiveState->warnings.numWarnings += check_aGF(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 pDiveState->warnings.numWarnings += check_AscentRate(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 pDiveState->warnings.numWarnings += check_CNS(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 pDiveState->warnings.numWarnings += check_Deco(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 pDiveState->warnings.numWarnings += check_ppO2(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 pDiveState->warnings.numWarnings += check_O2_sensors(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 pDiveState->warnings.numWarnings += check_BetterGas(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 pDiveState->warnings.numWarnings += check_BetterSetpoint(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 pDiveState->warnings.numWarnings += check_Battery(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 pDiveState->warnings.numWarnings += check_fallback(pDiveState);
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 void set_warning_fallback(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 fallback = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 void clear_warning_fallback(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 fallback = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 uint8_t actualBetterGasId(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 return betterGasId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 uint8_t actualBetterSetpointId(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 return betterSetpointId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 uint8_t actualLeftMaxDepth(const SDiveState * pDiveState)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 if(pDiveState->lifeData.depth_meter > (pDiveState->lifeData.max_depth_meter - 3.0f))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 /* Private functions ---------------------------------------------------------*/
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
119 static int8_t check_fallback(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 if(fallback && ((pDiveState->mode != MODE_DIVE) || (pDiveState->diveSettings.diveMode != DIVEMODE_CCR)))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 fallback = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 pDiveState->warnings.fallback = fallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 return pDiveState->warnings.fallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
129 static int8_t check_ppO2(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 if(pDiveState->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 pDiveState->warnings.ppO2Low = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 pDiveState->warnings.ppO2High = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 return 0;
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 localPPO2, testPPO2high;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 if(pDiveState->lifeData.ppO2 < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 localPPO2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 if(pDiveState->lifeData.ppO2 >= 2.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 localPPO2 = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 localPPO2 = (uint8_t)(pDiveState->lifeData.ppO2 * 100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 if((localPPO2 + 1) <= settingsGetPointer()->ppO2_min)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 pDiveState->warnings.ppO2Low = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 pDiveState->warnings.ppO2Low = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 if(actualLeftMaxDepth(pDiveState))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 testPPO2high = settingsGetPointer()->ppO2_max_deco;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 testPPO2high = settingsGetPointer()->ppO2_max_std;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 if(localPPO2 >= (testPPO2high + 1))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 pDiveState->warnings.ppO2High = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 pDiveState->warnings.ppO2High = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 return pDiveState->warnings.ppO2Low + pDiveState->warnings.ppO2High;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
167 static int8_t check_O2_sensors(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 pDiveState->warnings.sensorLinkLost = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 pDiveState->warnings.sensorOutOfBounds[0] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 pDiveState->warnings.sensorOutOfBounds[1] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 pDiveState->warnings.sensorOutOfBounds[2] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 if((pDiveState->diveSettings.diveMode == DIVEMODE_CCR) && (pDiveState->diveSettings.CCR_Mode == CCRMODE_Sensors))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 if(!get_HUD_battery_voltage_V())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 pDiveState->warnings.sensorLinkLost = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 test_HUD_sensor_values_outOfBounds(&pDiveState->warnings.sensorOutOfBounds[0], &pDiveState->warnings.sensorOutOfBounds[1], &pDiveState->warnings.sensorOutOfBounds[2]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 return pDiveState->warnings.sensorLinkLost
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 + pDiveState->warnings.sensorOutOfBounds[0]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 + pDiveState->warnings.sensorOutOfBounds[1]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 + pDiveState->warnings.sensorOutOfBounds[2];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
189 static int8_t check_BetterGas(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 pDiveState->warnings.betterGas = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 betterGasId = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 uint8_t gasIdOffset;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 uint8_t bestGasDepth, betterGasIdLocal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 SLifeData* pLifeData = &pDiveState->lifeData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 SDiveSettings* pDiveSettings = &pDiveState->diveSettings;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 pDiveState->warnings.betterGas = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 betterGasId = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 betterGasIdLocal = pLifeData->actualGas.GasIdInSettings;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 bestGasDepth = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 if(pDiveSettings->diveMode == DIVEMODE_CCR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 gasIdOffset = NUM_OFFSET_DILUENT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 gasIdOffset = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 /* life data is float, gas data is uint8 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 if(actualLeftMaxDepth(pDiveState)) /* deco gases */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 for(int i=1+gasIdOffset; i<= 5+gasIdOffset; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 if( (pDiveSettings->gas[i].note.ub.active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 && (pDiveSettings->gas[i].note.ub.deco)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 && (pDiveSettings->gas[i].depth_meter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 && (pDiveSettings->gas[i].depth_meter >= (pLifeData->depth_meter - 0.01f ))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 && (pDiveSettings->gas[i].depth_meter <= bestGasDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 betterGasIdLocal = i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 bestGasDepth = pDiveSettings->gas[i].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 if(betterGasIdLocal != pLifeData->actualGas.GasIdInSettings)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 if(!check_helper_same_oxygen_and_helium_content(&pDiveSettings->gas[betterGasIdLocal], &pDiveSettings->gas[pLifeData->actualGas.GasIdInSettings]))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 betterGasId = betterGasIdLocal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 pDiveState->warnings.betterGas = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 else /* travel gases */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 bestGasDepth = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 //check for travalgas
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 for(int i=1+gasIdOffset; i<= 5+gasIdOffset; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 if( (pDiveSettings->gas[i].note.ub.active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 && (pDiveSettings->gas[i].note.ub.travel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 && (pDiveSettings->gas[i].depth_meter_travel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 && (pDiveSettings->gas[i].depth_meter_travel <= (pLifeData->depth_meter + 0.01f ))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 && (pDiveSettings->gas[i].depth_meter_travel >= bestGasDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 betterGasIdLocal = i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 bestGasDepth = pDiveSettings->gas[i].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 if(betterGasIdLocal != pLifeData->actualGas.GasIdInSettings)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 if(!check_helper_same_oxygen_and_helium_content(&pDiveSettings->gas[betterGasIdLocal], &pDiveSettings->gas[pLifeData->actualGas.GasIdInSettings]))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 betterGasId = betterGasIdLocal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 pDiveState->warnings.betterGas = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 return pDiveState->warnings.betterGas;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 /* check for better travel!!! setpoint hw 151210
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 */
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
272 static int8_t check_BetterSetpoint(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 pDiveState->warnings.betterSetpoint = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 betterSetpointId = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 if((stateUsed->mode != MODE_DIVE) || (pDiveState->diveSettings.diveMode != DIVEMODE_CCR) || (pDiveState->diveSettings.CCR_Mode != CCRMODE_FixedSetpoint))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 uint8_t bestSetpointDepth = 0; // travel the deeper, the better
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 uint8_t betterSetpointIdLocal = 0; // nothing better
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 if(!actualLeftMaxDepth(pDiveState)) /* travel gases */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 for(int i=1; i<=NUM_GASES; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 if( (pDiveState->diveSettings.setpoint[i].note.ub.active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 && (pDiveState->diveSettings.setpoint[i].depth_meter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 && (pDiveState->diveSettings.setpoint[i].depth_meter <= ( pDiveState->lifeData.depth_meter + 0.01f ))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 && (pDiveState->diveSettings.setpoint[i].depth_meter >= bestSetpointDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 betterSetpointIdLocal = i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 bestSetpointDepth = pDiveState->diveSettings.setpoint[i].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 if((betterSetpointIdLocal) && (pDiveState->diveSettings.setpoint[betterSetpointIdLocal].setpoint_cbar != pDiveState->lifeData.actualGas.setPoint_cbar))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 betterSetpointId = betterSetpointIdLocal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 pDiveState->warnings.betterSetpoint = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 return pDiveState->warnings.betterSetpoint;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 /* hw 151030
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 */
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
311 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 if(gas1->helium_percentage != gas2->helium_percentage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 if(gas1->oxygen_percentage != gas2->oxygen_percentage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
323 static int8_t check_CNS(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 pDiveState->warnings.cnsHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 if(pDiveState->lifeData.cns >= (float)(settingsGetPointer()->CNS_max))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 pDiveState->warnings.cnsHigh = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 pDiveState->warnings.cnsHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 return pDiveState->warnings.cnsHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
339 static int8_t check_Battery(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 if(pDiveState->lifeData.battery_charge < 10)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 pDiveState->warnings.lowBattery = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 pDiveState->warnings.lowBattery = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 return pDiveState->warnings.lowBattery;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
350 static int8_t check_Deco(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 uint8_t depthNext = decom_get_actual_deco_stop(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 if(!depthNext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 if(pDiveState->lifeData.depth_meter + 0.1f < (float)depthNext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 pDiveState->warnings.decoMissed = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 return pDiveState->warnings.decoMissed;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
372 static int8_t check_AscentRate(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 pDiveState->warnings.ascentRateHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 float warnAscentRateFloat;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 warnAscentRateFloat = (float)(settingsGetPointer()->ascent_MeterPerMinute_max);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 if(pDiveState->lifeData.ascent_rate_meter_per_min >= warnAscentRateFloat)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 pDiveState->warnings.ascentRateHigh = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 pDiveState->warnings.ascentRateHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 return pDiveState->warnings.ascentRateHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
392 static int8_t check_aGF(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 pDiveState->warnings.aGf = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 pDiveState->warnings.aGf = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 if((pDiveState->diveSettings.gf_high != settingsGetPointer()->GF_high) || (pDiveState->diveSettings.gf_low != settingsGetPointer()->GF_low))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 pDiveState->warnings.aGf = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 return pDiveState->warnings.aGf;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410