Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditSetpoint.c @ 773:2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
author | heinrichsweikamp |
---|---|
date | Wed, 10 May 2023 16:24:57 +0200 |
parents | 1b995079c045 |
children | 46c6d2380d4e |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuEditSetpoint.c | |
5 /// \brief | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 19-Dec-2014 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 /* Includes ------------------------------------------------------------------*/ | |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
30 #include <stdbool.h> |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
31 |
38 | 32 #include "tMenuEditSetpoint.h" |
33 | |
34 #include "check_warning.h" | |
35 #include "gfx_fonts.h" | |
36 #include "tMenuEdit.h" | |
37 #include "unit.h" | |
38 | |
39 /* Private types -------------------------------------------------------------*/ | |
40 typedef struct | |
41 { | |
42 uint8_t spID; | |
43 SSetpointLine * pSetpointLine; | |
44 } SEditSetpointPage; | |
45 | |
46 | |
47 /* Private variables ---------------------------------------------------------*/ | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
48 static SEditSetpointPage editSetpointPage; |
38 | 49 |
50 /* Private function prototypes -----------------------------------------------*/ | |
51 | |
52 /* Announced function prototypes -----------------------------------------------*/ | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
53 static uint8_t OnAction_SP_Setpoint (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
54 static uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
55 static uint8_t OnAction_SP_DM_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
56 static uint8_t OnAction_SP_DM_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
38 | 57 |
58 /* Exported functions --------------------------------------------------------*/ | |
59 | |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
60 void checkSwitchToLoop(void) |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
61 { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
62 if(!isLoopMode(stateUsedWrite->diveSettings.diveMode)) { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
63 stateUsedWrite->diveSettings.diveMode = settingsGetPointer()->dive_mode; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
64 |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
65 unblock_diluent_page(); |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
66 } |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
67 } |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
68 |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
69 |
38 | 70 void openEdit_Setpoint(uint8_t line) |
71 { | |
72 uint8_t useSensorSubMenu = 0; | |
662 | 73 char text[20]; |
74 uint8_t sensorActive[3]; | |
38 | 75 |
76 /* dive mode */ | |
77 if(actual_menu_content != MENU_SURFACE) | |
78 { | |
79 uint8_t setpointCbar, actualGasID; | |
130
b7689d9e888a
Minor changes to improved code quality and to eliminate warnings
Ideenmodellierer
parents:
38
diff
changeset
|
80 setpointCbar = 100; |
38 | 81 |
82 // actualGasID | |
662 | 83 if(!isLoopMode(stateUsedWrite->diveSettings.diveMode)) |
38 | 84 { |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
85 actualGasID = stateUsedWrite->lifeData.lastDiluent_GasIdInSettings; |
38 | 86 if((actualGasID <= NUM_OFFSET_DILUENT) || (actualGasID > NUM_GASES + NUM_OFFSET_DILUENT)) |
87 actualGasID = NUM_OFFSET_DILUENT + 1; | |
88 } | |
89 else | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
90 actualGasID = stateUsedWrite->lifeData.actualGas.GasIdInSettings; |
38 | 91 |
92 // setpointCbar, CCR_Mode and sensor menu | |
662 | 93 if((line < 6) && (stateUsedWrite->diveSettings.diveMode != DIVEMODE_PSCR)) /* setpoints inactive in PSCR mode */ |
38 | 94 { |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
95 setpointCbar = stateUsedWrite->diveSettings.setpoint[line].setpoint_cbar; |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
96 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint; |
38 | 97 |
98 // BetterSetpoint warning only once | |
99 if(actualBetterSetpointId() == line) | |
100 { | |
101 uint8_t depth; | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
102 depth = stateUsedWrite->diveSettings.setpoint[line].depth_meter; |
38 | 103 // BetterSetpoint warning only once -> clear active |
104 for(int i=0; i<=NUM_GASES; i++) | |
105 { | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
106 stateUsedWrite->diveSettings.setpoint[i].note.ub.first = 0; |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
107 if(stateUsedWrite->diveSettings.setpoint[i].depth_meter <= depth) |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
108 stateUsedWrite->diveSettings.setpoint[i].note.ub.active = 0; |
38 | 109 } |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
110 stateUsedWrite->diveSettings.setpoint[line].note.ub.first = 1; |
38 | 111 } |
112 } | |
662 | 113 else /* menu item not pointing to setpoint selection => use sensor or ppo2 simulation */ |
38 | 114 { |
662 | 115 if((stateUsedWrite->diveSettings.diveMode == DIVEMODE_PSCR) && (line == 2)) |
116 { | |
117 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_Simulation; | |
118 } | |
119 else /* => use sensor */ | |
120 { | |
121 if(stateUsedWrite->diveSettings.CCR_Mode != CCRMODE_Sensors) | |
122 { | |
123 /* setpoint_cbar will be written by updateSetpointStateUsed() in main.c loop */ | |
124 setpointCbar = 255; | |
125 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_Sensors; | |
126 } | |
127 else | |
128 { | |
129 useSensorSubMenu = 1; | |
130 } | |
131 } | |
38 | 132 } |
133 | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
134 setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar); |
38 | 135 |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
136 checkSwitchToLoop(); |
38 | 137 |
138 clear_warning_fallback(); | |
139 | |
140 if(!useSensorSubMenu) | |
141 { | |
142 exitMenuEdit_to_Home(); | |
143 } | |
144 else // entire sub menu during dive to select sensors active | |
145 { | |
146 set_globalState_Menu_Line(line); | |
147 resetMenuEdit(CLUT_MenuPageGasSP); | |
148 | |
149 text[0] = '\001'; | |
150 text[1] = TXT_o2Sensors; | |
151 text[2] = 0; | |
152 write_topline(text); | |
153 | |
638
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
154 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1) |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
155 { |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
156 snprintf (text,20,"Sensor 1"); |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
157 sensorActive[0] = 0; |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
158 } |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
159 else |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
160 { |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
161 snprintf (text,20,"Sensor 1 (%01.2f)", stateUsed->lifeData.ppO2Sensor_bar[0] ); |
662 | 162 sensorActive[0] = 1; |
638
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
163 } |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
164 write_label_var( 96, 600, ME_Y_LINE1, &FontT48, text); |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
165 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 2) |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
166 { |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
167 snprintf (text,20,"Sensor 2"); |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
168 sensorActive[1] = 0; |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
169 } |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
170 else |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
171 { |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
172 snprintf (text,20,"Sensor 2 (%01.2f)", stateUsed->lifeData.ppO2Sensor_bar[1] ); |
662 | 173 sensorActive[1] = 1; |
638
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
174 } |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
175 write_label_var( 96, 600, ME_Y_LINE2, &FontT48, text); |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
176 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 4) |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
177 { |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
178 snprintf (text,20,"Sensor 3"); |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
179 sensorActive[2] = 0; |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
180 } |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
181 else |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
182 { |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
183 snprintf (text,20,"Sensor 3 (%01.2f)", stateUsed->lifeData.ppO2Sensor_bar[2] ); |
662 | 184 sensorActive[2] = 1; |
638
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
185 } |
4532953ac1a0
Added last measured PPO2 value to sensor selection dialog:
Ideenmodellierer
parents:
288
diff
changeset
|
186 write_label_var( 96, 600, ME_Y_LINE3, &FontT48, text); |
38 | 187 |
188 write_field_on_off(StMSP_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]); | |
189 write_field_on_off(StMSP_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); | |
190 write_field_on_off(StMSP_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]); | |
191 | |
192 setEvent(StMSP_Sensor1, (uint32_t)OnAction_SP_DM_Sensor1); | |
193 setEvent(StMSP_Sensor2, (uint32_t)OnAction_SP_DM_Sensor2); | |
194 setEvent(StMSP_Sensor3, (uint32_t)OnAction_SP_DM_Sensor3); | |
195 } | |
196 return; | |
197 } | |
198 else | |
199 { | |
200 /* surface mode */ | |
201 uint8_t spId, setpoint_cbar, sp_high, depthDeco, first; | |
202 // uint8_t active, | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
203 char text[70]; |
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
204 uint8_t textPointer; |
38 | 205 uint16_t y_line; |
206 | |
650 | 207 if(line < 6) |
208 { | |
209 set_globalState_Menu_Line(line); | |
38 | 210 |
650 | 211 resetMenuEdit(CLUT_MenuPageGasSP); |
212 | |
213 spId = line; | |
214 editSetpointPage.spID = spId; | |
215 SSettings *data = settingsGetPointer(); | |
216 editSetpointPage.pSetpointLine = data->setpoint; | |
38 | 217 |
650 | 218 setpoint_cbar = editSetpointPage.pSetpointLine[spId].setpoint_cbar; |
219 depthDeco = editSetpointPage.pSetpointLine[spId].depth_meter; | |
220 //active = editSetpointPage.pSetpointLine[spId].note.ub.active; | |
221 first = editSetpointPage.pSetpointLine[spId].note.ub.first; | |
38 | 222 |
650 | 223 sp_high = setpoint_cbar / 100; |
38 | 224 |
650 | 225 strcpy(text, "\001" "Setpoint #0 X"); |
226 text[11] += spId; | |
227 text[13] = TXT_Setpoint_Edit; | |
228 write_topline(text); | |
38 | 229 |
230 | |
650 | 231 y_line = ME_Y_LINE_BASE + (line * ME_Y_LINE_STEP); |
38 | 232 |
650 | 233 textPointer = 0; |
234 text[textPointer++] = 'S'; | |
235 text[textPointer++] = 'P'; | |
236 text[textPointer++] = '0' + spId; | |
237 text[textPointer++] = ' '; | |
238 text[textPointer++] = ' '; | |
38 | 239 |
650 | 240 if(first == 0) |
241 strcpy(&text[textPointer++],"\177"); | |
38 | 242 |
650 | 243 textPointer += snprintf(&text[textPointer], 60,\ |
244 "* " | |
245 " " | |
246 "\016\016" | |
247 " bar" | |
248 "\017" | |
249 "\034" | |
250 " " | |
251 "\016\016" | |
252 " " | |
253 "\017" | |
254 " " | |
255 "\016\016" | |
256 "meter" | |
257 "\017" | |
258 "\035" | |
259 "\n\r" | |
260 ); | |
261 write_label_var( 20, 800, y_line, &FontT48, text); | |
38 | 262 |
650 | 263 write_field_udigit(StMSP_ppo2_setting, 160, 800, y_line, &FontT48, "#.## ###", (uint32_t)sp_high, (uint32_t)(setpoint_cbar - (100 * sp_high)), depthDeco, 0); |
264 setEvent(StMSP_ppo2_setting, (uint32_t)OnAction_SP_Setpoint); | |
265 startEdit(); | |
266 } | |
267 else | |
268 { | |
269 SSettings *pSettings = settingsGetPointer(); | |
270 | |
271 if(pSettings->autoSetpoint == 0) | |
272 { | |
273 pSettings->autoSetpoint = 1; | |
274 } | |
275 else | |
276 { | |
277 pSettings->autoSetpoint = 0; | |
278 } | |
279 exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only(); | |
280 } | |
38 | 281 } |
282 } | |
283 | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
284 static uint8_t OnAction_SP_Setpoint(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
38 | 285 { |
286 int8_t digitContentNew; | |
287 uint32_t new_integer_part, new_fractional_part, new_cbar, newDepth; | |
288 | |
289 if(action == ACTION_BUTTON_ENTER) | |
290 return digitContent; | |
291 | |
292 if(action == ACTION_BUTTON_ENTER_FINAL) | |
293 { | |
294 evaluateNewString(editId, &new_integer_part, &new_fractional_part, &newDepth, 0); | |
295 | |
296 new_cbar = (new_integer_part * 100) + new_fractional_part; | |
297 | |
652 | 298 if(new_cbar < MIN_PPO2_SP_CBAR) |
299 new_cbar = MIN_PPO2_SP_CBAR; | |
38 | 300 |
301 if(new_cbar > 160) | |
302 new_cbar = 160; | |
303 | |
304 new_integer_part = new_cbar / 100; | |
305 new_fractional_part = new_cbar - (new_integer_part * 100); | |
306 | |
307 editSetpointPage.pSetpointLine[editSetpointPage.spID].setpoint_cbar = new_cbar; | |
308 | |
309 if(newDepth > 255) | |
310 newDepth = 255; | |
311 | |
312 editSetpointPage.pSetpointLine[editSetpointPage.spID].depth_meter = newDepth; | |
313 | |
314 return UPDATE_AND_EXIT_TO_MENU; | |
315 } | |
316 | |
317 if(action == ACTION_BUTTON_NEXT) | |
318 { | |
319 digitContentNew = digitContent + 1; | |
320 if((blockNumber == 0) && (digitContentNew > '1')) | |
321 digitContentNew = '0'; | |
322 if(digitContentNew > '9') | |
323 digitContentNew = '0'; | |
324 return digitContentNew; | |
325 } | |
326 | |
327 if(action == ACTION_BUTTON_BACK) | |
328 { | |
329 digitContentNew = digitContent - 1; | |
213
d539ed9aa5b8
Bugfix, trivial: do not visit 9 on first digit for setpoint
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
330 if((blockNumber == 0) && (digitContentNew < '0')) |
38 | 331 digitContentNew = '1'; |
332 if(digitContentNew < '0') | |
333 digitContentNew = '9'; | |
334 return digitContentNew; | |
335 } | |
336 | |
337 return EXIT_TO_MENU; | |
338 } | |
339 | |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
340 void openEdit_DiveSelectBetterSetpoint(bool useLastDiluent) |
38 | 341 { |
342 uint8_t spId; | |
343 uint8_t depth; | |
344 | |
662 | 345 if(stateUsedWrite->diveSettings.diveMode != DIVEMODE_PSCR) /* no setpoints in PSCR mode */ |
38 | 346 { |
662 | 347 spId = actualBetterSetpointId(); |
348 | |
349 depth = stateUsedWrite->diveSettings.setpoint[spId].depth_meter; | |
38 | 350 |
662 | 351 // BetterSetpoint warning only once -> clear active |
352 for(int i=0; i<=NUM_GASES; i++) | |
353 { | |
354 stateUsedWrite->diveSettings.setpoint[i].note.ub.first = 0; | |
355 if(stateUsedWrite->diveSettings.setpoint[i].depth_meter <= depth) | |
356 stateUsedWrite->diveSettings.setpoint[i].note.ub.active = 0; | |
357 } | |
38 | 358 |
662 | 359 // new setpoint |
360 stateUsedWrite->diveSettings.setpoint[spId].note.ub.first = 1; | |
361 | |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
362 uint8_t gasId; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
363 if (useLastDiluent) { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
364 gasId = stateUsed->lifeData.lastDiluent_GasIdInSettings; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
365 } else { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
366 gasId = stateUsed->lifeData.actualGas.GasIdInSettings; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
367 } |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
368 |
662 | 369 // change in lifeData |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
370 setActualGas_DM(&stateUsedWrite->lifeData, gasId, stateUsedWrite->diveSettings.setpoint[spId].setpoint_cbar); |
662 | 371 } |
38 | 372 } |
373 | |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
374 |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
375 static uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
38 | 376 { |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
377 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1) |
38 | 378 { |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
379 stateUsedWrite->diveSettings.ppo2sensors_deactivated &= 4+2; |
38 | 380 tMenuEdit_set_on_off(editId, 1); |
381 } | |
382 else | |
383 { | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
384 stateUsedWrite->diveSettings.ppo2sensors_deactivated |= 1; |
38 | 385 tMenuEdit_set_on_off(editId, 0); |
386 } | |
387 | |
388 return UNSPECIFIC_RETURN; | |
389 } | |
390 | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
391 static uint8_t OnAction_SP_DM_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
38 | 392 { |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
393 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 2) |
38 | 394 { |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
395 stateUsedWrite->diveSettings.ppo2sensors_deactivated &= 4+1; |
38 | 396 tMenuEdit_set_on_off(editId, 1); |
397 } | |
398 else | |
399 { | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
400 stateUsedWrite->diveSettings.ppo2sensors_deactivated |= 2; |
38 | 401 tMenuEdit_set_on_off(editId, 0); |
402 } | |
403 | |
404 return UNSPECIFIC_RETURN; | |
405 } | |
406 | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
407 static uint8_t OnAction_SP_DM_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
38 | 408 { |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
409 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 4) |
38 | 410 { |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
411 stateUsedWrite->diveSettings.ppo2sensors_deactivated &= 2+1; |
38 | 412 tMenuEdit_set_on_off(editId, 1); |
413 } | |
414 else | |
415 { | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
213
diff
changeset
|
416 stateUsedWrite->diveSettings.ppo2sensors_deactivated |= 4; |
38 | 417 tMenuEdit_set_on_off(editId, 0); |
418 } | |
419 return UNSPECIFIC_RETURN; | |
420 } |