Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditGasOC.c @ 319:d8e86af78474 fix-version
bugfix: correct packed main version number in dive header
This fixes a rather mysterious bug. Users report that up to 1.3.5 beta,
a correct version number is shown in libdivecomputer based
applications (like in Subsurface, in the extra data tab). Careful
examining the code in both libdivecomputer and the firmware shows
a subtle error in the bit mask and shift operation to pack a full
X.Y.Z.beta version number in 2 bytes (as is available in the
dive header) in the firmware end (as the libdivecomputer code
looks sane, assuming this is the right way to pack things).
Likely, this bug crept in in the conversion from the closed
source Keil period into the open source GCC setup of
the code base. So its impossible to document the exact
history of this problem here.
Further notice that the main version number is only 1 of 3 version
numbers, denoting the full version of the firmware (besides Font
and RTE).
Finally notice that this way of packing is limited to 2^5 bits
(decimal 32), so we could easily build a 1.4.21, but not a
1.4.55.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Wed, 19 Jun 2019 14:31:50 +0200 |
parents | ba229a012ac7 |
children | 3f09b283d993 |
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 #define MAX_SENDER_AT_ONCE 5 | |
48 | |
49 /* Private variables ---------------------------------------------------------*/ | |
50 SEditGasPage editGasPage; | |
51 | |
52 uint16_t wirelessSender[MAX_SENDER_AT_ONCE]; | |
53 | |
54 /* Private function prototypes -----------------------------------------------*/ | |
55 void create_text_with_u8(char *text, const char *text1, uint8_t inputU8, const char *text2); | |
56 | |
57 void openEdit_Gas(uint8_t line, uint8_t ccr); | |
58 void openEdit_GasType(void); | |
59 void openEdit_Wireless(void); | |
60 | |
61 void openEdit_DiveGasSelect(uint8_t line, uint8_t ccr); | |
62 void openEdit_SpecialDiveGasMenu(uint8_t ccr); | |
63 void openEdit_DiveGasSelect_Subroutine(uint8_t line, uint8_t ccr); | |
64 | |
65 void tMEGas_check_switch_to_bailout(void); | |
66 | |
67 /* Announced function prototypes -----------------------------------------------*/ | |
68 uint8_t OnAction_Mix (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
69 uint8_t OnAction_GasType (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
70 uint8_t OnAction_ChangeDepth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
71 uint8_t OnAction_SetToMOD (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
72 uint8_t OnAction_BottleSize (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
73 uint8_t OnAction_Wireless (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
74 | |
75 uint8_t OnAction_First (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
76 uint8_t OnAction_Deco (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
77 uint8_t OnAction_Travel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
78 uint8_t OnAction_Inactive (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
79 | |
80 uint8_t OnAction_WirelessID (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
81 uint8_t OnAction_NoWireless (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
82 | |
83 uint8_t OnAction_DM_Active (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
84 uint8_t OnAction_DM_Mix (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
85 | |
86 /* | |
87 uint8_t OnAction_DefaultMix (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
88 uint8_t OnAction_ToggleDepth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
89 uint8_t OnAction_ToggleDefault (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
90 uint8_t OnAction_DefaultDepth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
91 */ | |
92 | |
93 /* Exported functions --------------------------------------------------------*/ | |
94 | |
95 void openEdit_GasCC(uint8_t line) | |
96 { | |
97 if(actual_menu_content == MENU_SURFACE) | |
98 openEdit_Gas(line , 1); | |
99 else | |
100 if(line == 6) | |
101 openEdit_SpecialDiveGasMenu(1); | |
102 else | |
103 openEdit_DiveGasSelect(line, 1); | |
104 } | |
105 | |
106 | |
107 void openEdit_GasOC(uint8_t line) | |
108 { | |
109 if(actual_menu_content == MENU_SURFACE) | |
110 openEdit_Gas(line, 0); | |
111 else | |
112 if(line == 6) | |
113 openEdit_SpecialDiveGasMenu(0); | |
114 else | |
115 openEdit_DiveGasSelect(line, 0); | |
116 } | |
117 | |
118 | |
119 /* dive mode */ | |
120 void openEdit_DiveSelectBetterGas(void) | |
121 { | |
122 uint8_t gasId, ccr; | |
123 | |
124 gasId = actualBetterGasId(); | |
125 ccr = 0; | |
126 if(gasId>5) | |
127 { | |
128 gasId -= 5; | |
129 ccr = 1; | |
130 } | |
131 openEdit_DiveGasSelect_Subroutine(gasId,ccr); | |
132 if(ccr) | |
133 updateSpecificMenu(StMCG); // is this necessary? openEdit_DiveGasSelect_Subroutine has update. hw 151209 | |
134 else | |
135 updateSpecificMenu(StMOG); // is this necessary? openEdit_DiveGasSelect_Subroutine has update. hw 151209 | |
136 } | |
137 | |
138 | |
139 /* select gas in divemode */ | |
140 void openEdit_DiveGasSelect(uint8_t line, uint8_t ccr) | |
141 { | |
142 openEdit_DiveGasSelect_Subroutine(line, ccr); | |
143 if(!ccr) | |
144 tMEGas_check_switch_to_bailout(); | |
145 exitMenuEdit_to_Home_with_Menu_Update(); | |
146 } | |
147 | |
148 | |
149 void openEdit_DiveGasSelect_Subroutine(uint8_t line, uint8_t ccr) | |
150 { | |
151 uint8_t setpoint; | |
152 | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
153 editGasPage.pGasLine = stateUsed->diveSettings.gas; |
38 | 154 |
155 if(ccr) | |
156 { | |
157 editGasPage.gasID = line + NUM_OFFSET_DILUENT; | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
158 setpoint = stateUsed->lifeData.actualGas.setPoint_cbar; |
38 | 159 } |
160 else | |
161 { | |
162 editGasPage.gasID = line; | |
163 setpoint = 0; | |
164 } | |
165 | |
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 { | |
347 uint8_t gasID, oxygen, helium, depthDeco, active, first, depthMOD, deco, travel, inactive;//, bottleSizeLiter;, bottleWirelessStatus; | |
348 //uint16_t bottleWirelessId;//, bottleWirelessIdSmall; | |
349 | |
350 char text[32]; | |
351 char textMOD[32]; | |
352 uint8_t txtptr; | |
353 | |
354 if(line) | |
355 set_globalState_Menu_Line(line); | |
356 else | |
357 set_globalState_Menu_Line(NUM_GASES + 1); | |
358 | |
359 if(ccr) | |
360 resetMenuEdit(CLUT_MenuPageGasCC); | |
361 else | |
362 resetMenuEdit(CLUT_MenuPageGasOC); | |
363 | |
364 if(ccr) | |
365 gasID = line + NUM_OFFSET_DILUENT; | |
366 else | |
367 gasID = line; | |
368 | |
369 editGasPage.ccr = ccr; | |
370 editGasPage.gasID = gasID; | |
371 editGasPage.mod = calc_MOD(gasID); | |
372 | |
373 SSettings *data = settingsGetPointer(); | |
374 editGasPage.pGasLine = data->gas; | |
375 | |
376 oxygen = editGasPage.pGasLine[gasID].oxygen_percentage; | |
377 if(oxygen > 99) | |
378 oxygen = 99; | |
379 helium = editGasPage.pGasLine[gasID].helium_percentage; | |
380 depthDeco = editGasPage.pGasLine[gasID].depth_meter; | |
381 //depthTravel = editGasPage.pGasLine[gasID].depth_meter_travel; | |
382 active = editGasPage.pGasLine[gasID].note.ub.active; | |
383 first = editGasPage.pGasLine[gasID].note.ub.first; | |
384 deco = editGasPage.pGasLine[gasID].note.ub.deco; | |
385 travel = editGasPage.pGasLine[gasID].note.ub.travel; | |
386 | |
387 //bottleSizeLiter = editGasPage.pGasLine[gasID].bottle_size_liter; | |
388 // bottleWirelessStatus = editGasPage.pGasLine[gasID].bottle_wireless_status; | |
389 //bottleWirelessId = editGasPage.pGasLine[gasID].bottle_wireless_id; | |
390 //bottleWirelessIdSmall = bottleWirelessId & 0x0F; | |
391 | |
392 if(active) | |
393 inactive = 0; | |
394 else | |
395 inactive = 1; | |
396 | |
397 depthMOD = editGasPage.mod; | |
398 | |
399 int i = 0; | |
400 if(gasID >= 10) | |
401 { | |
402 i = 1; | |
403 strcpy(text, "\001" "Gas #10 X"); | |
404 } | |
405 else | |
406 strcpy(text, "\001" "Gas #0 X"); | |
407 | |
408 if(ccr) | |
409 text[8+i] = TXT_Diluent_Gas_Edit; | |
410 else | |
411 text[8+i] = TXT_OC_Gas_Edit; | |
412 | |
413 if(gasID >= 10) | |
414 text[6+i] += gasID - 10; | |
415 else | |
416 text[6+i] += gasID; | |
417 | |
418 write_topline(text); | |
419 if(actual_menu_content == MENU_SURFACE) | |
420 { | |
421 write_label_fix( 20, 800, ME_Y_LINE1, &FontT48, TXT_Mix); | |
422 write_field_udigit(StMOG_Mix, 210, 400, ME_Y_LINE1, &FontT48, "##/##", (uint32_t)oxygen, (uint32_t)helium, 0, 0); | |
423 | |
424 | |
425 text[1] = 0; | |
426 if(inactive) | |
427 text[0] = TXT_Inactive; | |
428 else | |
429 if(first) | |
430 text[0] = TXT_First; | |
431 else | |
432 if(deco) | |
433 text[0] = TXT_Deco; | |
434 else | |
435 if(travel) | |
436 text[0] = TXT_Travel; | |
437 else | |
438 text[0] = TXT_Inactive; | |
439 | |
440 write_field_button(StMOG_GasType, 20, 710, ME_Y_LINE2, &FontT48, text); | |
441 | |
442 | |
443 if(deco) | |
444 { | |
445 text[0] = TXT_ChangeDepth; | |
446 text[1] = ' '; | |
447 text[2] = TXT_Deco; | |
448 text[3] = 0; | |
449 write_label_var( 20 ,800, ME_Y_LINE3, &FontT48, text); | |
450 | |
451 textMOD[0] = '#'; | |
452 textMOD[1] = '#'; | |
453 textMOD[2] = '#'; | |
454 textMOD[3] = unit_depth_char1(); | |
455 textMOD[4] = unit_depth_char2(); | |
456 textMOD[5] = 0; | |
457 write_field_udigit(StMOG_ChangeDepth, 600, 710, ME_Y_LINE3, &FontT48,textMOD, (uint32_t)unit_depth_integer(depthDeco), 0, 0, 0); | |
458 | |
459 txtptr = 0; | |
460 text[txtptr++] = TXT_2BYTE; | |
461 text[txtptr++] = TXT2BYTE_SetToMOD; | |
462 text[txtptr++] = 0; | |
463 write_field_button(StMOG_SetToMOD, 20, 710, ME_Y_LINE4, &FontT48,text); | |
464 } | |
465 else | |
466 { | |
467 txtptr = 0; | |
468 text[txtptr++] = '\021'; | |
469 text[txtptr++] = TXT_ChangeDepth; | |
470 text[txtptr++] = ' '; | |
471 text[txtptr++] = TXT_Deco; | |
472 text[txtptr++] = 0; | |
473 write_label_var( 20 ,800, ME_Y_LINE3, &FontT48, text); | |
474 | |
475 txtptr = 0; | |
476 text[txtptr++] = '\021'; | |
477 text[txtptr++] = TXT_2BYTE; | |
478 text[txtptr++] = TXT2BYTE_SetToMOD; | |
479 text[txtptr++] = 0; | |
480 write_label_var( 20 ,800, ME_Y_LINE4, &FontT48, text); | |
481 } | |
482 /* | |
483 txtptr = 0; | |
484 text[txtptr++] = TXT_2BYTE; | |
485 text[txtptr++] = TXT2BYTE_Bottle; | |
486 text[txtptr++] = 0; | |
487 write_label_var( 20 ,800, ME_Y_LINE5, &FontT48, text); | |
488 write_field_2digit(StMOG_Bottle, 600, 710, ME_Y_LINE5, &FontT48,"## ltr", (uint32_t)bottleSizeLiter, 0, 0, 0); | |
489 | |
490 txtptr = 0; | |
491 text[txtptr++] = TXT_2BYTE; | |
492 text[txtptr++] = TXT2BYTE_WirelessSender; | |
493 text[txtptr++] = ' '; | |
494 if(!bottleWirelessId) | |
495 text[txtptr++] = '\021'; | |
496 txtptr += snprintf(&text[txtptr],20,"%u (%04X)",bottleWirelessIdSmall, bottleWirelessId); | |
497 write_field_button(StMOG_Wireless, 20, 710, ME_Y_LINE6, &FontT48, text); | |
498 */ | |
499 stop_cursor_fields(); | |
500 | |
501 textMOD[0] = '#'; | |
502 textMOD[1] = '#'; | |
503 textMOD[2] = '#'; | |
504 textMOD[3] = unit_depth_char1(); | |
505 textMOD[4] = unit_depth_char2(); | |
506 textMOD[5] = ' '; | |
507 textMOD[6] = 'M'; | |
508 textMOD[7] = 'O'; | |
509 textMOD[8] = 'D'; | |
510 textMOD[9] = 0; | |
511 | |
512 write_field_udigit(StMOG_MOD, 401, 780, ME_Y_LINE1, &FontT48, textMOD, (uint32_t)unit_depth_integer(depthMOD), 0, 0, 0); | |
513 // write_field_udigit(StMOG_MOD, 401, 780, ME_Y_LINE1, &FontT48, "###m MOD", (uint32_t)depthMOD, 0, 0, 0); | |
514 | |
515 setEvent(StMOG_Mix, (uint32_t)OnAction_Mix); | |
516 setEvent(StMOG_GasType, (uint32_t)OnAction_GasType); | |
517 | |
518 if(deco) | |
519 { | |
520 setEvent(StMOG_ChangeDepth, (uint32_t)OnAction_ChangeDepth); | |
521 setEvent(StMOG_SetToMOD, (uint32_t)OnAction_SetToMOD); | |
522 } | |
523 /* | |
524 setEvent(StMOG_Bottle, (uint32_t)OnAction_BottleSize); | |
525 setEvent(StMOG_Wireless, (uint32_t)OnAction_Wireless); | |
526 */ | |
527 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
528 } | |
529 } | |
530 | |
531 /* surface mode */ | |
532 void openEdit_GasType(void) | |
533 { | |
534 uint8_t gasID, active, first, deco, travel, inactive; | |
535 char text[32]; | |
536 | |
537 | |
538 if(editGasPage.ccr) | |
539 { | |
540 resetMenuEdit(CLUT_MenuPageGasCC); | |
541 setBackMenu((uint32_t)openEdit_GasCC, editGasPage.gasID - NUM_OFFSET_DILUENT, 2); | |
542 } | |
543 else | |
544 { | |
545 resetMenuEdit(CLUT_MenuPageGasOC); | |
546 setBackMenu((uint32_t)openEdit_GasOC, editGasPage.gasID, 2); | |
547 } | |
548 | |
549 gasID = editGasPage.gasID; | |
550 active = editGasPage.pGasLine[gasID].note.ub.active; | |
551 first = editGasPage.pGasLine[gasID].note.ub.first; | |
552 deco = editGasPage.pGasLine[gasID].note.ub.deco; | |
553 travel = editGasPage.pGasLine[gasID].note.ub.travel; | |
554 | |
555 if(active) | |
556 inactive = 0; | |
557 else | |
558 inactive = 1; | |
559 | |
560 | |
561 /* header */ | |
562 int i = 0; | |
563 if(gasID >= 10) | |
564 { | |
565 i = 1; | |
566 strcpy(text, "\001" "Gas #10 X"); | |
567 } | |
568 else | |
569 strcpy(text, "\001" "Gas #0 X"); | |
570 | |
571 if(editGasPage.ccr) | |
572 text[8+i] = TXT_Diluent_Gas_Edit; | |
573 else | |
574 text[8+i] = TXT_OC_Gas_Edit; | |
575 | |
576 if(gasID >= 10) | |
577 text[6+i] += gasID - 10; | |
578 else | |
579 text[6+i] += gasID; | |
580 write_topline(text); | |
581 | |
582 text[1] = 0; | |
583 text[0] = TXT_First; | |
584 write_field_on_off(StMOG_First, 30, 400, ME_Y_LINE1, &FontT48, text, first); | |
585 | |
586 text[0] = TXT_Deco; | |
587 write_field_on_off(StMOG_Deco, 30, 400, ME_Y_LINE2, &FontT48, text, deco); | |
588 | |
589 text[0] = TXT_Travel; | |
590 write_field_on_off(StMOG_Travel, 30, 400, ME_Y_LINE3, &FontT48, text, travel); | |
591 | |
592 text[0] = TXT_Inactive; | |
593 write_field_on_off(StMOG_Inactive, 30, 400, ME_Y_LINE4, &FontT48, text, inactive); | |
594 | |
595 setEvent(StMOG_First, (uint32_t)OnAction_First); | |
596 setEvent(StMOG_Deco, (uint32_t)OnAction_Deco); | |
597 setEvent(StMOG_Travel, (uint32_t)OnAction_Travel); | |
598 setEvent(StMOG_Inactive, (uint32_t)OnAction_Inactive); | |
599 | |
600 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
601 } | |
602 | |
603 uint8_t OnAction_GasType(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
604 { | |
605 openEdit_GasType(); | |
606 return UNSPECIFIC_RETURN; | |
607 } | |
608 | |
609 void openEdit_Wireless(void) | |
610 { | |
611 uint8_t gasID, wirelessSenderAvailable, isNotMatched, isMatchedWithThis, wirelessSenderActive[MAX_SENDER_AT_ONCE], senderCount, isInList; //, wirelessStatus; | |
612 uint16_t wirelessId, wirelessSenderIdSmall, wirelessIdTemp; | |
613 char text[32]; | |
614 uint8_t txtptr; | |
615 | |
616 if(editGasPage.ccr) | |
617 { | |
618 resetMenuEdit(CLUT_MenuPageGasCC); | |
619 setBackMenu((uint32_t)openEdit_GasCC, editGasPage.gasID - NUM_OFFSET_DILUENT, 5); | |
620 } | |
621 else | |
622 { | |
623 resetMenuEdit(CLUT_MenuPageGasOC); | |
624 setBackMenu((uint32_t)openEdit_GasOC, editGasPage.gasID, 5); | |
625 } | |
626 | |
627 gasID = editGasPage.gasID; | |
628 wirelessId = editGasPage.pGasLine[gasID].bottle_wireless_id; | |
629 // wirelessStatus = editGasPage.pGasLine[gasID].bottle_wireless_status; | |
630 | |
631 | |
632 /* header */ | |
633 int i = 0; | |
634 if(gasID >= 10) | |
635 { | |
636 i = 1; | |
637 strcpy(text, "\001" "Gas #10 X"); | |
638 } | |
639 else | |
640 strcpy(text, "\001" "Gas #0 X"); | |
641 | |
642 if(editGasPage.ccr) | |
643 text[8+i] = TXT_Diluent_Gas_Edit; | |
644 else | |
645 text[8+i] = TXT_OC_Gas_Edit; | |
646 | |
647 if(gasID >= 10) | |
648 text[6+i] += gasID - 10; | |
649 else | |
650 text[6+i] += gasID; | |
651 write_topline(text); | |
652 | |
653 senderCount = 0; | |
654 wirelessSenderAvailable = 0; | |
655 if(wirelessId) | |
656 { | |
657 wirelessSender[senderCount] = wirelessId; | |
658 wirelessSenderActive[senderCount] = 0; | |
659 wirelessSenderAvailable++; | |
660 senderCount++; | |
661 } | |
662 | |
663 for(int i=0;i<4;i++) | |
664 { | |
665 if((stateUsed->lifeData.wireless_data[i].ageInMilliSeconds) && (stateUsed->lifeData.wireless_data[i].ageInMilliSeconds <= 60000) && ((stateUsed->lifeData.wireless_data[i].data[1] & 0x0F) != 0)) | |
666 { | |
667 wirelessIdTemp = stateUsed->lifeData.wireless_data[i].data[0] * 256; | |
668 wirelessIdTemp += stateUsed->lifeData.wireless_data[i].data[1]; | |
669 if(wirelessId && (wirelessId == wirelessIdTemp)) | |
670 wirelessSenderActive[0] = 1; | |
671 else | |
672 { | |
673 isInList = 0; | |
674 for(int j=0;j<wirelessSenderAvailable;j++) | |
675 { | |
676 if(wirelessSender[j] == wirelessIdTemp) | |
677 { | |
678 isInList = 1; | |
679 break; | |
680 } | |
681 } | |
682 if(!isInList) | |
683 { | |
684 wirelessSender[senderCount] = wirelessIdTemp; | |
685 wirelessSenderActive[senderCount] = 1; | |
686 wirelessSenderAvailable++; | |
687 senderCount++; | |
688 } | |
689 } | |
690 } | |
691 } | |
692 | |
693 if(wirelessSenderAvailable > MAX_SENDER_AT_ONCE) | |
694 wirelessSenderAvailable = MAX_SENDER_AT_ONCE; | |
695 | |
696 isNotMatched = 1; | |
697 | |
698 for(int i=0;i<wirelessSenderAvailable;i++) | |
699 { | |
700 wirelessSenderIdSmall = wirelessSender[i] & 0x0F; | |
701 | |
702 txtptr = 0; | |
703 if(!wirelessSenderActive[i]) | |
704 text[txtptr++] = '\021'; | |
705 txtptr += snprintf(&text[txtptr],10,"%u (%04X)",wirelessSenderIdSmall, wirelessSender[i]); | |
706 | |
707 if(wirelessId == wirelessSender[i]) | |
708 { | |
709 isMatchedWithThis = 1; | |
710 isNotMatched = 0; | |
711 } | |
712 else | |
713 { | |
714 isMatchedWithThis = 0; | |
715 for(int j=1; j <= 2*NUM_GASES; j++) | |
716 { | |
717 if((gasID != j) && (settingsGetPointer()->gas[j].bottle_wireless_id == wirelessSender[i])) | |
718 { | |
719 txtptr += snprintf(&text[txtptr],20," used by Gas #%i",i); | |
720 break; | |
721 } | |
722 } | |
723 } | |
724 write_field_on_off(StMOG_Transmitter1 + i, 30, 710, ME_Y_LINE1 + (i * ME_Y_LINE_STEP), &FontT48, text, isMatchedWithThis); | |
725 } | |
726 | |
727 | |
728 txtptr = 0; | |
729 text[txtptr++] = TXT_2BYTE; | |
730 text[txtptr++] = TXT2BYTE_WirelessDisconnect; | |
731 text[txtptr++] = 0; | |
732 write_field_on_off(StMOG_NoTransmitter, 30, 400, ME_Y_LINE6, &FontT48, text, isNotMatched); | |
733 | |
734 // setEvent has to be _after_ all fields are written | |
735 for(int i=0;i<wirelessSenderAvailable;i++) | |
736 setEvent(StMOG_Transmitter1 + i, (uint32_t)OnAction_WirelessID); | |
737 | |
738 setEvent(StMOG_NoTransmitter, (uint32_t)OnAction_NoWireless); | |
739 } | |
740 | |
741 | |
742 uint8_t OnAction_Wireless(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
743 { | |
744 openEdit_Wireless(); | |
745 return UNSPECIFIC_RETURN; | |
746 } | |
747 | |
748 | |
749 uint8_t OnAction_WirelessID (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
750 { | |
751 if((editId < StMOG_Transmitter1) || (editId > StMOG_Transmitter5)) | |
752 return UNSPECIFIC_RETURN; | |
753 | |
754 uint8_t line, isMatched; | |
755 | |
756 line = editId - StMOG_Transmitter1; | |
757 | |
758 | |
759 if(editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_id == wirelessSender[line]) | |
760 isMatched = 1; | |
761 else | |
762 isMatched = 0; | |
763 | |
764 editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_id = wirelessSender[line]; | |
765 // editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_status = 0; | |
766 | |
767 for(int i=0;i<5;i++) | |
768 { | |
769 if((StMOG_Transmitter1 + i) != editId) | |
770 tMenuEdit_set_on_off(StMOG_Transmitter1 + i, 0); | |
771 } | |
772 tMenuEdit_set_on_off(editId, 1); | |
773 tMenuEdit_set_on_off(StMOG_NoTransmitter, 0); | |
774 | |
775 if(!isMatched) | |
776 return UPDATE_DIVESETTINGS; | |
777 else | |
778 return UPDATE_AND_EXIT_TO_MENU; | |
779 } | |
780 | |
781 | |
782 uint8_t OnAction_NoWireless (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
783 { | |
784 uint8_t isNotMatched; | |
785 | |
786 if(editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_id == 0) | |
787 isNotMatched = 1; | |
788 else | |
789 isNotMatched = 1; | |
790 | |
791 editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_id = 0; | |
792 // editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_status = 0; | |
793 | |
794 tMenuEdit_set_on_off(StMOG_Transmitter1, 0); | |
795 tMenuEdit_set_on_off(StMOG_Transmitter2, 0); | |
796 tMenuEdit_set_on_off(StMOG_Transmitter3, 0); | |
797 tMenuEdit_set_on_off(StMOG_Transmitter4, 0); | |
798 tMenuEdit_set_on_off(StMOG_Transmitter5, 0); | |
799 tMenuEdit_set_on_off(StMOG_NoTransmitter, 1); | |
800 | |
801 if(!isNotMatched) | |
802 return UPDATE_DIVESETTINGS; | |
803 else | |
804 return UPDATE_AND_EXIT_TO_MENU; | |
805 } | |
806 | |
807 | |
808 uint8_t OnAction_Mix(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
809 { | |
810 uint8_t digitContentNew; | |
811 uint32_t newOxygen, newHelium; | |
812 | |
813 if(action == ACTION_BUTTON_ENTER) | |
814 { | |
815 return digitContent; | |
816 } | |
817 if(action == ACTION_BUTTON_ENTER_FINAL) | |
818 { | |
819 evaluateNewString(editId, &newOxygen, &newHelium, 0, 0); | |
820 | |
821 if(newOxygen < 5) | |
822 newOxygen = 5; | |
823 if(newOxygen == 99) | |
824 newOxygen = 100; | |
825 if(newHelium > 95) | |
826 newHelium = 95; | |
827 if((newOxygen + newHelium) > 100) | |
828 newOxygen = 100 - newHelium; | |
829 | |
830 editGasPage.pGasLine[editGasPage.gasID].oxygen_percentage = newOxygen; | |
831 editGasPage.pGasLine[editGasPage.gasID].helium_percentage = newHelium; | |
832 editGasPage.mod = calc_MOD(editGasPage.gasID); | |
833 | |
834 if(newOxygen == 100) | |
835 newOxygen = 99; | |
836 | |
837 tMenuEdit_newInput(editId, newOxygen, newHelium, 0, 0); | |
838 tMenuEdit_newInput(StMOG_MOD, (uint32_t)unit_depth_integer(editGasPage.mod), 0, 0, 0); | |
839 | |
840 return UPDATE_DIVESETTINGS; | |
841 } | |
842 if(action == ACTION_BUTTON_NEXT) | |
843 { | |
844 digitContentNew = digitContent + 1; | |
845 if(digitContentNew > '9') | |
846 digitContentNew = '0'; | |
847 return digitContentNew; | |
848 } | |
849 if(action == ACTION_BUTTON_BACK) | |
850 { | |
851 digitContentNew = digitContent - 1; | |
852 if(digitContentNew < '0') | |
853 digitContentNew = '9'; | |
854 return digitContentNew; | |
855 } | |
856 | |
857 return UNSPECIFIC_RETURN; | |
858 } | |
859 | |
860 /* | |
861 uint8_t OnAction_DefaultMix(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
862 { | |
863 uint32_t newOxygen, newHelium; | |
864 uint8_t depthDEFAULT; | |
865 char text[32]; | |
866 | |
867 newOxygen = 21; | |
868 newHelium = 0; | |
869 | |
870 editGasPage.pGasLine[editGasPage.gasID].oxygen_percentage = newOxygen; | |
871 editGasPage.pGasLine[editGasPage.gasID].helium_percentage = newHelium; | |
872 | |
873 tMenuEdit_newInput(StMOG_Mix, newOxygen, newHelium, 0, 0); | |
874 | |
875 depthDEFAULT = calc_MOD(editGasPage.gasID); | |
876 create_text_with_u8(text, "", depthDEFAULT, "m MOD"); | |
877 tMenuEdit_newButtonText(StMOG_DefaultDepth, text); | |
878 | |
879 return UPDATE_DIVESETTINGS; | |
880 } | |
881 | |
882 uint8_t OnAction_ToggleDepth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
883 { | |
884 uint8_t depth; | |
885 uint32_t newDefaultDepth; | |
886 char text[32]; | |
887 | |
888 if(editGasPage.depth_mode == 0) | |
889 { | |
890 editGasPage.depth_mode = 1; | |
891 depth = editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel; | |
892 newDefaultDepth = calc_MinOD(editGasPage.gasID); | |
893 create_text_with_u8(text, "", newDefaultDepth, "m Min"); | |
894 } | |
895 else | |
896 { | |
897 editGasPage.depth_mode = 0; | |
898 depth = editGasPage.pGasLine[editGasPage.gasID].depth_meter; | |
899 newDefaultDepth = calc_MOD(editGasPage.gasID); | |
900 create_text_with_u8(text, "", newDefaultDepth, "m MOD"); | |
901 } | |
902 tMenuEdit_newInput(StMOG_Depth, (uint32_t)depth, 0, 0, 0); | |
903 tMenuEdit_newButtonText(StMOG_DefaultDepth, text); | |
904 | |
905 return UNSPECIFIC_RETURN; | |
906 } | |
907 | |
908 | |
909 uint8_t OnAction_Depth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
910 { | |
911 uint8_t digitContentNew; | |
912 uint32_t newDepth; | |
913 | |
914 if(action == ACTION_BUTTON_ENTER) | |
915 { | |
916 return digitContent; | |
917 } | |
918 if(action == ACTION_BUTTON_ENTER_FINAL) | |
919 { | |
920 evaluateNewString(editId, &newDepth, 0, 0, 0); | |
921 if(newDepth > 255) | |
922 newDepth = 255; | |
923 if(editGasPage.depth_mode == 0) | |
924 editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth; | |
925 else | |
926 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = newDepth; | |
927 tMenuEdit_newInput(editId, newDepth, 0, 0, 0); | |
928 return UPDATE_DIVESETTINGS; | |
929 } | |
930 if(action == ACTION_BUTTON_NEXT) | |
931 { | |
932 digitContentNew = digitContent + 1; | |
933 if(digitContentNew > '9') | |
934 digitContentNew = '0'; | |
935 return digitContentNew; | |
936 } | |
937 if(action == ACTION_BUTTON_BACK) | |
938 { | |
939 digitContentNew = digitContent - 1; | |
940 if(digitContentNew < '0') | |
941 digitContentNew = '9'; | |
942 return digitContentNew; | |
943 } | |
944 | |
945 return UNSPECIFIC_RETURN; | |
946 } | |
947 | |
948 | |
949 uint8_t OnAction_DefaultDepth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
950 { | |
951 uint32_t newDepth; | |
952 | |
953 if(editGasPage.depth_mode == 0) | |
954 { | |
955 newDepth = calc_MOD(editGasPage.gasID); | |
956 editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth; | |
957 } | |
958 else | |
959 { | |
960 newDepth = calc_MinOD(editGasPage.gasID); | |
961 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = newDepth; | |
962 } | |
963 | |
964 tMenuEdit_newInput(StMOG_Depth, newDepth, 0, 0, 0); | |
965 | |
966 return UPDATE_DIVESETTINGS; | |
967 } | |
968 | |
969 | |
970 uint8_t OnAction_Active(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
971 { | |
972 uint8_t active, first; | |
973 | |
974 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first; | |
975 | |
976 if(first) | |
977 return UNSPECIFIC_RETURN; | |
978 | |
979 active = editGasPage.pGasLine[editGasPage.gasID].note.ub.active; | |
980 | |
981 if(active) | |
982 { | |
983 active = 0; | |
984 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 0; | |
985 } | |
986 else | |
987 { | |
988 active = 1; | |
989 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; | |
990 } | |
991 tMenuEdit_set_on_off(editId, active); | |
992 | |
993 return UPDATE_DIVESETTINGS; | |
994 } | |
995 */ | |
996 | |
997 | |
998 uint8_t OnAction_First(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
999 { | |
1000 uint8_t first, i, gasOne; | |
1001 | |
1002 if(editGasPage.ccr) | |
1003 gasOne = 1 + NUM_OFFSET_DILUENT; | |
1004 else | |
1005 gasOne = 1; | |
1006 | |
1007 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first; | |
1008 | |
1009 if(!first) | |
1010 { | |
1011 for(i=gasOne;i<NUM_GASES + gasOne;i++) | |
1012 { | |
1013 if(editGasPage.pGasLine[i].note.ub.first) | |
1014 { | |
1015 editGasPage.pGasLine[i].note.ub.first = 0; | |
1016 editGasPage.pGasLine[i].note.ub.active = 0; | |
1017 } | |
1018 } | |
1019 } | |
1020 | |
1021 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1; | |
1022 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; | |
1023 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0; | |
1024 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0; | |
1025 editGasPage.pGasLine[editGasPage.gasID].depth_meter = 0; | |
1026 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0; | |
1027 | |
1028 tMenuEdit_set_on_off(StMOG_First, 1); | |
1029 tMenuEdit_set_on_off(StMOG_Deco, 0); | |
1030 tMenuEdit_set_on_off(StMOG_Travel, 0); | |
1031 tMenuEdit_set_on_off(StMOG_Inactive, 0); | |
1032 | |
1033 if(!first) | |
1034 return UPDATE_DIVESETTINGS; | |
1035 else | |
1036 return UPDATE_AND_EXIT_TO_MENU; | |
1037 } | |
1038 | |
1039 | |
1040 uint8_t OnAction_Deco(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
1041 { | |
1042 uint8_t first, deco, gasOne; | |
1043 | |
1044 if(editGasPage.ccr) | |
1045 gasOne = 1 + NUM_OFFSET_DILUENT; | |
1046 else | |
1047 gasOne = 1; | |
1048 | |
1049 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first; | |
1050 deco = editGasPage.pGasLine[editGasPage.gasID].note.ub.deco; | |
1051 | |
1052 if(first) | |
1053 { | |
1054 if(editGasPage.gasID == gasOne) | |
1055 return UNSPECIFIC_RETURN; | |
1056 else | |
1057 { | |
1058 editGasPage.pGasLine[gasOne].note.ub.first = 1; | |
1059 editGasPage.pGasLine[gasOne].note.ub.active = 1; | |
1060 editGasPage.pGasLine[gasOne].note.ub.deco = 0; | |
1061 editGasPage.pGasLine[gasOne].note.ub.travel = 0; | |
1062 editGasPage.pGasLine[gasOne].depth_meter = 0; | |
1063 editGasPage.pGasLine[gasOne].depth_meter_travel = 0; | |
1064 } | |
1065 } | |
1066 | |
1067 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0; | |
1068 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; | |
1069 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 1; | |
1070 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0; | |
1071 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0; | |
1072 editGasPage.mod = calc_MOD(editGasPage.gasID); | |
1073 editGasPage.pGasLine[editGasPage.gasID].depth_meter = editGasPage.mod; | |
1074 | |
1075 /* | |
1076 if(deco) | |
1077 { | |
1078 editGasPage.pGasLine[editGasPage.gasID].depth_meter = editGasPage.mod; | |
1079 tMenuEdit_newInput(StMOG_ChangeDepth, editGasPage.pGasLine[editGasPage.gasID].depth_meter, 0, 0, 0); | |
1080 } | |
1081 */ | |
1082 | |
1083 tMenuEdit_set_on_off(StMOG_First, 0); | |
1084 tMenuEdit_set_on_off(StMOG_Deco, 1); | |
1085 tMenuEdit_set_on_off(StMOG_Travel, 0); | |
1086 tMenuEdit_set_on_off(StMOG_Inactive, 0); | |
1087 | |
1088 if(!deco) | |
1089 return UPDATE_DIVESETTINGS; | |
1090 else | |
1091 return UPDATE_AND_EXIT_TO_MENU; | |
1092 } | |
1093 | |
1094 | |
1095 uint8_t OnAction_Travel(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
1096 { | |
1097 uint8_t first, travel, gasOne; | |
1098 | |
1099 if(editGasPage.ccr) | |
1100 gasOne = 1 + NUM_OFFSET_DILUENT; | |
1101 else | |
1102 gasOne = 1; | |
1103 | |
1104 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first; | |
1105 travel = editGasPage.pGasLine[editGasPage.gasID].note.ub.travel; | |
1106 | |
1107 if(first) | |
1108 { | |
1109 if(editGasPage.gasID == gasOne) | |
1110 return UNSPECIFIC_RETURN; | |
1111 else | |
1112 { | |
1113 editGasPage.pGasLine[gasOne].note.ub.first = 1; | |
1114 editGasPage.pGasLine[gasOne].note.ub.active = 1; | |
1115 editGasPage.pGasLine[gasOne].note.ub.deco = 0; | |
1116 editGasPage.pGasLine[gasOne].note.ub.travel = 0; | |
1117 editGasPage.pGasLine[gasOne].depth_meter = 0; | |
1118 editGasPage.pGasLine[gasOne].depth_meter_travel = 0; | |
1119 } | |
1120 } | |
1121 | |
1122 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0; | |
1123 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1; | |
1124 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0; | |
1125 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 1; | |
1126 editGasPage.pGasLine[editGasPage.gasID].depth_meter = 0; | |
1127 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0; | |
1128 | |
1129 tMenuEdit_set_on_off(StMOG_First, 0); | |
1130 tMenuEdit_set_on_off(StMOG_Deco, 0); | |
1131 tMenuEdit_set_on_off(StMOG_Travel, 1); | |
1132 tMenuEdit_set_on_off(StMOG_Inactive, 0); | |
1133 | |
1134 if(!travel) | |
1135 return UPDATE_DIVESETTINGS; | |
1136 else | |
1137 return UPDATE_AND_EXIT_TO_MENU; | |
1138 } | |
1139 | |
1140 | |
1141 uint8_t OnAction_Inactive(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
1142 { | |
1143 uint8_t first, inactive, gasOne; | |
1144 | |
1145 if(editGasPage.ccr) | |
1146 gasOne = 1 + NUM_OFFSET_DILUENT; | |
1147 else | |
1148 gasOne = 1; | |
1149 | |
1150 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first; | |
1151 | |
1152 if(editGasPage.pGasLine[editGasPage.gasID].note.ub.active) | |
1153 inactive = 0; | |
1154 else | |
1155 inactive = 1; | |
1156 | |
1157 if(first) | |
1158 { | |
1159 if(editGasPage.gasID == gasOne) | |
1160 return UNSPECIFIC_RETURN; | |
1161 else | |
1162 { | |
1163 editGasPage.pGasLine[gasOne].note.ub.first = 1; | |
1164 editGasPage.pGasLine[gasOne].note.ub.active = 1; | |
1165 editGasPage.pGasLine[gasOne].note.ub.deco = 0; | |
1166 editGasPage.pGasLine[gasOne].note.ub.travel = 0; | |
1167 editGasPage.pGasLine[gasOne].depth_meter = 0; | |
1168 editGasPage.pGasLine[gasOne].depth_meter_travel = 0; | |
1169 } | |
1170 } | |
1171 | |
1172 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0; | |
1173 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 0; | |
1174 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0; | |
1175 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0; | |
1176 | |
1177 tMenuEdit_set_on_off(StMOG_First, 0); | |
1178 tMenuEdit_set_on_off(StMOG_Deco, 0); | |
1179 tMenuEdit_set_on_off(StMOG_Travel, 0); | |
1180 tMenuEdit_set_on_off(StMOG_Inactive, 1); | |
1181 | |
1182 if(!inactive) | |
1183 return UPDATE_DIVESETTINGS; | |
1184 else | |
1185 return UPDATE_AND_EXIT_TO_MENU; | |
1186 } | |
1187 | |
1188 | |
1189 uint8_t OnAction_SetToMOD (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
1190 { | |
1191 uint8_t newChangeDepth = editGasPage.mod; | |
1192 | |
1193 editGasPage.pGasLine[editGasPage.gasID].depth_meter = newChangeDepth; | |
1194 tMenuEdit_newInput(StMOG_ChangeDepth, unit_depth_integer(newChangeDepth), 0, 0, 0); | |
1195 | |
1196 return UPDATE_DIVESETTINGS; | |
1197 } | |
1198 | |
1199 | |
1200 uint8_t OnAction_ChangeDepth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
1201 { | |
1202 uint8_t digitContentNew; | |
1203 uint32_t newDepth; | |
1204 | |
1205 if(action == ACTION_BUTTON_ENTER) | |
1206 { | |
1207 return digitContent; | |
1208 } | |
1209 if(action == ACTION_BUTTON_ENTER_FINAL) | |
1210 { | |
1211 evaluateNewString(editId, &newDepth, 0, 0, 0); | |
1212 if(settingsGetPointer()->nonMetricalSystem != 0) // new hw 170703 | |
1213 { | |
1214 newDepth += 2; // f�r rundung | |
1215 newDepth = (newDepth * 3) / 10; | |
1216 } | |
1217 if(newDepth > 255) | |
1218 newDepth = 255; | |
1219 editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth; | |
1220 tMenuEdit_newInput(editId, unit_depth_integer(newDepth), 0, 0, 0); | |
1221 return UPDATE_DIVESETTINGS; | |
1222 } | |
1223 if(action == ACTION_BUTTON_NEXT) | |
1224 { | |
1225 digitContentNew = digitContent + 1; | |
1226 if(digitContentNew > '9') | |
1227 digitContentNew = '0'; | |
1228 return digitContentNew; | |
1229 } | |
1230 if(action == ACTION_BUTTON_BACK) | |
1231 { | |
1232 digitContentNew = digitContent - 1; | |
1233 if(digitContentNew < '0') | |
1234 digitContentNew = '9'; | |
1235 return digitContentNew; | |
1236 } | |
1237 | |
1238 return UNSPECIFIC_RETURN; | |
1239 } | |
1240 | |
1241 | |
1242 uint8_t OnAction_BottleSize (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
1243 { | |
1244 int8_t digitContentNew; | |
1245 uint32_t newBottleSize; | |
1246 // const uint8_t validSize = {4,7,8,10,12,15,16,17,20,24,30,40,255}; | |
1247 const uint8_t validSize[] = {40,30,24,20,17,16,15,12,10,8,7,4,0}; | |
1248 | |
1249 if(action == ACTION_BUTTON_ENTER) | |
1250 { | |
1251 return digitContent; | |
1252 } | |
1253 if(action == ACTION_BUTTON_ENTER_FINAL) | |
1254 { | |
1255 evaluateNewString(editId, &newBottleSize, 0, 0, 0); | |
1256 | |
1257 if(newBottleSize > validSize[0]) | |
1258 newBottleSize = validSize[0]; | |
1259 | |
1260 editGasPage.pGasLine[editGasPage.gasID].bottle_size_liter = newBottleSize; | |
1261 | |
1262 tMenuEdit_newInput(editId, newBottleSize, 0, 0, 0); | |
1263 return UPDATE_DIVESETTINGS; | |
1264 } | |
1265 if(action == ACTION_BUTTON_NEXT) | |
1266 { | |
1267 // new here for ease of comparison | |
1268 digitContentNew = digitContent - '0'; | |
1269 | |
1270 if(digitContentNew > 0) | |
1271 { | |
1272 int i = 0; | |
1273 while(digitContentNew < validSize[i]) | |
1274 { | |
1275 i++; | |
1276 } | |
1277 if(i == 0) | |
1278 digitContentNew = 0; // off | |
1279 else | |
1280 digitContentNew = validSize[i-1]; | |
1281 } | |
1282 else | |
1283 { | |
1284 int i = 0; | |
1285 while(validSize[i] != 0) | |
1286 i++; | |
1287 digitContentNew = validSize[i-1]; // smallest tank | |
1288 } | |
1289 digitContentNew += '0'; | |
1290 return digitContentNew; | |
1291 } | |
1292 if(action == ACTION_BUTTON_BACK) | |
1293 { | |
1294 // new here for ease of comparison | |
1295 digitContentNew = digitContent - '0'; | |
1296 if(digitContentNew > 0) | |
1297 { | |
1298 int i = 0; | |
1299 while(digitContentNew < validSize[i]) | |
1300 { | |
1301 i++; | |
1302 } | |
1303 if(validSize[i] == 0) | |
1304 digitContentNew = 0; // off | |
1305 else if(validSize[i+1] == 0) | |
1306 digitContentNew = 0; // off | |
1307 else | |
1308 digitContentNew = validSize[i+1]; | |
1309 } | |
1310 else | |
1311 { | |
1312 digitContentNew = validSize[0]; | |
1313 } | |
1314 digitContentNew += '0'; | |
1315 | |
1316 return digitContentNew; | |
1317 } | |
1318 return EXIT_TO_MENU; | |
1319 } | |
1320 | |
1321 | |
1322 /* Private functions ---------------------------------------------------------*/ | |
1323 | |
1324 | |
1325 void create_text_with_u8(char *text, const char *text1, uint8_t inputU8, const char *text2) | |
1326 { | |
1327 uint8_t digit1, digit2, digit3, count; | |
1328 | |
1329 count = 0; | |
1330 | |
1331 if(*text1) | |
1332 { | |
1333 strcpy(&text[count], text1); | |
1334 count = strlen(text1); | |
1335 } | |
1336 | |
1337 digit1 = inputU8 / 100; | |
1338 inputU8 -= digit1 * 100; | |
1339 digit2 = inputU8 / 10; | |
1340 inputU8 -= digit2 * 10; | |
1341 digit3 = inputU8; | |
1342 if(digit1) | |
1343 text[count++] = '0' + digit1; | |
1344 if(count || digit2) | |
1345 text[count++] = '0' + digit2; | |
1346 text[count++] = '0' + digit3; | |
1347 | |
1348 if(*text2) | |
1349 { | |
1350 strcpy(&text[count], text2); | |
1351 } | |
1352 } |