annotate Discovery/Src/check_warning.c @ 756:6de83d8205a0

Added visualization of CO2 during dive: In the previous version CO2 values were available in sufrace mode only. Now the display of Co2 value has been added to the lower left corner view. In addition a Co2 alarm has been added. Early Co2 warning vaues will be displayed in yellow while critical values are shown in red.
author Ideenmodellierer
date Tue, 07 Mar 2023 20:02:05 +0100
parents b456be1e152d
children 29d9b5bc7946
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
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
41
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
42 #define DEBOUNCE_FALLBACK_TIME_MS (5000u) /* set warning after 5 seconds of pending error condition */
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
43
756
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
44
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
45 /* Private variables with access ----------------------------------------------*/
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
46 static uint8_t betterGasId = 0;
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
47 static uint8_t betterSetpointId = 0;
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
48 static int8_t fallback = 0;
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
49 static uint16_t debounceFallbackTimeMS = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 /* Private function prototypes -----------------------------------------------*/
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
52 static int8_t check_fallback(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
53 static int8_t check_ppO2(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
54 static int8_t check_O2_sensors(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
55 static int8_t check_CNS(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
56 static int8_t check_Deco(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
57 static int8_t check_AscentRate(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
58 static int8_t check_aGF(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
59 static int8_t check_BetterGas(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
60 static int8_t check_BetterSetpoint(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
61 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
62 #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
63 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
64 #endif
756
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
65 #ifdef ENABLE_CO2_SUPPORT
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
66 static int8_t check_co2(SDiveState * pDiveState);
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
67 #endif
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
68 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 void check_warning(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 {
272
74a8296a2318 cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents: 268
diff changeset
74 check_warning2(stateUsedWrite);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 void check_warning2(SDiveState * pDiveState)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 pDiveState->warnings.numWarnings = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 pDiveState->warnings.numWarnings += check_aGF(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 pDiveState->warnings.numWarnings += check_AscentRate(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 pDiveState->warnings.numWarnings += check_CNS(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 pDiveState->warnings.numWarnings += check_Deco(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 pDiveState->warnings.numWarnings += check_ppO2(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 pDiveState->warnings.numWarnings += check_O2_sensors(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 pDiveState->warnings.numWarnings += check_BetterGas(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 pDiveState->warnings.numWarnings += check_BetterSetpoint(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 pDiveState->warnings.numWarnings += check_Battery(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 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
92 #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
93 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
94 #endif
756
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
95 #ifdef ENABLE_CO2_SUPPORT
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
96 pDiveState->warnings.numWarnings += check_co2(pDiveState);
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
97 #endif
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 }
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 void set_warning_fallback(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 fallback = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 void clear_warning_fallback(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 fallback = 0;
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
110 debounceFallbackTimeMS = 0;
38
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 actualBetterGasId(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 return betterGasId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 uint8_t actualBetterSetpointId(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 return betterSetpointId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 uint8_t actualLeftMaxDepth(const SDiveState * pDiveState)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 if(pDiveState->lifeData.depth_meter > (pDiveState->lifeData.max_depth_meter - 3.0f))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 /* Private functions ---------------------------------------------------------*/
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
136 static int8_t check_fallback(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 {
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
138 if(fallback && ((pDiveState->mode != MODE_DIVE) || (!isLoopMode(pDiveState->diveSettings.diveMode))))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 fallback = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 pDiveState->warnings.fallback = fallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 return pDiveState->warnings.fallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
146 static int8_t check_ppO2(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 {
582
64bf41faab83 Show Fallback if no valid sensor value is available:
Ideenmodellierer
parents: 563
diff changeset
148 if((pDiveState->mode != MODE_DIVE) || (pDiveState->warnings.fallback))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 pDiveState->warnings.ppO2Low = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 pDiveState->warnings.ppO2High = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 uint8_t localPPO2, testPPO2high;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 if(pDiveState->lifeData.ppO2 < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 localPPO2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 if(pDiveState->lifeData.ppO2 >= 2.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 localPPO2 = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 localPPO2 = (uint8_t)(pDiveState->lifeData.ppO2 * 100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 if((localPPO2 + 1) <= settingsGetPointer()->ppO2_min)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 pDiveState->warnings.ppO2Low = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 pDiveState->warnings.ppO2Low = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 if(actualLeftMaxDepth(pDiveState))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 testPPO2high = settingsGetPointer()->ppO2_max_deco;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 testPPO2high = settingsGetPointer()->ppO2_max_std;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 if(localPPO2 >= (testPPO2high + 1))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 pDiveState->warnings.ppO2High = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 pDiveState->warnings.ppO2High = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 return pDiveState->warnings.ppO2Low + pDiveState->warnings.ppO2High;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
184 static int8_t check_O2_sensors(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 pDiveState->warnings.sensorLinkLost = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 pDiveState->warnings.sensorOutOfBounds[0] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 pDiveState->warnings.sensorOutOfBounds[1] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 pDiveState->warnings.sensorOutOfBounds[2] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
191 if(isLoopMode(pDiveState->diveSettings.diveMode) && (pDiveState->diveSettings.CCR_Mode == CCRMODE_Sensors))
563
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
192
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
193 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
194 {
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
195 {
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
196 if(!get_HUD_battery_voltage_V())
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
197 pDiveState->warnings.sensorLinkLost = 1;
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
198 }
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
199 }
634
7c73f066cd16 Enable sensor check for Analog PPO2 mode:
Ideenmodellierer
parents: 582
diff changeset
200 test_O2_sensor_values_outOfBounds(&pDiveState->warnings.sensorOutOfBounds[0], &pDiveState->warnings.sensorOutOfBounds[1], &pDiveState->warnings.sensorOutOfBounds[2]);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 return pDiveState->warnings.sensorLinkLost
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 + pDiveState->warnings.sensorOutOfBounds[0]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 + pDiveState->warnings.sensorOutOfBounds[1]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 + pDiveState->warnings.sensorOutOfBounds[2];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
208 static int8_t check_BetterGas(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 pDiveState->warnings.betterGas = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 betterGasId = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 uint8_t gasIdOffset;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 uint8_t bestGasDepth, betterGasIdLocal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 SLifeData* pLifeData = &pDiveState->lifeData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 SDiveSettings* pDiveSettings = &pDiveState->diveSettings;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 pDiveState->warnings.betterGas = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 betterGasId = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 betterGasIdLocal = pLifeData->actualGas.GasIdInSettings;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 bestGasDepth = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
228 if(isLoopMode(pDiveSettings->diveMode))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 gasIdOffset = NUM_OFFSET_DILUENT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 gasIdOffset = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 /* life data is float, gas data is uint8 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 if(actualLeftMaxDepth(pDiveState)) /* deco gases */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 for(int i=1+gasIdOffset; i<= 5+gasIdOffset; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 if( (pDiveSettings->gas[i].note.ub.active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 && (pDiveSettings->gas[i].note.ub.deco)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 && (pDiveSettings->gas[i].depth_meter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 && (pDiveSettings->gas[i].depth_meter >= (pLifeData->depth_meter - 0.01f ))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 && (pDiveSettings->gas[i].depth_meter <= bestGasDepth)
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 betterGasIdLocal = i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 bestGasDepth = pDiveSettings->gas[i].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 if(betterGasIdLocal != pLifeData->actualGas.GasIdInSettings)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 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
253 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 betterGasId = betterGasIdLocal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 pDiveState->warnings.betterGas = 1;
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 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 else /* travel gases */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 bestGasDepth = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 //check for travalgas
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 for(int i=1+gasIdOffset; i<= 5+gasIdOffset; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 if( (pDiveSettings->gas[i].note.ub.active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 && (pDiveSettings->gas[i].note.ub.travel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 && (pDiveSettings->gas[i].depth_meter_travel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 && (pDiveSettings->gas[i].depth_meter_travel <= (pLifeData->depth_meter + 0.01f ))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 && (pDiveSettings->gas[i].depth_meter_travel >= bestGasDepth)
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 betterGasIdLocal = i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 bestGasDepth = pDiveSettings->gas[i].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 if(betterGasIdLocal != pLifeData->actualGas.GasIdInSettings)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 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
280 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 betterGasId = betterGasIdLocal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 pDiveState->warnings.betterGas = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 return pDiveState->warnings.betterGas;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 /* check for better travel!!! setpoint hw 151210
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 */
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
291 static int8_t check_BetterSetpoint(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 pDiveState->warnings.betterSetpoint = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 betterSetpointId = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 uint8_t bestSetpointDepth = 0; // travel the deeper, the better
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 uint8_t betterSetpointIdLocal = 0; // nothing better
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
298
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
299 if((stateUsed->mode == MODE_DIVE) && (pDiveState->diveSettings.diveMode == DIVEMODE_CCR))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 {
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
301 if(!actualLeftMaxDepth(pDiveState)) /* travel gases */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 {
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
303 for(int i=1; i<=NUM_GASES; i++)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
304 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
305 if( (pDiveState->diveSettings.setpoint[i].note.ub.active)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
306 && (pDiveState->diveSettings.setpoint[i].depth_meter)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
307 && (pDiveState->diveSettings.setpoint[i].depth_meter <= ( pDiveState->lifeData.depth_meter + 0.01f ))
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
308 && (pDiveState->diveSettings.setpoint[i].depth_meter >= bestSetpointDepth)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
309 )
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
310 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
311 betterSetpointIdLocal = i;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
312 bestSetpointDepth = pDiveState->diveSettings.setpoint[i].depth_meter;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
313 }
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
314 }
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
315 if((betterSetpointIdLocal) && (pDiveState->diveSettings.setpoint[betterSetpointIdLocal].setpoint_cbar != pDiveState->lifeData.actualGas.setPoint_cbar))
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
316 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
317 betterSetpointId = betterSetpointIdLocal;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
318 pDiveState->warnings.betterSetpoint = 1;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
319 }
38
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 return pDiveState->warnings.betterSetpoint;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 /* hw 151030
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_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 if(gas1->helium_percentage != gas2->helium_percentage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 if(gas1->oxygen_percentage != gas2->oxygen_percentage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
340 static int8_t check_CNS(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 pDiveState->warnings.cnsHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 if(pDiveState->lifeData.cns >= (float)(settingsGetPointer()->CNS_max))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 pDiveState->warnings.cnsHigh = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 pDiveState->warnings.cnsHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 return pDiveState->warnings.cnsHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
356 static int8_t check_Battery(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 {
671
b456be1e152d Support of unknown charging counter values:
Ideenmodellierer
parents: 662
diff changeset
358 if((pDiveState->lifeData.battery_charge > 0) && (pDiveState->lifeData.battery_charge < 10))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 pDiveState->warnings.lowBattery = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 pDiveState->warnings.lowBattery = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 return pDiveState->warnings.lowBattery;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
367 static int8_t check_Deco(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 uint8_t depthNext = decom_get_actual_deco_stop(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 if(!depthNext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 if(pDiveState->lifeData.depth_meter + 0.1f < (float)depthNext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 pDiveState->warnings.decoMissed = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 return pDiveState->warnings.decoMissed;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
389 static int8_t check_AscentRate(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 pDiveState->warnings.ascentRateHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 float warnAscentRateFloat;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 warnAscentRateFloat = (float)(settingsGetPointer()->ascent_MeterPerMinute_max);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 if(pDiveState->lifeData.ascent_rate_meter_per_min >= warnAscentRateFloat)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 pDiveState->warnings.ascentRateHigh = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 pDiveState->warnings.ascentRateHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 return pDiveState->warnings.ascentRateHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
409 static int8_t check_aGF(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 pDiveState->warnings.aGf = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 pDiveState->warnings.aGf = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 if((pDiveState->diveSettings.gf_high != settingsGetPointer()->GF_high) || (pDiveState->diveSettings.gf_low != settingsGetPointer()->GF_low))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 pDiveState->warnings.aGf = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 return pDiveState->warnings.aGf;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425
478
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
426 #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
427 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
428 {
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
429 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
430 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
431 {
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
432 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
433 ret = 1;
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
434 }
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
435 else
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
436 {
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
437 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
438 }
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
439 return ret;
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
440 }
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
441 #endif
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
442
756
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
443 #ifdef ENABLE_CO2_SUPPORT
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
444 static int8_t check_co2(SDiveState * pDiveState)
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
445 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
446 if(pDiveState->mode != MODE_DIVE)
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
447 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
448 pDiveState->warnings.co2High = 0;
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
449 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
450 else
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
451 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
452 if(pDiveState->lifeData.CO2_data.CO2_ppm > CO2_ALARM_LEVEL_PPM)
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
453 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
454 pDiveState->warnings.co2High = 1;
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
455 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
456 else
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
457 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
458 pDiveState->warnings.co2High = 0;
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
459 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
460 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
461 return pDiveState->warnings.co2High;
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
462 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
463 #endif
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
464
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
465 uint8_t debounce_warning_fallback(uint16_t debounceStepms)
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
466 {
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
467 uint8_t retVal = 0;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
468
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
469 debounceFallbackTimeMS += debounceStepms;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
470 if(debounceFallbackTimeMS > DEBOUNCE_FALLBACK_TIME_MS)
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
471 {
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
472 debounceFallbackTimeMS = DEBOUNCE_FALLBACK_TIME_MS;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
473 retVal = 1;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
474 }
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
475 return retVal;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
476 }
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
477 void reset_debounce_warning_fallback()
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
478 {
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
479 debounceFallbackTimeMS = 0;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
480 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482