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