Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditGasOC.c @ 982:22d5b477c903 GasConsumption
Code cleanup: Remove disabled option to switch deco calc on/off
author | Ideenmodellierer |
---|---|
date | Sun, 02 Mar 2025 21:42:45 +0100 (2 months ago) |
parents | 79b522fbabe6 |
children |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuEditGasOC.c | |
5 /// \brief Main Template file for editing Open Circuit Gas Settings | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 09-July-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 ------------------------------------------------------------------*/ | |
30 #include "tMenuEditGasOC.h" | |
31 | |
32 #include "check_warning.h" | |
33 #include "gfx_fonts.h" | |
34 #include "tMenuEdit.h" | |
35 #include "unit.h" | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
36 #include "configuration.h" |
38 | 37 |
38 /* Private types -------------------------------------------------------------*/ | |
39 typedef struct | |
40 { | |
41 uint8_t gasID; | |
42 SGasLine * pGasLine; | |
43 uint8_t mod; | |
44 uint8_t ccr; | |
45 uint8_t setpoint; | |
46 } SEditGasPage; | |
47 | |
48 | |
49 /* Private variables ---------------------------------------------------------*/ | |
50 SEditGasPage editGasPage; | |
51 | |
52 /* Private function prototypes -----------------------------------------------*/ | |
53 void create_text_with_u8(char *text, const char *text1, uint8_t inputU8, const char *text2); | |
54 | |
55 void openEdit_Gas(uint8_t line, uint8_t ccr); | |
56 void openEdit_GasType(void); | |
57 | |
58 void openEdit_DiveGasSelect(uint8_t line, uint8_t ccr); | |
59 void openEdit_SpecialDiveGasMenu(uint8_t ccr); | |
60 void openEdit_DiveGasSelect_Subroutine(uint8_t line, uint8_t ccr); | |
61 | |
62 void tMEGas_check_switch_to_bailout(void); | |
63 | |
64 /* Announced function prototypes -----------------------------------------------*/ | |
65 uint8_t OnAction_Mix (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
66 uint8_t OnAction_GasType (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
67 uint8_t OnAction_ChangeDepth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
68 uint8_t OnAction_SetToMOD (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
69 uint8_t OnAction_BottleSize (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
70 | |
71 uint8_t OnAction_First (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
72 uint8_t OnAction_Deco (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
73 uint8_t OnAction_Travel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
74 uint8_t OnAction_Inactive (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
75 uint8_t OnAction_Off (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
38 | 76 |
77 uint8_t OnAction_DM_Active (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
78 uint8_t OnAction_DM_Mix (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
79 | |
80 /* | |
81 uint8_t OnAction_DefaultMix (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
82 uint8_t OnAction_ToggleDepth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
83 uint8_t OnAction_ToggleDefault (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
84 uint8_t OnAction_DefaultDepth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
85 */ | |
86 | |
87 /* Exported functions --------------------------------------------------------*/ | |
88 | |
89 void openEdit_GasCC(uint8_t line) | |
90 { | |
91 if(actual_menu_content == MENU_SURFACE) | |
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
92 { |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
93 if(line == 6) |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
94 { |
662 | 95 if(isLoopMode(settingsGetPointer()->dive_mode) || (stateUsed->diveSettings.ccrOption == 1)) |
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
96 { |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
97 selectPage(StMOG); |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
98 } |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
99 } |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
100 else |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
101 { |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
102 openEdit_Gas(line , 1); |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
103 } |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
104 } |
38 | 105 else |
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
106 { |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
107 if(line == 6) |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
108 { |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
109 openEdit_SpecialDiveGasMenu(1); |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
110 } |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
111 else |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
112 { |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
113 openEdit_DiveGasSelect(line, 1); |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
114 } |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
115 } |
38 | 116 } |
117 | |
118 | |
119 void openEdit_GasOC(uint8_t line) | |
120 { | |
121 if(actual_menu_content == MENU_SURFACE) | |
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
122 { |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
123 if(line == 6) |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
124 { |
662 | 125 if(isLoopMode(settingsGetPointer()->dive_mode) || (stateUsed->diveSettings.ccrOption == 1)) |
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
126 { |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
127 selectPage(StMCG); |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
128 } |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
129 } |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
130 else |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
131 { |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
132 openEdit_Gas(line, 0); |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
133 } |
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
134 } |
38 | 135 else |
136 if(line == 6) | |
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
137 { |
38 | 138 openEdit_SpecialDiveGasMenu(0); |
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
139 } |
38 | 140 else |
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
141 { |
38 | 142 openEdit_DiveGasSelect(line, 0); |
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
143 } |
38 | 144 } |
145 | |
146 | |
147 /* dive mode */ | |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
735
diff
changeset
|
148 void openEdit_DiveSelectBetterGas(bool doBailout) |
38 | 149 { |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
735
diff
changeset
|
150 uint8_t gasId; |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
735
diff
changeset
|
151 if (doBailout) { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
735
diff
changeset
|
152 gasId = actualBetterBailoutGasId(); |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
735
diff
changeset
|
153 } else { |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
735
diff
changeset
|
154 gasId = actualBetterGasId(); |
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
735
diff
changeset
|
155 } |
38 | 156 |
773
2c243233c999
Menu shortcut for bailout / return to circuit when diving in CCR mode (mikeller)
heinrichsweikamp
parents:
735
diff
changeset
|
157 uint8_t ccr = 0; |
38 | 158 if(gasId>5) |
159 { | |
160 gasId -= 5; | |
161 ccr = 1; | |
162 } | |
163 openEdit_DiveGasSelect_Subroutine(gasId,ccr); | |
164 if(ccr) | |
165 updateSpecificMenu(StMCG); // is this necessary? openEdit_DiveGasSelect_Subroutine has update. hw 151209 | |
166 else | |
167 updateSpecificMenu(StMOG); // is this necessary? openEdit_DiveGasSelect_Subroutine has update. hw 151209 | |
168 } | |
169 | |
170 | |
171 /* select gas in divemode */ | |
172 void openEdit_DiveGasSelect(uint8_t line, uint8_t ccr) | |
173 { | |
682 | 174 if(!ccr) |
175 { | |
176 tMEGas_check_switch_to_bailout(); | |
177 } | |
178 openEdit_DiveGasSelect_Subroutine(line, ccr); | |
179 | |
38 | 180 exitMenuEdit_to_Home_with_Menu_Update(); |
181 } | |
182 | |
183 | |
184 void openEdit_DiveGasSelect_Subroutine(uint8_t line, uint8_t ccr) | |
185 { | |
186 uint8_t setpoint; | |
187 | |
699 | 188 editGasPage.pGasLine = (SGasLine *)stateUsed->diveSettings.gas; |
38 | 189 |
190 if(ccr) | |
191 { | |
192 editGasPage.gasID = line + NUM_OFFSET_DILUENT; | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
193 setpoint = stateUsed->lifeData.actualGas.setPoint_cbar; |
38 | 194 } |
195 else | |
196 { | |
197 editGasPage.gasID = line; | |
198 setpoint = 0; | |
199 } | |
200 | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
201 #ifdef ENABLE_UNUSED_GAS_HIDING |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
202 if(editGasPage.pGasLine[editGasPage.gasID].note.ub.off) /* disable selection of switched off gases */ |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
203 { |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
204 return; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
205 } |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
206 #endif |
38 | 207 |
208 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
209 setActualGas_DM(&stateUsedWrite->lifeData,editGasPage.gasID,setpoint); |
38 | 210 } |
211 | |
212 /* extra gas and gas on/off option */ | |
213 void openEdit_SpecialDiveGasMenu(uint8_t ccr) | |
214 { | |
215 char text[32]; | |
216 uint8_t oxygen, helium, gasOffset, textpointer, lineCount, ptrGas; | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
217 //SDiveState * pState; |
38 | 218 |
699 | 219 editGasPage.pGasLine = (SGasLine *)stateUsed->diveSettings.gas; |
38 | 220 if(ccr) |
221 { | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
222 editGasPage.setpoint = stateUsed->lifeData.actualGas.setPoint_cbar; |
38 | 223 } |
224 editGasPage.ccr = ccr; | |
225 | |
226 set_globalState_Menu_Line(6); | |
227 | |
228 if(ccr) | |
229 resetMenuEdit(CLUT_MenuPageGasCC); | |
230 else | |
231 resetMenuEdit(CLUT_MenuPageGasOC); | |
232 | |
233 if(ccr) | |
234 gasOffset = NUM_OFFSET_DILUENT; | |
235 else | |
236 gasOffset = 0; | |
237 | |
238 | |
239 text[0] = '\001'; | |
240 text[1] = TXT_2BYTE; | |
241 if(ccr) | |
242 text[2] = TXT2BYTE_SpecialDiveGasMenuCCR; | |
243 else | |
244 text[2] = TXT2BYTE_SpecialDiveGasMenu; | |
245 text[3] = 0; | |
246 write_topline(text); | |
247 | |
248 lineCount = 1; | |
249 | |
250 | |
251 for(int i=1; i<=5; i++) | |
252 { | |
253 ptrGas = i + gasOffset; | |
254 oxygen = stateUsed->diveSettings.gas[ptrGas].oxygen_percentage; | |
255 helium = stateUsed->diveSettings.gas[ptrGas].helium_percentage; | |
256 | |
257 if(oxygen == 100) | |
258 textpointer = snprintf(text,10,"Oxy"); | |
259 else | |
260 if((oxygen == 21) && (helium == 0)) | |
261 textpointer = snprintf(text,10,"Air"); | |
262 else | |
263 textpointer = snprintf(text,10,"%02i/%02i",oxygen,helium); | |
264 | |
265 if(editGasPage.pGasLine[ptrGas].note.ub.first) | |
266 strcpy(&text[textpointer]," *"); | |
267 | |
268 write_field_on_off(StMOG_DM_ActiveBase+i, 30, 500, ME_Y_LINE_BASE + (lineCount * ME_Y_LINE_STEP), &FontT48, text, stateUsed->diveSettings.gas[ptrGas].note.ub.active); | |
269 lineCount++; | |
270 } | |
271 | |
272 if(!ccr) | |
273 { | |
274 if(stateUsed->diveSettings.gas[0].note.ub.first) | |
275 { | |
276 oxygen = stateUsed->diveSettings.gas[0].oxygen_percentage; | |
277 helium = stateUsed->diveSettings.gas[0].helium_percentage; | |
278 write_field_udigit(StMOG_DM_ExtraMix, 30, 800, ME_Y_LINE6, &FontT48, "##/## Extra Gas *", oxygen, helium, 0, 0); | |
279 } | |
280 else | |
281 { | |
282 write_field_udigit(StMOG_DM_ExtraMix, 30, 800, ME_Y_LINE6, &FontT48, "##/## Extra Gas", 0, 0, 0, 0); | |
283 } | |
284 } | |
285 | |
286 for(int i=1; i<=5; i++) | |
287 { | |
288 setEvent(StMOG_DM_ActiveBase + i,(uint32_t)OnAction_DM_Active); | |
289 } | |
290 | |
291 if(!ccr) | |
292 setEvent(StMOG_DM_ExtraMix,(uint32_t)OnAction_DM_Mix); | |
293 } | |
294 | |
295 | |
296 uint8_t OnAction_DM_Active (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
297 { | |
298 uint8_t gasOffset, newActive; | |
299 | |
300 if(editGasPage.ccr) | |
301 gasOffset = NUM_OFFSET_DILUENT; | |
302 else | |
303 gasOffset = 0; | |
304 | |
305 editGasPage.gasID = editId + gasOffset - StMOG_DM_ActiveBase; | |
306 | |
307 if(editGasPage.pGasLine[editGasPage.gasID].note.ub.first) | |
308 return UNSPECIFIC_RETURN; | |
309 | |
310 if(editGasPage.pGasLine[editGasPage.gasID].note.ub.active) | |
311 newActive = 0; | |
312 else | |
313 newActive = 1; | |
314 | |
315 tMenuEdit_set_on_off(editId, newActive); | |
316 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = newActive; | |
317 | |
318 return UNSPECIFIC_RETURN; | |
319 } | |
320 | |
321 /* only for OC */ | |
322 uint8_t OnAction_DM_Mix(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
323 { | |
324 uint8_t digitContentNew; | |
325 uint32_t newOxygen, newHelium; | |
326 | |
327 if(action == ACTION_BUTTON_ENTER) | |
328 { | |
329 return digitContent; | |
330 } | |
331 if(action == ACTION_BUTTON_ENTER_FINAL) | |
332 { | |
333 evaluateNewString(editId, &newOxygen, &newHelium, 0, 0); | |
334 | |
335 if(newOxygen < 5) | |
336 newOxygen = 5; | |
337 if(newOxygen == 99) | |
338 newOxygen = 100; | |
339 if(newHelium > 95) | |
340 newHelium = 95; | |
341 if((newOxygen + newHelium) > 100) | |
342 newOxygen = 100 - newHelium; | |
343 | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
344 //SDiveState * pDiveState = 0; |
38 | 345 |
346 for(int i=1;i<=(2*NUM_GASES);i++) | |
347 editGasPage.pGasLine[i].note.ub.first = 0; | |
348 | |
735
39f48356049b
Fixed invalid setpoint (0.0) used after switch from CCR to extra (OC) gas
heinrichsweikamp
parents:
699
diff
changeset
|
349 tMEGas_check_switch_to_bailout(); |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
350 setActualGas_ExtraGas(&stateUsedWrite->lifeData, newOxygen, newHelium, 0); |
38 | 351 return EXIT_TO_HOME; |
352 } | |
353 if(action == ACTION_BUTTON_NEXT) | |
354 { | |
355 digitContentNew = digitContent + 1; | |
356 if(digitContentNew > '9') | |
357 digitContentNew = '0'; | |
358 return digitContentNew; | |
359 } | |
360 if(action == ACTION_BUTTON_BACK) | |
361 { | |
362 digitContentNew = digitContent - 1; | |
363 if(digitContentNew < '0') | |
364 digitContentNew = '9'; | |
365 return digitContentNew; | |
366 } | |
367 | |
368 return UNSPECIFIC_RETURN; | |
369 } | |
370 | |
371 | |
372 void tMEGas_check_switch_to_bailout(void) | |
373 { | |
662 | 374 if(isLoopMode(stateUsed->diveSettings.diveMode)) |
38 | 375 { |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
376 stateUsedWrite->diveSettings.diveMode = DIVEMODE_OC; |
38 | 377 block_diluent_page(); |
378 } | |
379 } | |
380 | |
381 | |
382 /* surface mode */ | |
383 void openEdit_Gas(uint8_t line, uint8_t ccr) | |
384 { | |
973 | 385 uint8_t gasID, oxygen, helium, depthDeco, active, first, depthMOD, deco, travel, inactive, off ;//, bottleSizeLiter; |
386 | |
38 | 387 char text[32]; |
388 char textMOD[32]; | |
389 uint8_t txtptr; | |
390 | |
391 if(line) | |
392 set_globalState_Menu_Line(line); | |
393 else | |
394 set_globalState_Menu_Line(NUM_GASES + 1); | |
395 | |
396 if(ccr) | |
397 resetMenuEdit(CLUT_MenuPageGasCC); | |
398 else | |
399 resetMenuEdit(CLUT_MenuPageGasOC); | |
400 | |
401 if(ccr) | |
402 gasID = line + NUM_OFFSET_DILUENT; | |
403 else | |
404 gasID = line; | |
405 | |
406 editGasPage.ccr = ccr; | |
407 editGasPage.gasID = gasID; | |
408 editGasPage.mod = calc_MOD(gasID); | |
409 | |
410 SSettings *data = settingsGetPointer(); | |
411 editGasPage.pGasLine = data->gas; | |
412 | |
413 oxygen = editGasPage.pGasLine[gasID].oxygen_percentage; | |
414 if(oxygen > 99) | |
415 oxygen = 99; | |
416 helium = editGasPage.pGasLine[gasID].helium_percentage; | |
417 depthDeco = editGasPage.pGasLine[gasID].depth_meter; | |
418 //depthTravel = editGasPage.pGasLine[gasID].depth_meter_travel; | |
419 active = editGasPage.pGasLine[gasID].note.ub.active; | |
420 first = editGasPage.pGasLine[gasID].note.ub.first; | |
421 deco = editGasPage.pGasLine[gasID].note.ub.deco; | |
422 travel = editGasPage.pGasLine[gasID].note.ub.travel; | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
423 off = editGasPage.pGasLine[gasID].note.ub.off; |
982
22d5b477c903
Code cleanup: Remove disabled option to switch deco calc on/off
Ideenmodellierer
parents:
973
diff
changeset
|
424 |
38 | 425 //bottleSizeLiter = editGasPage.pGasLine[gasID].bottle_size_liter; |
426 | |
427 if(active) | |
428 inactive = 0; | |
429 else | |
430 inactive = 1; | |
431 | |
432 depthMOD = editGasPage.mod; | |
433 | |
434 int i = 0; | |
435 if(gasID >= 10) | |
436 { | |
437 i = 1; | |
438 strcpy(text, "\001" "Gas #10 X"); | |
439 } | |
440 else | |
441 strcpy(text, "\001" "Gas #0 X"); | |
442 | |
443 if(ccr) | |
444 text[8+i] = TXT_Diluent_Gas_Edit; | |
445 else | |
446 text[8+i] = TXT_OC_Gas_Edit; | |
447 | |
448 if(gasID >= 10) | |
449 text[6+i] += gasID - 10; | |
450 else | |
451 text[6+i] += gasID; | |
452 | |
453 write_topline(text); | |
454 if(actual_menu_content == MENU_SURFACE) | |
455 { | |
456 write_label_fix( 20, 800, ME_Y_LINE1, &FontT48, TXT_Mix); | |
457 write_field_udigit(StMOG_Mix, 210, 400, ME_Y_LINE1, &FontT48, "##/##", (uint32_t)oxygen, (uint32_t)helium, 0, 0); | |
458 | |
459 | |
460 text[1] = 0; | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
461 if(off) |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
462 text[0] = TXT_Off; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
463 else |
38 | 464 if(inactive) |
465 text[0] = TXT_Inactive; | |
466 else | |
467 if(first) | |
468 text[0] = TXT_First; | |
469 else | |
470 if(deco) | |
471 text[0] = TXT_Deco; | |
472 else | |
473 if(travel) | |
474 text[0] = TXT_Travel; | |
475 else | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
476 text[0] = TXT_Inactive; |
38 | 477 |
478 write_field_button(StMOG_GasType, 20, 710, ME_Y_LINE2, &FontT48, text); | |
479 | |
480 | |
830
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
481 if((deco) || (travel && ccr)) |
38 | 482 { |
483 text[0] = TXT_ChangeDepth; | |
484 text[1] = ' '; | |
830
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
485 |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
486 if(deco) |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
487 { |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
488 text[2] = TXT_Deco; |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
489 } |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
490 else |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
491 { |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
492 text[2] = TXT_Travel; |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
493 } |
38 | 494 text[3] = 0; |
495 write_label_var( 20 ,800, ME_Y_LINE3, &FontT48, text); | |
496 | |
497 textMOD[0] = '#'; | |
498 textMOD[1] = '#'; | |
499 textMOD[2] = '#'; | |
500 textMOD[3] = unit_depth_char1(); | |
501 textMOD[4] = unit_depth_char2(); | |
502 textMOD[5] = 0; | |
503 write_field_udigit(StMOG_ChangeDepth, 600, 710, ME_Y_LINE3, &FontT48,textMOD, (uint32_t)unit_depth_integer(depthDeco), 0, 0, 0); | |
504 | |
505 txtptr = 0; | |
506 text[txtptr++] = TXT_2BYTE; | |
507 text[txtptr++] = TXT2BYTE_SetToMOD; | |
508 text[txtptr++] = 0; | |
509 write_field_button(StMOG_SetToMOD, 20, 710, ME_Y_LINE4, &FontT48,text); | |
510 } | |
511 else | |
512 { | |
513 txtptr = 0; | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
514 text[txtptr++] = '\031'; |
38 | 515 text[txtptr++] = TXT_ChangeDepth; |
516 text[txtptr++] = ' '; | |
517 text[txtptr++] = TXT_Deco; | |
518 text[txtptr++] = 0; | |
519 write_label_var( 20 ,800, ME_Y_LINE3, &FontT48, text); | |
520 | |
521 txtptr = 0; | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
522 text[txtptr++] = '\031'; |
38 | 523 text[txtptr++] = TXT_2BYTE; |
524 text[txtptr++] = TXT2BYTE_SetToMOD; | |
525 text[txtptr++] = 0; | |
526 write_label_var( 20 ,800, ME_Y_LINE4, &FontT48, text); | |
527 } | |
528 /* | |
529 txtptr = 0; | |
530 text[txtptr++] = TXT_2BYTE; | |
531 text[txtptr++] = TXT2BYTE_Bottle; | |
532 text[txtptr++] = 0; | |
533 write_label_var( 20 ,800, ME_Y_LINE5, &FontT48, text); | |
534 write_field_2digit(StMOG_Bottle, 600, 710, ME_Y_LINE5, &FontT48,"## ltr", (uint32_t)bottleSizeLiter, 0, 0, 0); | |
535 | |
536 */ | |
537 stop_cursor_fields(); | |
538 | |
539 textMOD[0] = '#'; | |
540 textMOD[1] = '#'; | |
541 textMOD[2] = '#'; | |
542 textMOD[3] = unit_depth_char1(); | |
543 textMOD[4] = unit_depth_char2(); | |
544 textMOD[5] = ' '; | |
545 textMOD[6] = 'M'; | |
546 textMOD[7] = 'O'; | |
547 textMOD[8] = 'D'; | |
548 textMOD[9] = 0; | |
549 | |
550 write_field_udigit(StMOG_MOD, 401, 780, ME_Y_LINE1, &FontT48, textMOD, (uint32_t)unit_depth_integer(depthMOD), 0, 0, 0); | |
551 // write_field_udigit(StMOG_MOD, 401, 780, ME_Y_LINE1, &FontT48, "###m MOD", (uint32_t)depthMOD, 0, 0, 0); | |
552 | |
553 setEvent(StMOG_Mix, (uint32_t)OnAction_Mix); | |
554 setEvent(StMOG_GasType, (uint32_t)OnAction_GasType); | |
555 | |
830
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
556 if((deco) || (travel && ccr)) |
38 | 557 { |
558 setEvent(StMOG_ChangeDepth, (uint32_t)OnAction_ChangeDepth); | |
559 setEvent(StMOG_SetToMOD, (uint32_t)OnAction_SetToMOD); | |
560 } | |
561 /* | |
562 setEvent(StMOG_Bottle, (uint32_t)OnAction_BottleSize); | |
563 */ | |
564 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
565 } | |
566 } | |
567 | |
568 /* surface mode */ | |
569 void openEdit_GasType(void) | |
570 { | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
571 uint8_t gasID, active, first, deco, travel, inactive, off; |
38 | 572 char text[32]; |
573 | |
574 | |
575 if(editGasPage.ccr) | |
576 { | |
577 resetMenuEdit(CLUT_MenuPageGasCC); | |
578 setBackMenu((uint32_t)openEdit_GasCC, editGasPage.gasID - NUM_OFFSET_DILUENT, 2); | |
579 } | |
580 else | |
581 { | |
582 resetMenuEdit(CLUT_MenuPageGasOC); | |
583 setBackMenu((uint32_t)openEdit_GasOC, editGasPage.gasID, 2); | |
584 } | |
585 | |
586 gasID = editGasPage.gasID; | |
587 active = editGasPage.pGasLine[gasID].note.ub.active; | |
588 first = editGasPage.pGasLine[gasID].note.ub.first; | |
589 deco = editGasPage.pGasLine[gasID].note.ub.deco; | |
590 travel = editGasPage.pGasLine[gasID].note.ub.travel; | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
591 off = editGasPage.pGasLine[gasID].note.ub.off; |
38 | 592 |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
593 if((active) || (off)) |
38 | 594 inactive = 0; |
595 else | |
596 inactive = 1; | |
597 | |
598 | |
599 /* header */ | |
600 int i = 0; | |
601 if(gasID >= 10) | |
602 { | |
603 i = 1; | |
604 strcpy(text, "\001" "Gas #10 X"); | |
605 } | |
606 else | |
607 strcpy(text, "\001" "Gas #0 X"); | |
608 | |
609 if(editGasPage.ccr) | |
610 text[8+i] = TXT_Diluent_Gas_Edit; | |
611 else | |
612 text[8+i] = TXT_OC_Gas_Edit; | |
613 | |
614 if(gasID >= 10) | |
615 text[6+i] += gasID - 10; | |
616 else | |
617 text[6+i] += gasID; | |
618 write_topline(text); | |
619 | |
620 text[1] = 0; | |
621 text[0] = TXT_First; | |
622 write_field_on_off(StMOG_First, 30, 400, ME_Y_LINE1, &FontT48, text, first); | |
623 | |
624 text[0] = TXT_Deco; | |
625 write_field_on_off(StMOG_Deco, 30, 400, ME_Y_LINE2, &FontT48, text, deco); | |
626 | |
627 text[0] = TXT_Travel; | |
628 write_field_on_off(StMOG_Travel, 30, 400, ME_Y_LINE3, &FontT48, text, travel); | |
629 | |
630 text[0] = TXT_Inactive; | |
631 write_field_on_off(StMOG_Inactive, 30, 400, ME_Y_LINE4, &FontT48, text, inactive); | |
632 | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
633 #ifdef ENABLE_UNUSED_GAS_HIDING |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
634 text[0] = TXT_Off; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
635 write_field_on_off(StMOG_Off, 30, 400, ME_Y_LINE5, &FontT48, text, off); |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
636 #endif |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
637 |
38 | 638 setEvent(StMOG_First, (uint32_t)OnAction_First); |
639 setEvent(StMOG_Deco, (uint32_t)OnAction_Deco); | |
640 setEvent(StMOG_Travel, (uint32_t)OnAction_Travel); | |
641 setEvent(StMOG_Inactive, (uint32_t)OnAction_Inactive); | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
642 #ifdef ENABLE_UNUSED_GAS_HIDING |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
643 setEvent(StMOG_Off, (uint32_t)OnAction_Off); |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
644 #endif |
38 | 645 |
646 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
647 } | |
648 | |
649 uint8_t OnAction_GasType(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
650 { | |
651 openEdit_GasType(); | |
652 return UNSPECIFIC_RETURN; | |
653 } | |
654 | |
655 uint8_t OnAction_Mix(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
656 { | |
657 uint8_t digitContentNew; | |
658 uint32_t newOxygen, newHelium; | |
659 | |
660 if(action == ACTION_BUTTON_ENTER) | |
661 { | |
662 return digitContent; | |
663 } | |
664 if(action == ACTION_BUTTON_ENTER_FINAL) | |
665 { | |
666 evaluateNewString(editId, &newOxygen, &newHelium, 0, 0); | |
667 | |
668 if(newOxygen < 5) | |
669 newOxygen = 5; | |
670 if(newOxygen == 99) | |
671 newOxygen = 100; | |
672 if(newHelium > 95) | |
673 newHelium = 95; | |
674 if((newOxygen + newHelium) > 100) | |
675 newOxygen = 100 - newHelium; | |
676 | |
677 editGasPage.pGasLine[editGasPage.gasID].oxygen_percentage = newOxygen; | |
678 editGasPage.pGasLine[editGasPage.gasID].helium_percentage = newHelium; | |
679 editGasPage.mod = calc_MOD(editGasPage.gasID); | |
680 | |
681 if(newOxygen == 100) | |
682 newOxygen = 99; | |
683 | |
684 tMenuEdit_newInput(editId, newOxygen, newHelium, 0, 0); | |
685 tMenuEdit_newInput(StMOG_MOD, (uint32_t)unit_depth_integer(editGasPage.mod), 0, 0, 0); | |
686 | |
687 return UPDATE_DIVESETTINGS; | |
688 } | |
689 if(action == ACTION_BUTTON_NEXT) | |
690 { | |
691 digitContentNew = digitContent + 1; | |
692 if(digitContentNew > '9') | |
693 digitContentNew = '0'; | |
694 return digitContentNew; | |
695 } | |
696 if(action == ACTION_BUTTON_BACK) | |
697 { | |
698 digitContentNew = digitContent - 1; | |
699 if(digitContentNew < '0') | |
700 digitContentNew = '9'; | |
701 return digitContentNew; | |
702 } | |
703 | |
704 return UNSPECIFIC_RETURN; | |
705 } | |
706 | |
707 /* | |
708 uint8_t OnAction_DefaultMix(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
709 { | |
710 uint32_t newOxygen, newHelium; | |
711 uint8_t depthDEFAULT; | |
712 char text[32]; | |
713 | |
714 newOxygen = 21; | |
715 newHelium = 0; | |
716 | |
717 editGasPage.pGasLine[editGasPage.gasID].oxygen_percentage = newOxygen; | |
718 editGasPage.pGasLine[editGasPage.gasID].helium_percentage = newHelium; | |
719 | |
720 tMenuEdit_newInput(StMOG_Mix, newOxygen, newHelium, 0, 0); | |
721 | |
722 depthDEFAULT = calc_MOD(editGasPage.gasID); | |
723 create_text_with_u8(text, "", depthDEFAULT, "m MOD"); | |
724 tMenuEdit_newButtonText(StMOG_DefaultDepth, text); | |
725 | |
726 return UPDATE_DIVESETTINGS; | |
727 } | |
728 | |
729 uint8_t OnAction_ToggleDepth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
730 { | |
731 uint8_t depth; | |
732 uint32_t newDefaultDepth; | |
733 char text[32]; | |
734 | |
735 if(editGasPage.depth_mode == 0) | |
736 { | |
737 editGasPage.depth_mode = 1; | |
738 depth = editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel; | |
739 newDefaultDepth = calc_MinOD(editGasPage.gasID); | |
740 create_text_with_u8(text, "", newDefaultDepth, "m Min"); | |
741 } | |
742 else | |
743 { | |
744 editGasPage.depth_mode = 0; | |
745 depth = editGasPage.pGasLine[editGasPage.gasID].depth_meter; | |
746 newDefaultDepth = calc_MOD(editGasPage.gasID); | |
747 create_text_with_u8(text, "", newDefaultDepth, "m MOD"); | |
748 } | |
749 tMenuEdit_newInput(StMOG_Depth, (uint32_t)depth, 0, 0, 0); | |
750 tMenuEdit_newButtonText(StMOG_DefaultDepth, text); | |
751 | |
752 return UNSPECIFIC_RETURN; | |
753 } | |
754 | |
755 | |
756 uint8_t OnAction_Depth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
757 { | |
758 uint8_t digitContentNew; | |
759 uint32_t newDepth; | |
760 | |
761 if(action == ACTION_BUTTON_ENTER) | |
762 { | |
763 return digitContent; | |
764 } | |
765 if(action == ACTION_BUTTON_ENTER_FINAL) | |
766 { | |
767 evaluateNewString(editId, &newDepth, 0, 0, 0); | |
768 if(newDepth > 255) | |
769 newDepth = 255; | |
770 if(editGasPage.depth_mode == 0) | |
771 editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth; | |
772 else | |
773 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = newDepth; | |
774 tMenuEdit_newInput(editId, newDepth, 0, 0, 0); | |
775 return UPDATE_DIVESETTINGS; | |
776 } | |
777 if(action == ACTION_BUTTON_NEXT) | |
778 { | |
779 digitContentNew = digitContent + 1; | |
780 if(digitContentNew > '9') | |
781 digitContentNew = '0'; | |
782 return digitContentNew; | |
783 } | |
784 if(action == ACTION_BUTTON_BACK) | |
785 { | |
786 digitContentNew = digitContent - 1; | |
787 if(digitContentNew < '0') | |
788 digitContentNew = '9'; | |
789 return digitContentNew; | |
790 } | |
791 | |
792 return UNSPECIFIC_RETURN; | |
793 } | |
794 | |
795 | |
796 uint8_t OnAction_DefaultDepth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
797 { | |
798 uint32_t newDepth; | |
799 | |
800 if(editGasPage.depth_mode == 0) | |
801 { | |
802 newDepth = calc_MOD(editGasPage.gasID); | |
803 editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth; | |
804 } | |
805 else | |
806 { | |
807 newDepth = calc_MinOD(editGasPage.gasID); | |
808 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = newDepth; | |
809 } | |
810 | |
811 tMenuEdit_newInput(StMOG_Depth, newDepth, 0, 0, 0); | |
812 | |
813 return UPDATE_DIVESETTINGS; | |
814 } | |
815 | |
816 | |
817 uint8_t OnAction_Active(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
818 { | |
819 uint8_t active, first; | |
820 | |
821 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first; | |
822 | |
823 if(first) | |
824 return UNSPECIFIC_RETURN; | |
825 | |
826 active = editGasPage.pGasLine[editGasPage.gasID].note.ub.active; | |
827 | |
828 if(active) | |
829 { | |
830 active = 0; | |
831 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 0; | |
832 } | |
833 else | |
834 { | |
835 active = 1; | |
836 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; | |
837 } | |
838 tMenuEdit_set_on_off(editId, active); | |
839 | |
840 return UPDATE_DIVESETTINGS; | |
841 } | |
842 */ | |
843 | |
844 | |
845 uint8_t OnAction_First(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
846 { | |
847 uint8_t first, i, gasOne; | |
848 | |
849 if(editGasPage.ccr) | |
850 gasOne = 1 + NUM_OFFSET_DILUENT; | |
851 else | |
852 gasOne = 1; | |
853 | |
854 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first; | |
855 | |
856 if(!first) | |
857 { | |
858 for(i=gasOne;i<NUM_GASES + gasOne;i++) | |
859 { | |
860 if(editGasPage.pGasLine[i].note.ub.first) | |
861 { | |
862 editGasPage.pGasLine[i].note.ub.first = 0; | |
863 editGasPage.pGasLine[i].note.ub.active = 0; | |
864 } | |
865 } | |
866 } | |
867 | |
868 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1; | |
869 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; | |
870 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0; | |
871 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0; | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
872 editGasPage.pGasLine[editGasPage.gasID].note.ub.off = 0; |
38 | 873 editGasPage.pGasLine[editGasPage.gasID].depth_meter = 0; |
874 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0; | |
875 | |
876 tMenuEdit_set_on_off(StMOG_First, 1); | |
877 tMenuEdit_set_on_off(StMOG_Deco, 0); | |
878 tMenuEdit_set_on_off(StMOG_Travel, 0); | |
879 tMenuEdit_set_on_off(StMOG_Inactive, 0); | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
880 #ifdef ENABLE_UNUSED_GAS_HIDING |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
881 tMenuEdit_set_on_off(StMOG_Off, 0); |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
882 #endif |
38 | 883 |
884 if(!first) | |
885 return UPDATE_DIVESETTINGS; | |
886 else | |
887 return UPDATE_AND_EXIT_TO_MENU; | |
888 } | |
889 | |
890 | |
891 uint8_t OnAction_Deco(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
892 { | |
893 uint8_t first, deco, gasOne; | |
894 | |
895 if(editGasPage.ccr) | |
896 gasOne = 1 + NUM_OFFSET_DILUENT; | |
897 else | |
898 gasOne = 1; | |
899 | |
900 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first; | |
901 deco = editGasPage.pGasLine[editGasPage.gasID].note.ub.deco; | |
902 | |
903 if(first) | |
904 { | |
905 if(editGasPage.gasID == gasOne) | |
906 return UNSPECIFIC_RETURN; | |
907 else | |
908 { | |
909 editGasPage.pGasLine[gasOne].note.ub.first = 1; | |
910 editGasPage.pGasLine[gasOne].note.ub.active = 1; | |
911 editGasPage.pGasLine[gasOne].note.ub.deco = 0; | |
912 editGasPage.pGasLine[gasOne].note.ub.travel = 0; | |
913 editGasPage.pGasLine[gasOne].depth_meter = 0; | |
914 editGasPage.pGasLine[gasOne].depth_meter_travel = 0; | |
915 } | |
916 } | |
917 | |
918 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0; | |
919 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; | |
920 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 1; | |
921 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0; | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
922 editGasPage.pGasLine[editGasPage.gasID].note.ub.off = 0; |
38 | 923 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0; |
924 editGasPage.mod = calc_MOD(editGasPage.gasID); | |
925 editGasPage.pGasLine[editGasPage.gasID].depth_meter = editGasPage.mod; | |
926 | |
927 /* | |
928 if(deco) | |
929 { | |
930 editGasPage.pGasLine[editGasPage.gasID].depth_meter = editGasPage.mod; | |
931 tMenuEdit_newInput(StMOG_ChangeDepth, editGasPage.pGasLine[editGasPage.gasID].depth_meter, 0, 0, 0); | |
932 } | |
933 */ | |
934 | |
935 tMenuEdit_set_on_off(StMOG_First, 0); | |
936 tMenuEdit_set_on_off(StMOG_Deco, 1); | |
937 tMenuEdit_set_on_off(StMOG_Travel, 0); | |
938 tMenuEdit_set_on_off(StMOG_Inactive, 0); | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
939 #ifdef ENABLE_UNUSED_GAS_HIDING |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
940 tMenuEdit_set_on_off(StMOG_Off, 0); |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
941 #endif |
38 | 942 |
943 if(!deco) | |
944 return UPDATE_DIVESETTINGS; | |
945 else | |
946 return UPDATE_AND_EXIT_TO_MENU; | |
947 } | |
948 | |
949 | |
950 uint8_t OnAction_Travel(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
951 { | |
952 uint8_t first, travel, gasOne; | |
953 | |
954 if(editGasPage.ccr) | |
955 gasOne = 1 + NUM_OFFSET_DILUENT; | |
956 else | |
957 gasOne = 1; | |
958 | |
959 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first; | |
960 travel = editGasPage.pGasLine[editGasPage.gasID].note.ub.travel; | |
961 | |
962 if(first) | |
963 { | |
964 if(editGasPage.gasID == gasOne) | |
965 return UNSPECIFIC_RETURN; | |
966 else | |
967 { | |
968 editGasPage.pGasLine[gasOne].note.ub.first = 1; | |
969 editGasPage.pGasLine[gasOne].note.ub.active = 1; | |
970 editGasPage.pGasLine[gasOne].note.ub.deco = 0; | |
971 editGasPage.pGasLine[gasOne].note.ub.travel = 0; | |
972 editGasPage.pGasLine[gasOne].depth_meter = 0; | |
973 editGasPage.pGasLine[gasOne].depth_meter_travel = 0; | |
974 } | |
975 } | |
976 | |
977 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0; | |
978 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; | |
979 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0; | |
980 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 1; | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
981 editGasPage.pGasLine[editGasPage.gasID].note.ub.off = 0; |
38 | 982 editGasPage.pGasLine[editGasPage.gasID].depth_meter = 0; |
983 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0; | |
984 | |
985 tMenuEdit_set_on_off(StMOG_First, 0); | |
986 tMenuEdit_set_on_off(StMOG_Deco, 0); | |
987 tMenuEdit_set_on_off(StMOG_Travel, 1); | |
988 tMenuEdit_set_on_off(StMOG_Inactive, 0); | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
989 #ifdef ENABLE_UNUSED_GAS_HIDING |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
990 tMenuEdit_set_on_off(StMOG_Off, 0); |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
991 #endif |
38 | 992 |
993 if(!travel) | |
994 return UPDATE_DIVESETTINGS; | |
995 else | |
996 return UPDATE_AND_EXIT_TO_MENU; | |
997 } | |
998 | |
999 | |
1000 uint8_t OnAction_Inactive(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
1001 { | |
1002 uint8_t first, inactive, gasOne; | |
1003 | |
1004 if(editGasPage.ccr) | |
1005 gasOne = 1 + NUM_OFFSET_DILUENT; | |
1006 else | |
1007 gasOne = 1; | |
1008 | |
1009 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first; | |
1010 | |
1011 if(editGasPage.pGasLine[editGasPage.gasID].note.ub.active) | |
1012 inactive = 0; | |
1013 else | |
1014 inactive = 1; | |
1015 | |
1016 if(first) | |
1017 { | |
1018 if(editGasPage.gasID == gasOne) | |
1019 return UNSPECIFIC_RETURN; | |
1020 else | |
1021 { | |
1022 editGasPage.pGasLine[gasOne].note.ub.first = 1; | |
1023 editGasPage.pGasLine[gasOne].note.ub.active = 1; | |
1024 editGasPage.pGasLine[gasOne].note.ub.deco = 0; | |
1025 editGasPage.pGasLine[gasOne].note.ub.travel = 0; | |
1026 editGasPage.pGasLine[gasOne].depth_meter = 0; | |
1027 editGasPage.pGasLine[gasOne].depth_meter_travel = 0; | |
1028 } | |
1029 } | |
1030 | |
1031 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0; | |
1032 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 0; | |
1033 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0; | |
1034 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0; | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1035 editGasPage.pGasLine[editGasPage.gasID].note.ub.off = 0; |
38 | 1036 |
1037 tMenuEdit_set_on_off(StMOG_First, 0); | |
1038 tMenuEdit_set_on_off(StMOG_Deco, 0); | |
1039 tMenuEdit_set_on_off(StMOG_Travel, 0); | |
1040 tMenuEdit_set_on_off(StMOG_Inactive, 1); | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1041 #ifdef ENABLE_UNUSED_GAS_HIDING |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1042 tMenuEdit_set_on_off(StMOG_Off, 0); |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1043 #endif |
38 | 1044 if(!inactive) |
1045 return UPDATE_DIVESETTINGS; | |
1046 else | |
1047 return UPDATE_AND_EXIT_TO_MENU; | |
1048 } | |
1049 | |
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1050 uint8_t OnAction_Off (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1051 { |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1052 uint8_t first, off, gasOne; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1053 |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1054 if(editGasPage.ccr) |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1055 gasOne = 1 + NUM_OFFSET_DILUENT; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1056 else |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1057 gasOne = 1; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1058 |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1059 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1060 off =editGasPage.pGasLine[editGasPage.gasID].note.ub.off; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1061 |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1062 if(first) |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1063 { |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1064 if(editGasPage.gasID == gasOne) |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1065 return UNSPECIFIC_RETURN; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1066 else |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1067 { |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1068 editGasPage.pGasLine[gasOne].note.ub.first = 1; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1069 editGasPage.pGasLine[gasOne].note.ub.active = 1; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1070 editGasPage.pGasLine[gasOne].note.ub.deco = 0; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1071 editGasPage.pGasLine[gasOne].note.ub.travel = 0; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1072 editGasPage.pGasLine[gasOne].depth_meter = 0; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1073 editGasPage.pGasLine[gasOne].depth_meter_travel = 0; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1074 } |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1075 } |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1076 |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1077 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1078 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 0; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1079 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1080 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1081 editGasPage.pGasLine[editGasPage.gasID].note.ub.off = 1; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1082 |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1083 tMenuEdit_set_on_off(StMOG_First, 0); |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1084 tMenuEdit_set_on_off(StMOG_Deco, 0); |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1085 tMenuEdit_set_on_off(StMOG_Travel, 0); |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1086 tMenuEdit_set_on_off(StMOG_Inactive, 0); |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1087 #ifdef ENABLE_UNUSED_GAS_HIDING |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1088 tMenuEdit_set_on_off(StMOG_Off, 1); |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1089 #endif |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1090 if(!off) |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1091 return UPDATE_DIVESETTINGS; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1092 else |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1093 return UPDATE_AND_EXIT_TO_MENU; |
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
1094 } |
38 | 1095 |
1096 uint8_t OnAction_SetToMOD (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
1097 { | |
1098 uint8_t newChangeDepth = editGasPage.mod; | |
1099 | |
830
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1100 if(editGasPage.pGasLine[editGasPage.gasID].note.ub.travel) |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1101 { |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1102 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel= newChangeDepth; |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1103 } |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1104 else |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1105 { |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1106 editGasPage.pGasLine[editGasPage.gasID].depth_meter = newChangeDepth; |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1107 } |
38 | 1108 tMenuEdit_newInput(StMOG_ChangeDepth, unit_depth_integer(newChangeDepth), 0, 0, 0); |
1109 | |
1110 return UPDATE_DIVESETTINGS; | |
1111 } | |
830
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1112 |
38 | 1113 uint8_t OnAction_ChangeDepth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
1114 { | |
1115 uint8_t digitContentNew; | |
1116 uint32_t newDepth; | |
1117 | |
1118 if(action == ACTION_BUTTON_ENTER) | |
1119 { | |
1120 return digitContent; | |
1121 } | |
1122 if(action == ACTION_BUTTON_ENTER_FINAL) | |
1123 { | |
1124 evaluateNewString(editId, &newDepth, 0, 0, 0); | |
1125 if(settingsGetPointer()->nonMetricalSystem != 0) // new hw 170703 | |
1126 { | |
1127 newDepth += 2; // f�r rundung | |
1128 newDepth = (newDepth * 3) / 10; | |
1129 } | |
1130 if(newDepth > 255) | |
1131 newDepth = 255; | |
830
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1132 |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1133 if(editGasPage.pGasLine[editGasPage.gasID].note.ub.travel) |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1134 { |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1135 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = newDepth; |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1136 } |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1137 else |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1138 { |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1139 editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth; |
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
773
diff
changeset
|
1140 } |
38 | 1141 tMenuEdit_newInput(editId, unit_depth_integer(newDepth), 0, 0, 0); |
1142 return UPDATE_DIVESETTINGS; | |
1143 } | |
1144 if(action == ACTION_BUTTON_NEXT) | |
1145 { | |
1146 digitContentNew = digitContent + 1; | |
1147 if(digitContentNew > '9') | |
1148 digitContentNew = '0'; | |
1149 return digitContentNew; | |
1150 } | |
1151 if(action == ACTION_BUTTON_BACK) | |
1152 { | |
1153 digitContentNew = digitContent - 1; | |
1154 if(digitContentNew < '0') | |
1155 digitContentNew = '9'; | |
1156 return digitContentNew; | |
1157 } | |
1158 | |
1159 return UNSPECIFIC_RETURN; | |
1160 } | |
1161 | |
1162 | |
1163 uint8_t OnAction_BottleSize (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
1164 { | |
1165 int8_t digitContentNew; | |
1166 uint32_t newBottleSize; | |
1167 // const uint8_t validSize = {4,7,8,10,12,15,16,17,20,24,30,40,255}; | |
1168 const uint8_t validSize[] = {40,30,24,20,17,16,15,12,10,8,7,4,0}; | |
1169 | |
1170 if(action == ACTION_BUTTON_ENTER) | |
1171 { | |
1172 return digitContent; | |
1173 } | |
1174 if(action == ACTION_BUTTON_ENTER_FINAL) | |
1175 { | |
1176 evaluateNewString(editId, &newBottleSize, 0, 0, 0); | |
1177 | |
1178 if(newBottleSize > validSize[0]) | |
1179 newBottleSize = validSize[0]; | |
1180 | |
1181 editGasPage.pGasLine[editGasPage.gasID].bottle_size_liter = newBottleSize; | |
1182 | |
1183 tMenuEdit_newInput(editId, newBottleSize, 0, 0, 0); | |
1184 return UPDATE_DIVESETTINGS; | |
1185 } | |
1186 if(action == ACTION_BUTTON_NEXT) | |
1187 { | |
1188 // new here for ease of comparison | |
1189 digitContentNew = digitContent - '0'; | |
1190 | |
1191 if(digitContentNew > 0) | |
1192 { | |
1193 int i = 0; | |
1194 while(digitContentNew < validSize[i]) | |
1195 { | |
1196 i++; | |
1197 } | |
1198 if(i == 0) | |
1199 digitContentNew = 0; // off | |
1200 else | |
1201 digitContentNew = validSize[i-1]; | |
1202 } | |
1203 else | |
1204 { | |
1205 int i = 0; | |
1206 while(validSize[i] != 0) | |
1207 i++; | |
1208 digitContentNew = validSize[i-1]; // smallest tank | |
1209 } | |
1210 digitContentNew += '0'; | |
1211 return digitContentNew; | |
1212 } | |
1213 if(action == ACTION_BUTTON_BACK) | |
1214 { | |
1215 // new here for ease of comparison | |
1216 digitContentNew = digitContent - '0'; | |
1217 if(digitContentNew > 0) | |
1218 { | |
1219 int i = 0; | |
1220 while(digitContentNew < validSize[i]) | |
1221 { | |
1222 i++; | |
1223 } | |
1224 if(validSize[i] == 0) | |
1225 digitContentNew = 0; // off | |
1226 else if(validSize[i+1] == 0) | |
1227 digitContentNew = 0; // off | |
1228 else | |
1229 digitContentNew = validSize[i+1]; | |
1230 } | |
1231 else | |
1232 { | |
1233 digitContentNew = validSize[0]; | |
1234 } | |
1235 digitContentNew += '0'; | |
1236 | |
1237 return digitContentNew; | |
1238 } | |
1239 return EXIT_TO_MENU; | |
1240 } | |
1241 | |
1242 | |
1243 /* Private functions ---------------------------------------------------------*/ | |
1244 | |
1245 | |
1246 void create_text_with_u8(char *text, const char *text1, uint8_t inputU8, const char *text2) | |
1247 { | |
1248 uint8_t digit1, digit2, digit3, count; | |
1249 | |
1250 count = 0; | |
1251 | |
1252 if(*text1) | |
1253 { | |
1254 strcpy(&text[count], text1); | |
1255 count = strlen(text1); | |
1256 } | |
1257 | |
1258 digit1 = inputU8 / 100; | |
1259 inputU8 -= digit1 * 100; | |
1260 digit2 = inputU8 / 10; | |
1261 inputU8 -= digit2 * 10; | |
1262 digit3 = inputU8; | |
1263 if(digit1) | |
1264 text[count++] = '0' + digit1; | |
1265 if(count || digit2) | |
1266 text[count++] = '0' + digit2; | |
1267 text[count++] = '0' + digit3; | |
1268 | |
1269 if(*text2) | |
1270 { | |
1271 strcpy(&text[count], text2); | |
1272 } | |
1273 } |