annotate Discovery/Src/check_warning.c @ 952:33e24b77cc6c Evo_2_23

Bugfix ppo2 high/low check in OC mode: The fallback option which is used in CC mode was applied to the OC mode as well. As result the check could be deactivated depending on the fallback state, even if a OC dive is performed. now the check will always be performed if the dive mode is OC. Added vibration warning: The internal buzzer of the GPIO_V2 may now be used as additional warning notificator. It can be activated using the check button in the customer view menu. The vibration will be active while the warning message is displayed in the dive window. In case the diver is in the menu then the warning will be active for a shorter duration.
author Ideenmodellierer
date Sun, 29 Dec 2024 18:33:02 +0100
parents 5f38cf765193
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file check_warning.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @date 17-Nov-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @since 17-Nov-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * @brief check and set warnings for warnings
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ##### How to use #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 OSTC3 Warnings:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 niedriger Batteriezustand (
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 zu hoher oder zu niedriger Sauerstoffpartialdruck (ppO2) 0.2 - 1.6
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 zu hoher CNS (Gefahr der Sauerstoffvergiftung) 90%
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 zu hohe Gradientenfaktoren 90 - 90
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 Missachtung der Dekostopps (der �berschrittene Dekostopp wird rot angezeigt) 0 m
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 zu hohe Aufstiegsgeschwindigkeit 30 m/min
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 aGF-Warnung: die Berechnung der Dekompression wird �ber alternative GF-Werte durchgef�hrt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 Fallback-Warnung bei ausgefallenem Sensor
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 * <h2><center>&copy; COPYRIGHT(c) 2014 heinrichs weikamp</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34
771
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
35 #include <stdbool.h>
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
36
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 #include "data_exchange.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 #include "check_warning.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 #include "settings.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 #include "decom.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 #include "tCCR.h"
788
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
42 #include "tHome.h"
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
44
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
45 #define DEBOUNCE_FALLBACK_TIME_MS (5000u) /* set warning after 5 seconds of pending error condition */
952
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
46 #define GUI_BUZZER_TIMEOUT_MS (200u) /* the buzzer should be active while Warning string is shown, but diver may be in a menu... */
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
47
788
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
48 #define SETPOINT_DECO_START_RANGE_M 3.0
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
49 #define SWITCH_DEPTH_LOW_MINIMUM_M 1.0
756
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
50
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
51 /* Private variables with access ----------------------------------------------*/
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
52 static uint8_t betterGasId = 0;
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
53 static uint8_t betterBailoutGasId = 0;
771
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
54 static uint8_t betterSetpointId = 1;
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
55 static int8_t fallback = 0;
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
56 static uint16_t debounceFallbackTimeMS = 0;
952
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
57 static uint8_t buzzerRequestActive = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 /* Private function prototypes -----------------------------------------------*/
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
60 static int8_t check_fallback(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
61 static int8_t check_ppO2(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
62 static int8_t check_O2_sensors(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
63 static int8_t check_CNS(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
64 static int8_t check_Deco(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
65 static int8_t check_AscentRate(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
66 static int8_t check_aGF(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
67 static int8_t check_BetterGas(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
68 static int8_t check_BetterSetpoint(SDiveState * pDiveState);
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
69 static int8_t check_Battery(SDiveState * pDiveState);
478
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
70 #ifdef ENABLE_BOTTLE_SENSOR
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
71 static int8_t check_pressureSensor(SDiveState * pDiveState);
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
72 #endif
756
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
73 #ifdef ENABLE_CO2_SUPPORT
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
74 static int8_t check_co2(SDiveState * pDiveState);
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
75 #endif
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
76 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2);
857
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
77 #ifdef HAVE_DEBUG_WARNINGS
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
78 static int8_t check_debug(SDiveState * pDiveState);
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
79 #endif
952
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
80 static uint8_t buzzerOn = 0; /* current state of the buzzer */
857
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
81
952
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
82 static void setBuzzer(int8_t warningActive);
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
83 /* Exported functions --------------------------------------------------------*/
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
84
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
85 void requestBuzzerActivation(uint8_t active)
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
86 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
87 buzzerRequestActive = active;
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
88 }
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
89
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
90 uint8_t getBuzzerActivationState()
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
91 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
92 return buzzerOn;
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
93 }
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
94
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
95 static void setBuzzer(int8_t warningActive)
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
96 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
97 static uint32_t guiTimeoutCnt = 0; /* max delay till buzzer will be activated independend from gui request */
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
98 static uint32_t stateTick = 0; /* activation tick of current state */
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
99 static uint8_t lastWarningState = 0; /* the parameter value of the last call*/
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
100
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
101 uint32_t tick = HAL_GetTick();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102
952
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
103 if(warningActive)
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
104 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
105 if(!lastWarningState) /* init structures */
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
106 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
107 guiTimeoutCnt = tick;
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
108 stateTick = tick;
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
109 }
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
110 if(buzzerOn)
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
111 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
112 if(time_elapsed_ms(stateTick, tick) > EXT_INTERFACE_BUZZER_STABLE_TIME_MS) /* buzzer has to be on for a certain time */
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
113 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
114 if((!buzzerRequestActive) || (time_elapsed_ms(stateTick, tick) > EXT_INTERFACE_BUZZER_ON_TIME_MS))
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
115 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
116 buzzerOn = 0;
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
117 stateTick = tick;
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
118 guiTimeoutCnt = tick;
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
119 }
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
120 }
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
121 }
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
122 else
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
123 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
124 if(time_elapsed_ms(stateTick, tick) > EXT_INTERFACE_BUZZER_STABLE_TIME_MS) /* buzzer has to be off for a certain time */
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
125 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
126 if((buzzerRequestActive) || (time_elapsed_ms(guiTimeoutCnt, tick) > EXT_INTERFACE_BUZZER_ON_TIME_MS + GUI_BUZZER_TIMEOUT_MS))
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
127 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
128 buzzerOn = 1;
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
129 stateTick = tick;
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
130 }
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
131 }
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
132 }
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
133 }
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
134 else
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
135 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
136 buzzerOn = 0;
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
137 }
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
138 lastWarningState = warningActive;
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
139 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 void check_warning(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 {
272
74a8296a2318 cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents: 268
diff changeset
143 check_warning2(stateUsedWrite);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 void check_warning2(SDiveState * pDiveState)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 pDiveState->warnings.numWarnings = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150
952
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
151 /* Warnings checked before the SetBuzzer call will activate the buzzer */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 pDiveState->warnings.numWarnings += check_AscentRate(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 pDiveState->warnings.numWarnings += check_Deco(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 pDiveState->warnings.numWarnings += check_ppO2(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 pDiveState->warnings.numWarnings += check_O2_sensors(pDiveState);
952
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
156 pDiveState->warnings.numWarnings += check_fallback(pDiveState);
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
157 #ifdef ENABLE_CO2_SUPPORT
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
158 pDiveState->warnings.numWarnings += check_co2(pDiveState);
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
159 #endif
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
160
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
161 if(settingsGetPointer()->warningBuzzer)
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
162 {
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
163 setBuzzer(pDiveState->warnings.numWarnings);
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
164 }
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
165
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
166 /* Warnings checked after this line will not cause activation of the buzzer */
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
167 pDiveState->warnings.numWarnings += check_aGF(pDiveState);
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
168 pDiveState->warnings.numWarnings += check_CNS(pDiveState);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 pDiveState->warnings.numWarnings += check_BetterGas(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 pDiveState->warnings.numWarnings += check_BetterSetpoint(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 pDiveState->warnings.numWarnings += check_Battery(pDiveState);
478
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
172 #ifdef ENABLE_BOTTLE_SENSOR
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
173 pDiveState->warnings.numWarnings += check_pressureSensor(pDiveState);
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
174 #endif
952
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
175
857
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
176 #ifdef HAVE_DEBUG_WARNINGS
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
177 pDiveState->warnings.numWarnings += check_debug(pDiveState);
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
178 #endif
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 void set_warning_fallback(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 fallback = 1;
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 void clear_warning_fallback(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 fallback = 0;
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
191 debounceFallbackTimeMS = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 uint8_t actualBetterGasId(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 return betterGasId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
201 uint8_t actualBetterBailoutGasId(void)
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
202 {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
203 return betterBailoutGasId;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
204 }
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
205
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
206
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 uint8_t actualBetterSetpointId(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 return betterSetpointId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 uint8_t actualLeftMaxDepth(const SDiveState * pDiveState)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 if(pDiveState->lifeData.depth_meter > (pDiveState->lifeData.max_depth_meter - 3.0f))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 /* Private functions ---------------------------------------------------------*/
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
223 static int8_t check_fallback(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 {
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
225 if(fallback && ((pDiveState->mode != MODE_DIVE) || (!isLoopMode(pDiveState->diveSettings.diveMode))))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 fallback = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 pDiveState->warnings.fallback = fallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 return pDiveState->warnings.fallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
233 static int8_t check_ppO2(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 {
952
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
235 if((pDiveState->mode != MODE_DIVE) || ((isLoopMode(pDiveState->diveSettings.diveMode) && (pDiveState->warnings.fallback))))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 pDiveState->warnings.ppO2Low = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 pDiveState->warnings.ppO2High = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 uint8_t localPPO2, testPPO2high;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 if(pDiveState->lifeData.ppO2 < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 localPPO2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 if(pDiveState->lifeData.ppO2 >= 2.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 localPPO2 = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 localPPO2 = (uint8_t)(pDiveState->lifeData.ppO2 * 100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 if((localPPO2 + 1) <= settingsGetPointer()->ppO2_min)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 pDiveState->warnings.ppO2Low = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 pDiveState->warnings.ppO2Low = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 if(actualLeftMaxDepth(pDiveState))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 testPPO2high = settingsGetPointer()->ppO2_max_deco;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 testPPO2high = settingsGetPointer()->ppO2_max_std;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 if(localPPO2 >= (testPPO2high + 1))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 pDiveState->warnings.ppO2High = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 pDiveState->warnings.ppO2High = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 return pDiveState->warnings.ppO2Low + pDiveState->warnings.ppO2High;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
271 static int8_t check_O2_sensors(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 pDiveState->warnings.sensorLinkLost = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 pDiveState->warnings.sensorOutOfBounds[0] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 pDiveState->warnings.sensorOutOfBounds[1] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 pDiveState->warnings.sensorOutOfBounds[2] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
278 if(isLoopMode(pDiveState->diveSettings.diveMode) && (pDiveState->diveSettings.CCR_Mode == CCRMODE_Sensors))
952
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
279 {
563
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
280 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
281 {
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
282 {
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
283 if(!get_HUD_battery_voltage_V())
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
284 pDiveState->warnings.sensorLinkLost = 1;
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
285 }
d97f0e395058 Refine o2 sensor diagnostic functions:
Ideenmodellierer
parents: 478
diff changeset
286 }
952
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
287 test_O2_sensor_values_outOfBounds(&pDiveState->warnings.sensorOutOfBounds[0], &pDiveState->warnings.sensorOutOfBounds[1], &pDiveState->warnings.sensorOutOfBounds[2]);
33e24b77cc6c Bugfix ppo2 high/low check in OC mode:
Ideenmodellierer
parents: 913
diff changeset
288 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 return pDiveState->warnings.sensorLinkLost
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 + pDiveState->warnings.sensorOutOfBounds[0]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 + pDiveState->warnings.sensorOutOfBounds[1]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 + pDiveState->warnings.sensorOutOfBounds[2];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
296 static uint8_t getBetterGasId(bool getDiluent, uint8_t startingGasId, SDiveState *diveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 {
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
298 SDiveSettings diveSettings = diveState->diveSettings;
831
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
299 SGasLine localGas;
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
300 uint8_t betterGasIdLocal = startingGasId;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
301 uint8_t bestGasDepth = 255;
831
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
302 uint8_t i;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
304 uint8_t gasIdOffset;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
305 if (getDiluent) {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
306 gasIdOffset = NUM_OFFSET_DILUENT;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
307 } else {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
308 gasIdOffset = 0;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
309 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 /* life data is float, gas data is uint8 */
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
312 if (actualLeftMaxDepth(diveState)) { /* deco gases */
831
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
313 for (i=1+gasIdOffset; i<= 5+gasIdOffset; i++) {
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
314 memcpy(&localGas,&diveSettings.gas[i],sizeof(SGasLine));
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
315 if((localGas.note.ub.first) && (diveSettings.diveMode == DIVEMODE_PSCR)) /* handle first gas as if it would be a deco gas set to MOD */
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
316 {
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
317 localGas.note.ub.active = 1;
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
318 localGas.note.ub.deco = 1;
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
319 localGas.depth_meter = calc_MOD(i);
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
320 }
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
321 if ((localGas.note.ub.active)
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
322 && (localGas.note.ub.deco)
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
323 && (localGas.depth_meter)
913
5f38cf765193 Adapted limit for better gas warning:
Ideenmodellierer
parents: 873
diff changeset
324 && (localGas.depth_meter >= (diveState->lifeData.depth_meter - 0.9f ))
831
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
325 && (localGas.depth_meter <= bestGasDepth)) {
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
326 betterGasIdLocal = i;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
327 bestGasDepth = diveSettings.gas[i].depth_meter;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
328 }
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
329 }
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
330 } else { /* travel gases */
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
331 bestGasDepth = 0;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
332 //check for travalgas
831
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
333 for (i = 1 + gasIdOffset; i <= 5 + gasIdOffset; i++) {
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
334 if ((diveSettings.gas[i].note.ub.active)
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
335 && (diveSettings.gas[i].note.ub.travel)
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
336 && (diveSettings.gas[i].depth_meter_travel)
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
337 && (diveSettings.gas[i].depth_meter_travel <= (diveState->lifeData.depth_meter + 0.01f ))
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
338 && (diveSettings.gas[i].depth_meter_travel >= bestGasDepth)) {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
339 betterGasIdLocal = i;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
340 bestGasDepth = diveSettings.gas[i].depth_meter;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
341 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 }
831
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
344 if((!getDiluent) && (betterGasIdLocal > NUM_OFFSET_DILUENT)) /* an OC gas was requested but Id is pointing to a diluent => return first OC */
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
345 {
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
346 for (i = 1 ; i <= NUM_OFFSET_DILUENT; i++)
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
347 {
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
348 if(diveSettings.gas[i].note.ub.first)
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
349 {
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
350 betterGasIdLocal = i;
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
351 break;
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
352 }
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
353 }
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
354 }
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
355
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
357 return betterGasIdLocal;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
358 }
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
359
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
360
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
361 static int8_t check_BetterGas(SDiveState *diveState)
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
362 {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
363 diveState->warnings.betterGas = 0;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
364
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
365 if (stateUsed->mode != MODE_DIVE) {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
366 betterGasId = 0;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
367
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
368 return 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 }
773
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
370
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
371 SDiveSettings diveSettings = diveState->diveSettings;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
372 SLifeData lifeData = diveState->lifeData;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
373
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
374 if (isLoopMode(diveSettings.diveMode)) {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
375 betterGasId = getBetterGasId(true, lifeData.actualGas.GasIdInSettings, diveState);
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
376 betterBailoutGasId = getBetterGasId(false, lifeData.lastDiluent_GasIdInSettings, diveState);
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
377 } else {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
378 betterGasId = getBetterGasId(false, lifeData.actualGas.GasIdInSettings, diveState);
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
379 }
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
380
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
381 if (betterGasId != lifeData.actualGas.GasIdInSettings && !check_helper_same_oxygen_and_helium_content(&diveSettings.gas[betterGasId], &diveSettings.gas[lifeData.actualGas.GasIdInSettings])) {
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
382 diveState->warnings.betterGas = 1;
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
383 }
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
384
2c243233c999 Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents: 771
diff changeset
385 return diveState->warnings.betterGas;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387
771
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
388
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
389 uint8_t getSetpointLowId(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 {
788
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
391 SSettings *settings = settingsGetPointer();
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
392
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
393 if (settings->autoSetpoint) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
394 return SETPOINT_INDEX_AUTO_LOW;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
395 }
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
396
771
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
397 uint8_t setpointLowId = 0;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
398 uint8_t setpointLowDepthM = UINT8_MAX;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
399 for (unsigned i = 1; i <= NUM_GASES; i++) {
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
400 if (stateUsed->diveSettings.setpoint[i].depth_meter && stateUsed->diveSettings.setpoint[i].depth_meter < setpointLowDepthM) {
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
401 setpointLowId = i;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
402 setpointLowDepthM = stateUsed->diveSettings.setpoint[i].depth_meter;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
403 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
404 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
405
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
406 return setpointLowId;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
407 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
408
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
409
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
410 uint8_t getSetpointHighId(void)
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
411 {
788
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
412 SSettings *settings = settingsGetPointer();
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
413
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
414 if (settings->autoSetpoint) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
415 return SETPOINT_INDEX_AUTO_HIGH;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
416 }
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
417
771
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
418 uint8_t setpointHighId = 0;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
419 uint8_t setpointHighDepthM = 0;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
420 for (unsigned i = 1; i <= NUM_GASES; i++) {
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
421 if (stateUsed->diveSettings.setpoint[i].depth_meter && stateUsed->diveSettings.setpoint[i].depth_meter >= setpointHighDepthM) {
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
422 setpointHighId = i;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
423 setpointHighDepthM = stateUsed->diveSettings.setpoint[i].depth_meter;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
424 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
425 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
426
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
427 return setpointHighId;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
428 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 636
diff changeset
430
788
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
431 uint8_t getSetpointDecoId(void)
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
432 {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
433 SSettings *settings = settingsGetPointer();
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
434
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
435 if (settings->autoSetpoint && stateUsed->diveSettings.setpoint[SETPOINT_INDEX_AUTO_DECO].note.ub.active) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
436 return SETPOINT_INDEX_AUTO_DECO;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
437 }
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
438
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
439 return 0;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
440 }
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
441
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
442
771
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
443 /* check for better travel!!! setpoint hw 151210
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
444 */
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
445 static int8_t check_BetterSetpoint(SDiveState *diveState)
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
446 {
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
447 diveState->warnings.betterSetpoint = 0;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
448
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
449 if (stateUsed->mode != MODE_DIVE) {
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
450 betterSetpointId = 1;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
451
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
452 return 0;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
453 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
454
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
455 SSettings *settings = settingsGetPointer();
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
456
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
457 float currentDepthM = diveState->lifeData.depth_meter;
788
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
458 float lastChangeDepthM = diveState->lifeData.lastSetpointChangeDepthM;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
459 if (settings->dive_mode == DIVEMODE_CCR && lastChangeDepthM != currentDepthM) {
771
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
460 bool descending = currentDepthM > lastChangeDepthM;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
461 uint8_t betterSetpointIdLocal = 0;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
462
788
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
463 if (settings->autoSetpoint) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
464 bool decoSetpointEnabled = diveState->diveSettings.setpoint[SETPOINT_INDEX_AUTO_DECO].note.ub.active;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
465 const SDecoinfo *decoInfo = getDecoInfo();
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
466 uint8_t nextDecoStopDepthM;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
467 uint16_t nextDecoStopTimeRemainingS;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
468 tHome_findNextStop(decoInfo->output_stop_length_seconds, &nextDecoStopDepthM, &nextDecoStopTimeRemainingS);
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
469
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
470 if (decoSetpointEnabled && nextDecoStopDepthM && currentDepthM < nextDecoStopDepthM + SETPOINT_DECO_START_RANGE_M && !diveState->lifeData.setpointDecoActivated) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
471 betterSetpointIdLocal = SETPOINT_INDEX_AUTO_DECO;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
472 diveState->lifeData.setpointDecoActivated = true;
771
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
473 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
474
788
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
475 if (descending) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
476 uint8_t switchDepthHighM = diveState->diveSettings.setpoint[SETPOINT_INDEX_AUTO_HIGH].depth_meter;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
477
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
478 if (lastChangeDepthM < switchDepthHighM && switchDepthHighM < currentDepthM && !diveState->lifeData.setpointDecoActivated) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
479 betterSetpointIdLocal = SETPOINT_INDEX_AUTO_HIGH;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
480 }
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
481 } else {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
482 uint8_t switchDepthLowM = diveState->diveSettings.setpoint[SETPOINT_INDEX_AUTO_LOW].depth_meter;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
483
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
484 if (lastChangeDepthM > SWITCH_DEPTH_LOW_MINIMUM_M && SWITCH_DEPTH_LOW_MINIMUM_M > currentDepthM) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
485 // Avoid draining the oxygen supply by surfacing with a setpoint >= 1.0
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
486 betterSetpointIdLocal = SETPOINT_INDEX_AUTO_LOW;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
487 diveState->lifeData.setpointLowDelayed = false;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
488 } else if (lastChangeDepthM > switchDepthLowM && switchDepthLowM > currentDepthM) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
489 if (nextDecoStopDepthM && settings->delaySetpointLow) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
490 diveState->lifeData.setpointLowDelayed = true;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
491 } else {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
492 betterSetpointIdLocal = SETPOINT_INDEX_AUTO_LOW;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
493 }
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
494 }
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
495 }
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
496
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
497 if (!nextDecoStopDepthM) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
498 // Update the state when the decompression obligation ends
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
499 diveState->lifeData.setpointDecoActivated = false;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
500
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
501 if (diveState->lifeData.setpointLowDelayed) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
502 betterSetpointIdLocal = SETPOINT_INDEX_AUTO_LOW;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
503 diveState->lifeData.setpointLowDelayed = false;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
504 }
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
505 }
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
506 } else {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
507 uint8_t setpointLowId = getSetpointLowId();
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
508 uint8_t setpointHighId = getSetpointHighId();
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
509 uint8_t betterSetpointSwitchDepthM = descending ? 0 : UINT8_MAX;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
510
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
511 for (unsigned i = 1; i <= NUM_GASES; i++) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
512 uint8_t switchDepthM = diveState->diveSettings.setpoint[i].depth_meter;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
513 if (!switchDepthM || (descending && i == setpointLowId) || (!descending && i == setpointHighId)) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
514 continue;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
515 }
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
516
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
517 if ((descending && lastChangeDepthM < switchDepthM && switchDepthM < currentDepthM && switchDepthM > betterSetpointSwitchDepthM)
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
518 || (!descending && lastChangeDepthM > switchDepthM && switchDepthM > currentDepthM && switchDepthM <= betterSetpointSwitchDepthM)) {
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
519 betterSetpointIdLocal = i;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
520 betterSetpointSwitchDepthM = switchDepthM;
4abfb8a2a435 Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents: 773
diff changeset
521 }
771
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
522 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
523 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
524
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
525 if (betterSetpointIdLocal) {
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
526 betterSetpointId = betterSetpointIdLocal;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
527 if (diveState->diveSettings.diveMode == DIVEMODE_CCR && diveState->diveSettings.setpoint[betterSetpointIdLocal].setpoint_cbar != diveState->lifeData.actualGas.setPoint_cbar) {
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
528 diveState->warnings.betterSetpoint = 1;
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
529 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
530 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
531 }
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
532
29d9b5bc7946 Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents: 756
diff changeset
533 return diveState->warnings.betterSetpoint;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 /* hw 151030
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 */
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
539 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 if(gas1->helium_percentage != gas2->helium_percentage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 if(gas1->oxygen_percentage != gas2->oxygen_percentage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
551 static int8_t check_CNS(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 pDiveState->warnings.cnsHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 if(pDiveState->lifeData.cns >= (float)(settingsGetPointer()->CNS_max))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 pDiveState->warnings.cnsHigh = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 pDiveState->warnings.cnsHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 return pDiveState->warnings.cnsHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
567 static int8_t check_Battery(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568 {
671
b456be1e152d Support of unknown charging counter values:
Ideenmodellierer
parents: 662
diff changeset
569 if((pDiveState->lifeData.battery_charge > 0) && (pDiveState->lifeData.battery_charge < 10))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 pDiveState->warnings.lowBattery = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 pDiveState->warnings.lowBattery = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 return pDiveState->warnings.lowBattery;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
578 static int8_t check_Deco(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 uint8_t depthNext = decom_get_actual_deco_stop(pDiveState);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588 if(!depthNext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 if(pDiveState->lifeData.depth_meter + 0.1f < (float)depthNext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 pDiveState->warnings.decoMissed = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 pDiveState->warnings.decoMissed = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 return pDiveState->warnings.decoMissed;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
600 static int8_t check_AscentRate(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 pDiveState->warnings.ascentRateHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 float warnAscentRateFloat;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 warnAscentRateFloat = (float)(settingsGetPointer()->ascent_MeterPerMinute_max);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 if(pDiveState->lifeData.ascent_rate_meter_per_min >= warnAscentRateFloat)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 pDiveState->warnings.ascentRateHigh = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 pDiveState->warnings.ascentRateHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 return pDiveState->warnings.ascentRateHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619
268
1b9847d40e81 cleanup: make things static where possible.
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
620 static int8_t check_aGF(SDiveState * pDiveState)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 pDiveState->warnings.aGf = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628 pDiveState->warnings.aGf = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631 if((pDiveState->diveSettings.gf_high != settingsGetPointer()->GF_high) || (pDiveState->diveSettings.gf_low != settingsGetPointer()->GF_low))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632 pDiveState->warnings.aGf = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 return pDiveState->warnings.aGf;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636
478
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
637 #ifdef ENABLE_BOTTLE_SENSOR
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
638 static int8_t check_pressureSensor(SDiveState * pDiveState)
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
639 {
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
640 int8_t ret = 0;
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
641 if(pDiveState->lifeData.bottle_bar_age_MilliSeconds[pDiveState->lifeData.actualGas.GasIdInSettings] < 50) /* we received a new value */
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
642 {
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
643 pDiveState->warnings.newPressure = stateUsed->lifeData.bottle_bar[stateUsed->lifeData.actualGas.GasIdInSettings];
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
644 ret = 1;
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
645 }
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
646 else
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
647 {
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
648 pDiveState->warnings.newPressure = 0;
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
649 }
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
650 return ret;
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
651 }
58200d756365 Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents: 272
diff changeset
652 #endif
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
653
756
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
654 #ifdef ENABLE_CO2_SUPPORT
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
655 static int8_t check_co2(SDiveState * pDiveState)
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
656 {
831
da632300e7d4 Activated work gas for (p)scr mode:
Ideenmodellierer
parents: 788
diff changeset
657 if((pDiveState->mode != MODE_DIVE) || (settingsGetPointer()->co2_sensor_active == 0))
756
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
658 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
659 pDiveState->warnings.co2High = 0;
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
660 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
661 else
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
662 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
663 if(pDiveState->lifeData.CO2_data.CO2_ppm > CO2_ALARM_LEVEL_PPM)
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
664 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
665 pDiveState->warnings.co2High = 1;
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
666 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
667 else
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
668 {
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
669 pDiveState->warnings.co2High = 0;
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
670 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
671 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
672 return pDiveState->warnings.co2High;
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
673 }
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
674 #endif
6de83d8205a0 Added visualization of CO2 during dive:
Ideenmodellierer
parents: 671
diff changeset
675
857
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
676 #ifdef HAVE_DEBUG_WARNINGS
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
677 static int8_t check_debug(SDiveState * pDiveState)
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
678 {
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
679 uint8_t index = 0;
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
680
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
681 pDiveState->warnings.debug = 0;
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
682
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
683 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG))
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
684 {
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
685 for(index=0; index<3; index++)
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
686 {
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
687 if(((pDiveState->lifeData.extIf_sensor_map[index] == SENSOR_DIGO2M) && (((SSensorDataDiveO2*)(stateUsed->lifeData.extIf_sensor_data[index]))->status & DVO2_FATAL_ERROR)))
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
688 {
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
689 pDiveState->warnings.debug = 1;
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
690 }
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
691 }
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
692 }
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
693 return pDiveState->warnings.debug;
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
694 }
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
695 #endif
ba1aebc6d5af Developer feature debug warning:
Ideenmodellierer
parents: 831
diff changeset
696
636
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
697 uint8_t debounce_warning_fallback(uint16_t debounceStepms)
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
698 {
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
699 uint8_t retVal = 0;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
700
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
701 debounceFallbackTimeMS += debounceStepms;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
702 if(debounceFallbackTimeMS > DEBOUNCE_FALLBACK_TIME_MS)
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
703 {
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
704 debounceFallbackTimeMS = DEBOUNCE_FALLBACK_TIME_MS;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
705 retVal = 1;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
706 }
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
707 return retVal;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
708 }
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
709 void reset_debounce_warning_fallback()
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
710 {
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
711 debounceFallbackTimeMS = 0;
c47766ec3f96 Debounce fallback warning:
Ideenmodellierer
parents: 634
diff changeset
712 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714