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