annotate Discovery/Src/check_warning.c @ 496:9623f166b0c0

Bugfix display of disabled screen. It is possible to select a screen as default which is in parallel disabled in the selection view. To avoid this the enable / disable state is not also checked when entering dive mode. The check function was depending on an ACTION. The functionality has been changed to allow the function call without ACTION. Changed setting of compass circle position from constant position to variable This was needed to reuse the same function in several views with different compass position Added new views Navigation and Depth data Both views were basically already available but the idea behind the layout is to combine all information needed for navigation dives (compass + timer) in one view. The classic maxdepth view just showed the maxdepth with a black box on the right side. this box is now used for display of average depth (shown in classic view Stopwatch) Minor changes in compass paint function to improve code readability Use same Y offset for all views While switching across the views some number were shown ~20 pixel higher than others. This was caused by the usage of the line selection which works for some fonts but not for all => set linenumber to 0 for all views
author Ideenmodellierer
date Mon, 24 Aug 2020 19:53:27 +0200
parents 58200d756365
children d97f0e395058
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);
478
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
57 #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
58 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
59 #endif
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
60 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 void check_warning(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 {
272
74a8296a2318 cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents: 268
diff changeset
66 check_warning2(stateUsedWrite);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 void check_warning2(SDiveState * pDiveState)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 pDiveState->warnings.numWarnings = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 pDiveState->warnings.numWarnings += check_aGF(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 pDiveState->warnings.numWarnings += check_AscentRate(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 pDiveState->warnings.numWarnings += check_CNS(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 pDiveState->warnings.numWarnings += check_Deco(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 pDiveState->warnings.numWarnings += check_ppO2(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 pDiveState->warnings.numWarnings += check_O2_sensors(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 pDiveState->warnings.numWarnings += check_BetterGas(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 pDiveState->warnings.numWarnings += check_BetterSetpoint(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 pDiveState->warnings.numWarnings += check_Battery(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 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
84 #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
85 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
86 #endif
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 }
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 void set_warning_fallback(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 fallback = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 }
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 void clear_warning_fallback(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 fallback = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 }
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 uint8_t actualBetterGasId(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 return betterGasId;
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 uint8_t actualBetterSetpointId(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 return betterSetpointId;
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 uint8_t actualLeftMaxDepth(const SDiveState * pDiveState)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 if(pDiveState->lifeData.depth_meter > (pDiveState->lifeData.max_depth_meter - 3.0f))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 /* Private functions ---------------------------------------------------------*/
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
124 static int8_t check_fallback(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 if(fallback && ((pDiveState->mode != MODE_DIVE) || (pDiveState->diveSettings.diveMode != DIVEMODE_CCR)))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 fallback = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 pDiveState->warnings.fallback = fallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 return pDiveState->warnings.fallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
134 static int8_t check_ppO2(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 if(pDiveState->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 pDiveState->warnings.ppO2Low = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 pDiveState->warnings.ppO2High = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 uint8_t localPPO2, testPPO2high;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 if(pDiveState->lifeData.ppO2 < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 localPPO2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 if(pDiveState->lifeData.ppO2 >= 2.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 localPPO2 = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 localPPO2 = (uint8_t)(pDiveState->lifeData.ppO2 * 100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 if((localPPO2 + 1) <= settingsGetPointer()->ppO2_min)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 pDiveState->warnings.ppO2Low = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 pDiveState->warnings.ppO2Low = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 if(actualLeftMaxDepth(pDiveState))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 testPPO2high = settingsGetPointer()->ppO2_max_deco;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 testPPO2high = settingsGetPointer()->ppO2_max_std;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 if(localPPO2 >= (testPPO2high + 1))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 pDiveState->warnings.ppO2High = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 pDiveState->warnings.ppO2High = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 return pDiveState->warnings.ppO2Low + pDiveState->warnings.ppO2High;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
172 static int8_t check_O2_sensors(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 pDiveState->warnings.sensorLinkLost = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 pDiveState->warnings.sensorOutOfBounds[0] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 pDiveState->warnings.sensorOutOfBounds[1] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 pDiveState->warnings.sensorOutOfBounds[2] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 if((pDiveState->diveSettings.diveMode == DIVEMODE_CCR) && (pDiveState->diveSettings.CCR_Mode == CCRMODE_Sensors))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 if(!get_HUD_battery_voltage_V())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 pDiveState->warnings.sensorLinkLost = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 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
185
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 return pDiveState->warnings.sensorLinkLost
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 + pDiveState->warnings.sensorOutOfBounds[0]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 + pDiveState->warnings.sensorOutOfBounds[1]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 + pDiveState->warnings.sensorOutOfBounds[2];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
194 static int8_t check_BetterGas(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 pDiveState->warnings.betterGas = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 betterGasId = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 uint8_t gasIdOffset;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 uint8_t bestGasDepth, betterGasIdLocal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 SLifeData* pLifeData = &pDiveState->lifeData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 SDiveSettings* pDiveSettings = &pDiveState->diveSettings;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 pDiveState->warnings.betterGas = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 betterGasId = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 betterGasIdLocal = pLifeData->actualGas.GasIdInSettings;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 bestGasDepth = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 if(pDiveSettings->diveMode == DIVEMODE_CCR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 gasIdOffset = NUM_OFFSET_DILUENT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 gasIdOffset = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 /* life data is float, gas data is uint8 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 if(actualLeftMaxDepth(pDiveState)) /* deco gases */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 for(int i=1+gasIdOffset; i<= 5+gasIdOffset; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 if( (pDiveSettings->gas[i].note.ub.active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 && (pDiveSettings->gas[i].note.ub.deco)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 && (pDiveSettings->gas[i].depth_meter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 && (pDiveSettings->gas[i].depth_meter >= (pLifeData->depth_meter - 0.01f ))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 && (pDiveSettings->gas[i].depth_meter <= bestGasDepth)
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 betterGasIdLocal = i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 bestGasDepth = pDiveSettings->gas[i].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 if(betterGasIdLocal != pLifeData->actualGas.GasIdInSettings)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 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
239 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 betterGasId = betterGasIdLocal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 pDiveState->warnings.betterGas = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 else /* travel gases */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 bestGasDepth = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 //check for travalgas
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 for(int i=1+gasIdOffset; i<= 5+gasIdOffset; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 if( (pDiveSettings->gas[i].note.ub.active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 && (pDiveSettings->gas[i].note.ub.travel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 && (pDiveSettings->gas[i].depth_meter_travel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 && (pDiveSettings->gas[i].depth_meter_travel <= (pLifeData->depth_meter + 0.01f ))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 && (pDiveSettings->gas[i].depth_meter_travel >= bestGasDepth)
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 betterGasIdLocal = i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 bestGasDepth = pDiveSettings->gas[i].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 if(betterGasIdLocal != pLifeData->actualGas.GasIdInSettings)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 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
266 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 betterGasId = betterGasIdLocal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 pDiveState->warnings.betterGas = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 return pDiveState->warnings.betterGas;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 /* check for better travel!!! setpoint hw 151210
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 */
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
277 static int8_t check_BetterSetpoint(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 pDiveState->warnings.betterSetpoint = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 betterSetpointId = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 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
283 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 uint8_t bestSetpointDepth = 0; // travel the deeper, the better
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 uint8_t betterSetpointIdLocal = 0; // nothing better
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 if(!actualLeftMaxDepth(pDiveState)) /* travel gases */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 for(int i=1; i<=NUM_GASES; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 if( (pDiveState->diveSettings.setpoint[i].note.ub.active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 && (pDiveState->diveSettings.setpoint[i].depth_meter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 && (pDiveState->diveSettings.setpoint[i].depth_meter <= ( pDiveState->lifeData.depth_meter + 0.01f ))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 && (pDiveState->diveSettings.setpoint[i].depth_meter >= bestSetpointDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 betterSetpointIdLocal = i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 bestSetpointDepth = pDiveState->diveSettings.setpoint[i].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 if((betterSetpointIdLocal) && (pDiveState->diveSettings.setpoint[betterSetpointIdLocal].setpoint_cbar != pDiveState->lifeData.actualGas.setPoint_cbar))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 betterSetpointId = betterSetpointIdLocal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 pDiveState->warnings.betterSetpoint = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 return pDiveState->warnings.betterSetpoint;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 /* hw 151030
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 */
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
316 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 if(gas1->helium_percentage != gas2->helium_percentage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 if(gas1->oxygen_percentage != gas2->oxygen_percentage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
328 static int8_t check_CNS(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 pDiveState->warnings.cnsHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 if(pDiveState->lifeData.cns >= (float)(settingsGetPointer()->CNS_max))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 pDiveState->warnings.cnsHigh = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 pDiveState->warnings.cnsHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 return pDiveState->warnings.cnsHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
344 static int8_t check_Battery(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 if(pDiveState->lifeData.battery_charge < 10)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 pDiveState->warnings.lowBattery = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 pDiveState->warnings.lowBattery = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 return pDiveState->warnings.lowBattery;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
355 static int8_t check_Deco(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 uint8_t depthNext = decom_get_actual_deco_stop(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 if(!depthNext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 if(pDiveState->lifeData.depth_meter + 0.1f < (float)depthNext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 pDiveState->warnings.decoMissed = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 return pDiveState->warnings.decoMissed;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
377 static int8_t check_AscentRate(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 pDiveState->warnings.ascentRateHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 float warnAscentRateFloat;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 warnAscentRateFloat = (float)(settingsGetPointer()->ascent_MeterPerMinute_max);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 if(pDiveState->lifeData.ascent_rate_meter_per_min >= warnAscentRateFloat)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 pDiveState->warnings.ascentRateHigh = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 pDiveState->warnings.ascentRateHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 return pDiveState->warnings.ascentRateHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
397 static int8_t check_aGF(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 pDiveState->warnings.aGf = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 pDiveState->warnings.aGf = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 if((pDiveState->diveSettings.gf_high != settingsGetPointer()->GF_high) || (pDiveState->diveSettings.gf_low != settingsGetPointer()->GF_low))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 pDiveState->warnings.aGf = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 return pDiveState->warnings.aGf;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413
478
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
414 #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
415 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
416 {
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
417 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
418 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
419 {
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
420 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
421 ret = 1;
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
422 }
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
423 else
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
424 {
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
425 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
426 }
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
427 return ret;
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
428 }
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
429 #endif
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431