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 SDiveState * pState;
|
|
152 uint8_t setpoint;
|
|
153
|
|
154 if(actual_menu_content == MENU_DIVE_REAL)
|
|
155 {
|
|
156 pState = stateRealGetPointerWrite();
|
|
157 editGasPage.pGasLine = pState->diveSettings.gas;
|
|
158 }
|
|
159 else
|
|
160 {
|
|
161 pState = stateSimGetPointerWrite();
|
|
162 editGasPage.pGasLine = pState->diveSettings.gas;
|
|
163 }
|
|
164
|
|
165 if(ccr)
|
|
166 {
|
|
167 editGasPage.gasID = line + NUM_OFFSET_DILUENT;
|
|
168 setpoint = pState->lifeData.actualGas.setPoint_cbar;
|
|
169 }
|
|
170 else
|
|
171 {
|
|
172 editGasPage.gasID = line;
|
|
173 setpoint = 0;
|
|
174 }
|
|
175
|
|
176 for(int i=0;i<(1+ (2*NUM_GASES));i++)
|
|
177 editGasPage.pGasLine[i].note.ub.first = 0;
|
|
178
|
|
179 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
|
|
180 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1;
|
|
181 setActualGas_DM(&pState->lifeData,editGasPage.gasID,setpoint);
|
|
182 }
|
|
183
|
|
184 /* extra gas and gas on/off option */
|
|
185 void openEdit_SpecialDiveGasMenu(uint8_t ccr)
|
|
186 {
|
|
187 char text[32];
|
|
188 uint8_t oxygen, helium, gasOffset, textpointer, lineCount, ptrGas;
|
|
189 SDiveState * pState;
|
|
190
|
|
191 if(actual_menu_content == MENU_DIVE_REAL)
|
|
192 {
|
|
193 pState = stateRealGetPointerWrite();
|
|
194 editGasPage.pGasLine = pState->diveSettings.gas;
|
|
195 }
|
|
196 else
|
|
197 {
|
|
198 pState = stateSimGetPointerWrite();
|
|
199 editGasPage.pGasLine = pState->diveSettings.gas;
|
|
200 }
|
|
201 if(ccr)
|
|
202 {
|
|
203 editGasPage.setpoint = pState->lifeData.actualGas.setPoint_cbar;
|
|
204 }
|
|
205 editGasPage.ccr = ccr;
|
|
206
|
|
207 set_globalState_Menu_Line(6);
|
|
208
|
|
209 if(ccr)
|
|
210 resetMenuEdit(CLUT_MenuPageGasCC);
|
|
211 else
|
|
212 resetMenuEdit(CLUT_MenuPageGasOC);
|
|
213
|
|
214 if(ccr)
|
|
215 gasOffset = NUM_OFFSET_DILUENT;
|
|
216 else
|
|
217 gasOffset = 0;
|
|
218
|
|
219
|
|
220 text[0] = '\001';
|
|
221 text[1] = TXT_2BYTE;
|
|
222 if(ccr)
|
|
223 text[2] = TXT2BYTE_SpecialDiveGasMenuCCR;
|
|
224 else
|
|
225 text[2] = TXT2BYTE_SpecialDiveGasMenu;
|
|
226 text[3] = 0;
|
|
227 write_topline(text);
|
|
228
|
|
229 lineCount = 1;
|
|
230
|
|
231
|
|
232 for(int i=1; i<=5; i++)
|
|
233 {
|
|
234 ptrGas = i + gasOffset;
|
|
235 oxygen = stateUsed->diveSettings.gas[ptrGas].oxygen_percentage;
|
|
236 helium = stateUsed->diveSettings.gas[ptrGas].helium_percentage;
|
|
237
|
|
238 if(oxygen == 100)
|
|
239 textpointer = snprintf(text,10,"Oxy");
|
|
240 else
|
|
241 if((oxygen == 21) && (helium == 0))
|
|
242 textpointer = snprintf(text,10,"Air");
|
|
243 else
|
|
244 textpointer = snprintf(text,10,"%02i/%02i",oxygen,helium);
|
|
245
|
|
246 if(editGasPage.pGasLine[ptrGas].note.ub.first)
|
|
247 strcpy(&text[textpointer]," *");
|
|
248
|
|
249 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);
|
|
250 lineCount++;
|
|
251 }
|
|
252
|
|
253 if(!ccr)
|
|
254 {
|
|
255 if(stateUsed->diveSettings.gas[0].note.ub.first)
|
|
256 {
|
|
257 oxygen = stateUsed->diveSettings.gas[0].oxygen_percentage;
|
|
258 helium = stateUsed->diveSettings.gas[0].helium_percentage;
|
|
259 write_field_udigit(StMOG_DM_ExtraMix, 30, 800, ME_Y_LINE6, &FontT48, "##/## Extra Gas *", oxygen, helium, 0, 0);
|
|
260 }
|
|
261 else
|
|
262 {
|
|
263 write_field_udigit(StMOG_DM_ExtraMix, 30, 800, ME_Y_LINE6, &FontT48, "##/## Extra Gas", 0, 0, 0, 0);
|
|
264 }
|
|
265 }
|
|
266
|
|
267 for(int i=1; i<=5; i++)
|
|
268 {
|
|
269 setEvent(StMOG_DM_ActiveBase + i,(uint32_t)OnAction_DM_Active);
|
|
270 }
|
|
271
|
|
272 if(!ccr)
|
|
273 setEvent(StMOG_DM_ExtraMix,(uint32_t)OnAction_DM_Mix);
|
|
274 }
|
|
275
|
|
276
|
|
277 uint8_t OnAction_DM_Active (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
278 {
|
|
279 uint8_t gasOffset, newActive;
|
|
280
|
|
281 if(editGasPage.ccr)
|
|
282 gasOffset = NUM_OFFSET_DILUENT;
|
|
283 else
|
|
284 gasOffset = 0;
|
|
285
|
|
286 editGasPage.gasID = editId + gasOffset - StMOG_DM_ActiveBase;
|
|
287
|
|
288 if(editGasPage.pGasLine[editGasPage.gasID].note.ub.first)
|
|
289 return UNSPECIFIC_RETURN;
|
|
290
|
|
291 if(editGasPage.pGasLine[editGasPage.gasID].note.ub.active)
|
|
292 newActive = 0;
|
|
293 else
|
|
294 newActive = 1;
|
|
295
|
|
296 tMenuEdit_set_on_off(editId, newActive);
|
|
297 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = newActive;
|
|
298
|
|
299 return UNSPECIFIC_RETURN;
|
|
300 }
|
|
301
|
|
302 /* only for OC */
|
|
303 uint8_t OnAction_DM_Mix(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
304 {
|
|
305 uint8_t digitContentNew;
|
|
306 uint32_t newOxygen, newHelium;
|
|
307
|
|
308 if(action == ACTION_BUTTON_ENTER)
|
|
309 {
|
|
310 return digitContent;
|
|
311 }
|
|
312 if(action == ACTION_BUTTON_ENTER_FINAL)
|
|
313 {
|
|
314 evaluateNewString(editId, &newOxygen, &newHelium, 0, 0);
|
|
315
|
|
316 if(newOxygen < 5)
|
|
317 newOxygen = 5;
|
|
318 if(newOxygen == 99)
|
|
319 newOxygen = 100;
|
|
320 if(newHelium > 95)
|
|
321 newHelium = 95;
|
|
322 if((newOxygen + newHelium) > 100)
|
|
323 newOxygen = 100 - newHelium;
|
|
324
|
|
325 SDiveState * pDiveState = 0;
|
|
326
|
|
327 for(int i=1;i<=(2*NUM_GASES);i++)
|
|
328 editGasPage.pGasLine[i].note.ub.first = 0;
|
|
329
|
|
330 if(actual_menu_content == MENU_DIVE_REAL)
|
|
331 pDiveState = stateRealGetPointerWrite();
|
|
332 else
|
|
333 pDiveState = stateSimGetPointerWrite();
|
|
334
|
|
335 setActualGas_ExtraGas(&pDiveState->lifeData, newOxygen, newHelium, 0);
|
|
336 tMEGas_check_switch_to_bailout();
|
|
337 return EXIT_TO_HOME;
|
|
338 }
|
|
339 if(action == ACTION_BUTTON_NEXT)
|
|
340 {
|
|
341 digitContentNew = digitContent + 1;
|
|
342 if(digitContentNew > '9')
|
|
343 digitContentNew = '0';
|
|
344 return digitContentNew;
|
|
345 }
|
|
346 if(action == ACTION_BUTTON_BACK)
|
|
347 {
|
|
348 digitContentNew = digitContent - 1;
|
|
349 if(digitContentNew < '0')
|
|
350 digitContentNew = '9';
|
|
351 return digitContentNew;
|
|
352 }
|
|
353
|
|
354 return UNSPECIFIC_RETURN;
|
|
355 }
|
|
356
|
|
357
|
|
358 void tMEGas_check_switch_to_bailout(void)
|
|
359 {
|
|
360 SDiveState *pState;
|
|
361
|
|
362 if(actual_menu_content == MENU_DIVE_REAL)
|
|
363 pState = stateRealGetPointerWrite();
|
|
364 else
|
|
365 pState = stateSimGetPointerWrite();
|
|
366
|
|
367 if(pState->diveSettings.diveMode == DIVEMODE_CCR)
|
|
368 {
|
|
369 pState->diveSettings.diveMode = DIVEMODE_OC;
|
|
370 block_diluent_page();
|
|
371 }
|
|
372 }
|
|
373
|
|
374
|
|
375 /* surface mode */
|
|
376 void openEdit_Gas(uint8_t line, uint8_t ccr)
|
|
377 {
|
|
378 uint8_t gasID, oxygen, helium, depthDeco, active, first, depthMOD, deco, travel, inactive;//, bottleSizeLiter;, bottleWirelessStatus;
|
|
379 //uint16_t bottleWirelessId;//, bottleWirelessIdSmall;
|
|
380
|
|
381 char text[32];
|
|
382 char textMOD[32];
|
|
383 uint8_t txtptr;
|
|
384
|
|
385 if(line)
|
|
386 set_globalState_Menu_Line(line);
|
|
387 else
|
|
388 set_globalState_Menu_Line(NUM_GASES + 1);
|
|
389
|
|
390 if(ccr)
|
|
391 resetMenuEdit(CLUT_MenuPageGasCC);
|
|
392 else
|
|
393 resetMenuEdit(CLUT_MenuPageGasOC);
|
|
394
|
|
395 if(ccr)
|
|
396 gasID = line + NUM_OFFSET_DILUENT;
|
|
397 else
|
|
398 gasID = line;
|
|
399
|
|
400 editGasPage.ccr = ccr;
|
|
401 editGasPage.gasID = gasID;
|
|
402 editGasPage.mod = calc_MOD(gasID);
|
|
403
|
|
404 SSettings *data = settingsGetPointer();
|
|
405 editGasPage.pGasLine = data->gas;
|
|
406
|
|
407 oxygen = editGasPage.pGasLine[gasID].oxygen_percentage;
|
|
408 if(oxygen > 99)
|
|
409 oxygen = 99;
|
|
410 helium = editGasPage.pGasLine[gasID].helium_percentage;
|
|
411 depthDeco = editGasPage.pGasLine[gasID].depth_meter;
|
|
412 //depthTravel = editGasPage.pGasLine[gasID].depth_meter_travel;
|
|
413 active = editGasPage.pGasLine[gasID].note.ub.active;
|
|
414 first = editGasPage.pGasLine[gasID].note.ub.first;
|
|
415 deco = editGasPage.pGasLine[gasID].note.ub.deco;
|
|
416 travel = editGasPage.pGasLine[gasID].note.ub.travel;
|
|
417
|
|
418 //bottleSizeLiter = editGasPage.pGasLine[gasID].bottle_size_liter;
|
|
419 // bottleWirelessStatus = editGasPage.pGasLine[gasID].bottle_wireless_status;
|
|
420 //bottleWirelessId = editGasPage.pGasLine[gasID].bottle_wireless_id;
|
|
421 //bottleWirelessIdSmall = bottleWirelessId & 0x0F;
|
|
422
|
|
423 if(active)
|
|
424 inactive = 0;
|
|
425 else
|
|
426 inactive = 1;
|
|
427
|
|
428 depthMOD = editGasPage.mod;
|
|
429
|
|
430 int i = 0;
|
|
431 if(gasID >= 10)
|
|
432 {
|
|
433 i = 1;
|
|
434 strcpy(text, "\001" "Gas #10 X");
|
|
435 }
|
|
436 else
|
|
437 strcpy(text, "\001" "Gas #0 X");
|
|
438
|
|
439 if(ccr)
|
|
440 text[8+i] = TXT_Diluent_Gas_Edit;
|
|
441 else
|
|
442 text[8+i] = TXT_OC_Gas_Edit;
|
|
443
|
|
444 if(gasID >= 10)
|
|
445 text[6+i] += gasID - 10;
|
|
446 else
|
|
447 text[6+i] += gasID;
|
|
448
|
|
449 write_topline(text);
|
|
450 if(actual_menu_content == MENU_SURFACE)
|
|
451 {
|
|
452 write_label_fix( 20, 800, ME_Y_LINE1, &FontT48, TXT_Mix);
|
|
453 write_field_udigit(StMOG_Mix, 210, 400, ME_Y_LINE1, &FontT48, "##/##", (uint32_t)oxygen, (uint32_t)helium, 0, 0);
|
|
454
|
|
455
|
|
456 text[1] = 0;
|
|
457 if(inactive)
|
|
458 text[0] = TXT_Inactive;
|
|
459 else
|
|
460 if(first)
|
|
461 text[0] = TXT_First;
|
|
462 else
|
|
463 if(deco)
|
|
464 text[0] = TXT_Deco;
|
|
465 else
|
|
466 if(travel)
|
|
467 text[0] = TXT_Travel;
|
|
468 else
|
|
469 text[0] = TXT_Inactive;
|
|
470
|
|
471 write_field_button(StMOG_GasType, 20, 710, ME_Y_LINE2, &FontT48, text);
|
|
472
|
|
473
|
|
474 if(deco)
|
|
475 {
|
|
476 text[0] = TXT_ChangeDepth;
|
|
477 text[1] = ' ';
|
|
478 text[2] = TXT_Deco;
|
|
479 text[3] = 0;
|
|
480 write_label_var( 20 ,800, ME_Y_LINE3, &FontT48, text);
|
|
481
|
|
482 textMOD[0] = '#';
|
|
483 textMOD[1] = '#';
|
|
484 textMOD[2] = '#';
|
|
485 textMOD[3] = unit_depth_char1();
|
|
486 textMOD[4] = unit_depth_char2();
|
|
487 textMOD[5] = 0;
|
|
488 write_field_udigit(StMOG_ChangeDepth, 600, 710, ME_Y_LINE3, &FontT48,textMOD, (uint32_t)unit_depth_integer(depthDeco), 0, 0, 0);
|
|
489
|
|
490 txtptr = 0;
|
|
491 text[txtptr++] = TXT_2BYTE;
|
|
492 text[txtptr++] = TXT2BYTE_SetToMOD;
|
|
493 text[txtptr++] = 0;
|
|
494 write_field_button(StMOG_SetToMOD, 20, 710, ME_Y_LINE4, &FontT48,text);
|
|
495 }
|
|
496 else
|
|
497 {
|
|
498 txtptr = 0;
|
|
499 text[txtptr++] = '\021';
|
|
500 text[txtptr++] = TXT_ChangeDepth;
|
|
501 text[txtptr++] = ' ';
|
|
502 text[txtptr++] = TXT_Deco;
|
|
503 text[txtptr++] = 0;
|
|
504 write_label_var( 20 ,800, ME_Y_LINE3, &FontT48, text);
|
|
505
|
|
506 txtptr = 0;
|
|
507 text[txtptr++] = '\021';
|
|
508 text[txtptr++] = TXT_2BYTE;
|
|
509 text[txtptr++] = TXT2BYTE_SetToMOD;
|
|
510 text[txtptr++] = 0;
|
|
511 write_label_var( 20 ,800, ME_Y_LINE4, &FontT48, text);
|
|
512 }
|
|
513 /*
|
|
514 txtptr = 0;
|
|
515 text[txtptr++] = TXT_2BYTE;
|
|
516 text[txtptr++] = TXT2BYTE_Bottle;
|
|
517 text[txtptr++] = 0;
|
|
518 write_label_var( 20 ,800, ME_Y_LINE5, &FontT48, text);
|
|
519 write_field_2digit(StMOG_Bottle, 600, 710, ME_Y_LINE5, &FontT48,"## ltr", (uint32_t)bottleSizeLiter, 0, 0, 0);
|
|
520
|
|
521 txtptr = 0;
|
|
522 text[txtptr++] = TXT_2BYTE;
|
|
523 text[txtptr++] = TXT2BYTE_WirelessSender;
|
|
524 text[txtptr++] = ' ';
|
|
525 if(!bottleWirelessId)
|
|
526 text[txtptr++] = '\021';
|
|
527 txtptr += snprintf(&text[txtptr],20,"%u (%04X)",bottleWirelessIdSmall, bottleWirelessId);
|
|
528 write_field_button(StMOG_Wireless, 20, 710, ME_Y_LINE6, &FontT48, text);
|
|
529 */
|
|
530 stop_cursor_fields();
|
|
531
|
|
532 textMOD[0] = '#';
|
|
533 textMOD[1] = '#';
|
|
534 textMOD[2] = '#';
|
|
535 textMOD[3] = unit_depth_char1();
|
|
536 textMOD[4] = unit_depth_char2();
|
|
537 textMOD[5] = ' ';
|
|
538 textMOD[6] = 'M';
|
|
539 textMOD[7] = 'O';
|
|
540 textMOD[8] = 'D';
|
|
541 textMOD[9] = 0;
|
|
542
|
|
543 write_field_udigit(StMOG_MOD, 401, 780, ME_Y_LINE1, &FontT48, textMOD, (uint32_t)unit_depth_integer(depthMOD), 0, 0, 0);
|
|
544 // write_field_udigit(StMOG_MOD, 401, 780, ME_Y_LINE1, &FontT48, "###m MOD", (uint32_t)depthMOD, 0, 0, 0);
|
|
545
|
|
546 setEvent(StMOG_Mix, (uint32_t)OnAction_Mix);
|
|
547 setEvent(StMOG_GasType, (uint32_t)OnAction_GasType);
|
|
548
|
|
549 if(deco)
|
|
550 {
|
|
551 setEvent(StMOG_ChangeDepth, (uint32_t)OnAction_ChangeDepth);
|
|
552 setEvent(StMOG_SetToMOD, (uint32_t)OnAction_SetToMOD);
|
|
553 }
|
|
554 /*
|
|
555 setEvent(StMOG_Bottle, (uint32_t)OnAction_BottleSize);
|
|
556 setEvent(StMOG_Wireless, (uint32_t)OnAction_Wireless);
|
|
557 */
|
|
558 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
|
|
559 }
|
|
560 }
|
|
561
|
|
562 /* surface mode */
|
|
563 void openEdit_GasType(void)
|
|
564 {
|
|
565 uint8_t gasID, active, first, deco, travel, inactive;
|
|
566 char text[32];
|
|
567
|
|
568
|
|
569 if(editGasPage.ccr)
|
|
570 {
|
|
571 resetMenuEdit(CLUT_MenuPageGasCC);
|
|
572 setBackMenu((uint32_t)openEdit_GasCC, editGasPage.gasID - NUM_OFFSET_DILUENT, 2);
|
|
573 }
|
|
574 else
|
|
575 {
|
|
576 resetMenuEdit(CLUT_MenuPageGasOC);
|
|
577 setBackMenu((uint32_t)openEdit_GasOC, editGasPage.gasID, 2);
|
|
578 }
|
|
579
|
|
580 gasID = editGasPage.gasID;
|
|
581 active = editGasPage.pGasLine[gasID].note.ub.active;
|
|
582 first = editGasPage.pGasLine[gasID].note.ub.first;
|
|
583 deco = editGasPage.pGasLine[gasID].note.ub.deco;
|
|
584 travel = editGasPage.pGasLine[gasID].note.ub.travel;
|
|
585
|
|
586 if(active)
|
|
587 inactive = 0;
|
|
588 else
|
|
589 inactive = 1;
|
|
590
|
|
591
|
|
592 /* header */
|
|
593 int i = 0;
|
|
594 if(gasID >= 10)
|
|
595 {
|
|
596 i = 1;
|
|
597 strcpy(text, "\001" "Gas #10 X");
|
|
598 }
|
|
599 else
|
|
600 strcpy(text, "\001" "Gas #0 X");
|
|
601
|
|
602 if(editGasPage.ccr)
|
|
603 text[8+i] = TXT_Diluent_Gas_Edit;
|
|
604 else
|
|
605 text[8+i] = TXT_OC_Gas_Edit;
|
|
606
|
|
607 if(gasID >= 10)
|
|
608 text[6+i] += gasID - 10;
|
|
609 else
|
|
610 text[6+i] += gasID;
|
|
611 write_topline(text);
|
|
612
|
|
613 text[1] = 0;
|
|
614 text[0] = TXT_First;
|
|
615 write_field_on_off(StMOG_First, 30, 400, ME_Y_LINE1, &FontT48, text, first);
|
|
616
|
|
617 text[0] = TXT_Deco;
|
|
618 write_field_on_off(StMOG_Deco, 30, 400, ME_Y_LINE2, &FontT48, text, deco);
|
|
619
|
|
620 text[0] = TXT_Travel;
|
|
621 write_field_on_off(StMOG_Travel, 30, 400, ME_Y_LINE3, &FontT48, text, travel);
|
|
622
|
|
623 text[0] = TXT_Inactive;
|
|
624 write_field_on_off(StMOG_Inactive, 30, 400, ME_Y_LINE4, &FontT48, text, inactive);
|
|
625
|
|
626 setEvent(StMOG_First, (uint32_t)OnAction_First);
|
|
627 setEvent(StMOG_Deco, (uint32_t)OnAction_Deco);
|
|
628 setEvent(StMOG_Travel, (uint32_t)OnAction_Travel);
|
|
629 setEvent(StMOG_Inactive, (uint32_t)OnAction_Inactive);
|
|
630
|
|
631 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
|
|
632 }
|
|
633
|
|
634 uint8_t OnAction_GasType(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
635 {
|
|
636 openEdit_GasType();
|
|
637 return UNSPECIFIC_RETURN;
|
|
638 }
|
|
639
|
|
640 void openEdit_Wireless(void)
|
|
641 {
|
|
642 uint8_t gasID, wirelessSenderAvailable, isNotMatched, isMatchedWithThis, wirelessSenderActive[MAX_SENDER_AT_ONCE], senderCount, isInList; //, wirelessStatus;
|
|
643 uint16_t wirelessId, wirelessSenderIdSmall, wirelessIdTemp;
|
|
644 char text[32];
|
|
645 uint8_t txtptr;
|
|
646
|
|
647 if(editGasPage.ccr)
|
|
648 {
|
|
649 resetMenuEdit(CLUT_MenuPageGasCC);
|
|
650 setBackMenu((uint32_t)openEdit_GasCC, editGasPage.gasID - NUM_OFFSET_DILUENT, 5);
|
|
651 }
|
|
652 else
|
|
653 {
|
|
654 resetMenuEdit(CLUT_MenuPageGasOC);
|
|
655 setBackMenu((uint32_t)openEdit_GasOC, editGasPage.gasID, 5);
|
|
656 }
|
|
657
|
|
658 gasID = editGasPage.gasID;
|
|
659 wirelessId = editGasPage.pGasLine[gasID].bottle_wireless_id;
|
|
660 // wirelessStatus = editGasPage.pGasLine[gasID].bottle_wireless_status;
|
|
661
|
|
662
|
|
663 /* header */
|
|
664 int i = 0;
|
|
665 if(gasID >= 10)
|
|
666 {
|
|
667 i = 1;
|
|
668 strcpy(text, "\001" "Gas #10 X");
|
|
669 }
|
|
670 else
|
|
671 strcpy(text, "\001" "Gas #0 X");
|
|
672
|
|
673 if(editGasPage.ccr)
|
|
674 text[8+i] = TXT_Diluent_Gas_Edit;
|
|
675 else
|
|
676 text[8+i] = TXT_OC_Gas_Edit;
|
|
677
|
|
678 if(gasID >= 10)
|
|
679 text[6+i] += gasID - 10;
|
|
680 else
|
|
681 text[6+i] += gasID;
|
|
682 write_topline(text);
|
|
683
|
|
684 senderCount = 0;
|
|
685 wirelessSenderAvailable = 0;
|
|
686 if(wirelessId)
|
|
687 {
|
|
688 wirelessSender[senderCount] = wirelessId;
|
|
689 wirelessSenderActive[senderCount] = 0;
|
|
690 wirelessSenderAvailable++;
|
|
691 senderCount++;
|
|
692 }
|
|
693
|
|
694 for(int i=0;i<4;i++)
|
|
695 {
|
|
696 if((stateUsed->lifeData.wireless_data[i].ageInMilliSeconds) && (stateUsed->lifeData.wireless_data[i].ageInMilliSeconds <= 60000) && ((stateUsed->lifeData.wireless_data[i].data[1] & 0x0F) != 0))
|
|
697 {
|
|
698 wirelessIdTemp = stateUsed->lifeData.wireless_data[i].data[0] * 256;
|
|
699 wirelessIdTemp += stateUsed->lifeData.wireless_data[i].data[1];
|
|
700 if(wirelessId && (wirelessId == wirelessIdTemp))
|
|
701 wirelessSenderActive[0] = 1;
|
|
702 else
|
|
703 {
|
|
704 isInList = 0;
|
|
705 for(int j=0;j<wirelessSenderAvailable;j++)
|
|
706 {
|
|
707 if(wirelessSender[j] == wirelessIdTemp)
|
|
708 {
|
|
709 isInList = 1;
|
|
710 break;
|
|
711 }
|
|
712 }
|
|
713 if(!isInList)
|
|
714 {
|
|
715 wirelessSender[senderCount] = wirelessIdTemp;
|
|
716 wirelessSenderActive[senderCount] = 1;
|
|
717 wirelessSenderAvailable++;
|
|
718 senderCount++;
|
|
719 }
|
|
720 }
|
|
721 }
|
|
722 }
|
|
723
|
|
724 if(wirelessSenderAvailable > MAX_SENDER_AT_ONCE)
|
|
725 wirelessSenderAvailable = MAX_SENDER_AT_ONCE;
|
|
726
|
|
727 isNotMatched = 1;
|
|
728
|
|
729 for(int i=0;i<wirelessSenderAvailable;i++)
|
|
730 {
|
|
731 wirelessSenderIdSmall = wirelessSender[i] & 0x0F;
|
|
732
|
|
733 txtptr = 0;
|
|
734 if(!wirelessSenderActive[i])
|
|
735 text[txtptr++] = '\021';
|
|
736 txtptr += snprintf(&text[txtptr],10,"%u (%04X)",wirelessSenderIdSmall, wirelessSender[i]);
|
|
737
|
|
738 if(wirelessId == wirelessSender[i])
|
|
739 {
|
|
740 isMatchedWithThis = 1;
|
|
741 isNotMatched = 0;
|
|
742 }
|
|
743 else
|
|
744 {
|
|
745 isMatchedWithThis = 0;
|
|
746 for(int j=1; j <= 2*NUM_GASES; j++)
|
|
747 {
|
|
748 if((gasID != j) && (settingsGetPointer()->gas[j].bottle_wireless_id == wirelessSender[i]))
|
|
749 {
|
|
750 txtptr += snprintf(&text[txtptr],20," used by Gas #%i",i);
|
|
751 break;
|
|
752 }
|
|
753 }
|
|
754 }
|
|
755 write_field_on_off(StMOG_Transmitter1 + i, 30, 710, ME_Y_LINE1 + (i * ME_Y_LINE_STEP), &FontT48, text, isMatchedWithThis);
|
|
756 }
|
|
757
|
|
758
|
|
759 txtptr = 0;
|
|
760 text[txtptr++] = TXT_2BYTE;
|
|
761 text[txtptr++] = TXT2BYTE_WirelessDisconnect;
|
|
762 text[txtptr++] = 0;
|
|
763 write_field_on_off(StMOG_NoTransmitter, 30, 400, ME_Y_LINE6, &FontT48, text, isNotMatched);
|
|
764
|
|
765 // setEvent has to be _after_ all fields are written
|
|
766 for(int i=0;i<wirelessSenderAvailable;i++)
|
|
767 setEvent(StMOG_Transmitter1 + i, (uint32_t)OnAction_WirelessID);
|
|
768
|
|
769 setEvent(StMOG_NoTransmitter, (uint32_t)OnAction_NoWireless);
|
|
770 }
|
|
771
|
|
772
|
|
773 uint8_t OnAction_Wireless(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
774 {
|
|
775 openEdit_Wireless();
|
|
776 return UNSPECIFIC_RETURN;
|
|
777 }
|
|
778
|
|
779
|
|
780 uint8_t OnAction_WirelessID (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
781 {
|
|
782 if((editId < StMOG_Transmitter1) || (editId > StMOG_Transmitter5))
|
|
783 return UNSPECIFIC_RETURN;
|
|
784
|
|
785 uint8_t line, isMatched;
|
|
786
|
|
787 line = editId - StMOG_Transmitter1;
|
|
788
|
|
789
|
|
790 if(editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_id == wirelessSender[line])
|
|
791 isMatched = 1;
|
|
792 else
|
|
793 isMatched = 0;
|
|
794
|
|
795 editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_id = wirelessSender[line];
|
|
796 // editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_status = 0;
|
|
797
|
|
798 for(int i=0;i<5;i++)
|
|
799 {
|
|
800 if((StMOG_Transmitter1 + i) != editId)
|
|
801 tMenuEdit_set_on_off(StMOG_Transmitter1 + i, 0);
|
|
802 }
|
|
803 tMenuEdit_set_on_off(editId, 1);
|
|
804 tMenuEdit_set_on_off(StMOG_NoTransmitter, 0);
|
|
805
|
|
806 if(!isMatched)
|
|
807 return UPDATE_DIVESETTINGS;
|
|
808 else
|
|
809 return UPDATE_AND_EXIT_TO_MENU;
|
|
810 }
|
|
811
|
|
812
|
|
813 uint8_t OnAction_NoWireless (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
814 {
|
|
815 uint8_t isNotMatched;
|
|
816
|
|
817 if(editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_id == 0)
|
|
818 isNotMatched = 1;
|
|
819 else
|
|
820 isNotMatched = 1;
|
|
821
|
|
822 editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_id = 0;
|
|
823 // editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_status = 0;
|
|
824
|
|
825 tMenuEdit_set_on_off(StMOG_Transmitter1, 0);
|
|
826 tMenuEdit_set_on_off(StMOG_Transmitter2, 0);
|
|
827 tMenuEdit_set_on_off(StMOG_Transmitter3, 0);
|
|
828 tMenuEdit_set_on_off(StMOG_Transmitter4, 0);
|
|
829 tMenuEdit_set_on_off(StMOG_Transmitter5, 0);
|
|
830 tMenuEdit_set_on_off(StMOG_NoTransmitter, 1);
|
|
831
|
|
832 if(!isNotMatched)
|
|
833 return UPDATE_DIVESETTINGS;
|
|
834 else
|
|
835 return UPDATE_AND_EXIT_TO_MENU;
|
|
836 }
|
|
837
|
|
838
|
|
839 uint8_t OnAction_Mix(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
840 {
|
|
841 uint8_t digitContentNew;
|
|
842 uint32_t newOxygen, newHelium;
|
|
843
|
|
844 if(action == ACTION_BUTTON_ENTER)
|
|
845 {
|
|
846 return digitContent;
|
|
847 }
|
|
848 if(action == ACTION_BUTTON_ENTER_FINAL)
|
|
849 {
|
|
850 evaluateNewString(editId, &newOxygen, &newHelium, 0, 0);
|
|
851
|
|
852 if(newOxygen < 5)
|
|
853 newOxygen = 5;
|
|
854 if(newOxygen == 99)
|
|
855 newOxygen = 100;
|
|
856 if(newHelium > 95)
|
|
857 newHelium = 95;
|
|
858 if((newOxygen + newHelium) > 100)
|
|
859 newOxygen = 100 - newHelium;
|
|
860
|
|
861 editGasPage.pGasLine[editGasPage.gasID].oxygen_percentage = newOxygen;
|
|
862 editGasPage.pGasLine[editGasPage.gasID].helium_percentage = newHelium;
|
|
863 editGasPage.mod = calc_MOD(editGasPage.gasID);
|
|
864
|
|
865 if(newOxygen == 100)
|
|
866 newOxygen = 99;
|
|
867
|
|
868 tMenuEdit_newInput(editId, newOxygen, newHelium, 0, 0);
|
|
869 tMenuEdit_newInput(StMOG_MOD, (uint32_t)unit_depth_integer(editGasPage.mod), 0, 0, 0);
|
|
870
|
|
871 return UPDATE_DIVESETTINGS;
|
|
872 }
|
|
873 if(action == ACTION_BUTTON_NEXT)
|
|
874 {
|
|
875 digitContentNew = digitContent + 1;
|
|
876 if(digitContentNew > '9')
|
|
877 digitContentNew = '0';
|
|
878 return digitContentNew;
|
|
879 }
|
|
880 if(action == ACTION_BUTTON_BACK)
|
|
881 {
|
|
882 digitContentNew = digitContent - 1;
|
|
883 if(digitContentNew < '0')
|
|
884 digitContentNew = '9';
|
|
885 return digitContentNew;
|
|
886 }
|
|
887
|
|
888 return UNSPECIFIC_RETURN;
|
|
889 }
|
|
890
|
|
891 /*
|
|
892 uint8_t OnAction_DefaultMix(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
893 {
|
|
894 uint32_t newOxygen, newHelium;
|
|
895 uint8_t depthDEFAULT;
|
|
896 char text[32];
|
|
897
|
|
898 newOxygen = 21;
|
|
899 newHelium = 0;
|
|
900
|
|
901 editGasPage.pGasLine[editGasPage.gasID].oxygen_percentage = newOxygen;
|
|
902 editGasPage.pGasLine[editGasPage.gasID].helium_percentage = newHelium;
|
|
903
|
|
904 tMenuEdit_newInput(StMOG_Mix, newOxygen, newHelium, 0, 0);
|
|
905
|
|
906 depthDEFAULT = calc_MOD(editGasPage.gasID);
|
|
907 create_text_with_u8(text, "", depthDEFAULT, "m MOD");
|
|
908 tMenuEdit_newButtonText(StMOG_DefaultDepth, text);
|
|
909
|
|
910 return UPDATE_DIVESETTINGS;
|
|
911 }
|
|
912
|
|
913 uint8_t OnAction_ToggleDepth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
914 {
|
|
915 uint8_t depth;
|
|
916 uint32_t newDefaultDepth;
|
|
917 char text[32];
|
|
918
|
|
919 if(editGasPage.depth_mode == 0)
|
|
920 {
|
|
921 editGasPage.depth_mode = 1;
|
|
922 depth = editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel;
|
|
923 newDefaultDepth = calc_MinOD(editGasPage.gasID);
|
|
924 create_text_with_u8(text, "", newDefaultDepth, "m Min");
|
|
925 }
|
|
926 else
|
|
927 {
|
|
928 editGasPage.depth_mode = 0;
|
|
929 depth = editGasPage.pGasLine[editGasPage.gasID].depth_meter;
|
|
930 newDefaultDepth = calc_MOD(editGasPage.gasID);
|
|
931 create_text_with_u8(text, "", newDefaultDepth, "m MOD");
|
|
932 }
|
|
933 tMenuEdit_newInput(StMOG_Depth, (uint32_t)depth, 0, 0, 0);
|
|
934 tMenuEdit_newButtonText(StMOG_DefaultDepth, text);
|
|
935
|
|
936 return UNSPECIFIC_RETURN;
|
|
937 }
|
|
938
|
|
939
|
|
940 uint8_t OnAction_Depth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
941 {
|
|
942 uint8_t digitContentNew;
|
|
943 uint32_t newDepth;
|
|
944
|
|
945 if(action == ACTION_BUTTON_ENTER)
|
|
946 {
|
|
947 return digitContent;
|
|
948 }
|
|
949 if(action == ACTION_BUTTON_ENTER_FINAL)
|
|
950 {
|
|
951 evaluateNewString(editId, &newDepth, 0, 0, 0);
|
|
952 if(newDepth > 255)
|
|
953 newDepth = 255;
|
|
954 if(editGasPage.depth_mode == 0)
|
|
955 editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth;
|
|
956 else
|
|
957 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = newDepth;
|
|
958 tMenuEdit_newInput(editId, newDepth, 0, 0, 0);
|
|
959 return UPDATE_DIVESETTINGS;
|
|
960 }
|
|
961 if(action == ACTION_BUTTON_NEXT)
|
|
962 {
|
|
963 digitContentNew = digitContent + 1;
|
|
964 if(digitContentNew > '9')
|
|
965 digitContentNew = '0';
|
|
966 return digitContentNew;
|
|
967 }
|
|
968 if(action == ACTION_BUTTON_BACK)
|
|
969 {
|
|
970 digitContentNew = digitContent - 1;
|
|
971 if(digitContentNew < '0')
|
|
972 digitContentNew = '9';
|
|
973 return digitContentNew;
|
|
974 }
|
|
975
|
|
976 return UNSPECIFIC_RETURN;
|
|
977 }
|
|
978
|
|
979
|
|
980 uint8_t OnAction_DefaultDepth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
981 {
|
|
982 uint32_t newDepth;
|
|
983
|
|
984 if(editGasPage.depth_mode == 0)
|
|
985 {
|
|
986 newDepth = calc_MOD(editGasPage.gasID);
|
|
987 editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth;
|
|
988 }
|
|
989 else
|
|
990 {
|
|
991 newDepth = calc_MinOD(editGasPage.gasID);
|
|
992 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = newDepth;
|
|
993 }
|
|
994
|
|
995 tMenuEdit_newInput(StMOG_Depth, newDepth, 0, 0, 0);
|
|
996
|
|
997 return UPDATE_DIVESETTINGS;
|
|
998 }
|
|
999
|
|
1000
|
|
1001 uint8_t OnAction_Active(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
1002 {
|
|
1003 uint8_t active, first;
|
|
1004
|
|
1005 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first;
|
|
1006
|
|
1007 if(first)
|
|
1008 return UNSPECIFIC_RETURN;
|
|
1009
|
|
1010 active = editGasPage.pGasLine[editGasPage.gasID].note.ub.active;
|
|
1011
|
|
1012 if(active)
|
|
1013 {
|
|
1014 active = 0;
|
|
1015 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 0;
|
|
1016 }
|
|
1017 else
|
|
1018 {
|
|
1019 active = 1;
|
|
1020 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
|
|
1021 }
|
|
1022 tMenuEdit_set_on_off(editId, active);
|
|
1023
|
|
1024 return UPDATE_DIVESETTINGS;
|
|
1025 }
|
|
1026 */
|
|
1027
|
|
1028
|
|
1029 uint8_t OnAction_First(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
1030 {
|
|
1031 uint8_t first, i, gasOne;
|
|
1032
|
|
1033 if(editGasPage.ccr)
|
|
1034 gasOne = 1 + NUM_OFFSET_DILUENT;
|
|
1035 else
|
|
1036 gasOne = 1;
|
|
1037
|
|
1038 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first;
|
|
1039
|
|
1040 if(!first)
|
|
1041 {
|
|
1042 for(i=gasOne;i<NUM_GASES + gasOne;i++)
|
|
1043 {
|
|
1044 if(editGasPage.pGasLine[i].note.ub.first)
|
|
1045 {
|
|
1046 editGasPage.pGasLine[i].note.ub.first = 0;
|
|
1047 editGasPage.pGasLine[i].note.ub.active = 0;
|
|
1048 }
|
|
1049 }
|
|
1050 }
|
|
1051
|
|
1052 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1;
|
|
1053 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
|
|
1054 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0;
|
|
1055 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0;
|
|
1056 editGasPage.pGasLine[editGasPage.gasID].depth_meter = 0;
|
|
1057 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0;
|
|
1058
|
|
1059 tMenuEdit_set_on_off(StMOG_First, 1);
|
|
1060 tMenuEdit_set_on_off(StMOG_Deco, 0);
|
|
1061 tMenuEdit_set_on_off(StMOG_Travel, 0);
|
|
1062 tMenuEdit_set_on_off(StMOG_Inactive, 0);
|
|
1063
|
|
1064 if(!first)
|
|
1065 return UPDATE_DIVESETTINGS;
|
|
1066 else
|
|
1067 return UPDATE_AND_EXIT_TO_MENU;
|
|
1068 }
|
|
1069
|
|
1070
|
|
1071 uint8_t OnAction_Deco(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
1072 {
|
|
1073 uint8_t first, deco, gasOne;
|
|
1074
|
|
1075 if(editGasPage.ccr)
|
|
1076 gasOne = 1 + NUM_OFFSET_DILUENT;
|
|
1077 else
|
|
1078 gasOne = 1;
|
|
1079
|
|
1080 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first;
|
|
1081 deco = editGasPage.pGasLine[editGasPage.gasID].note.ub.deco;
|
|
1082
|
|
1083 if(first)
|
|
1084 {
|
|
1085 if(editGasPage.gasID == gasOne)
|
|
1086 return UNSPECIFIC_RETURN;
|
|
1087 else
|
|
1088 {
|
|
1089 editGasPage.pGasLine[gasOne].note.ub.first = 1;
|
|
1090 editGasPage.pGasLine[gasOne].note.ub.active = 1;
|
|
1091 editGasPage.pGasLine[gasOne].note.ub.deco = 0;
|
|
1092 editGasPage.pGasLine[gasOne].note.ub.travel = 0;
|
|
1093 editGasPage.pGasLine[gasOne].depth_meter = 0;
|
|
1094 editGasPage.pGasLine[gasOne].depth_meter_travel = 0;
|
|
1095 }
|
|
1096 }
|
|
1097
|
|
1098 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0;
|
|
1099 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
|
|
1100 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 1;
|
|
1101 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0;
|
|
1102 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0;
|
|
1103 editGasPage.mod = calc_MOD(editGasPage.gasID);
|
|
1104 editGasPage.pGasLine[editGasPage.gasID].depth_meter = editGasPage.mod;
|
|
1105
|
|
1106 /*
|
|
1107 if(deco)
|
|
1108 {
|
|
1109 editGasPage.pGasLine[editGasPage.gasID].depth_meter = editGasPage.mod;
|
|
1110 tMenuEdit_newInput(StMOG_ChangeDepth, editGasPage.pGasLine[editGasPage.gasID].depth_meter, 0, 0, 0);
|
|
1111 }
|
|
1112 */
|
|
1113
|
|
1114 tMenuEdit_set_on_off(StMOG_First, 0);
|
|
1115 tMenuEdit_set_on_off(StMOG_Deco, 1);
|
|
1116 tMenuEdit_set_on_off(StMOG_Travel, 0);
|
|
1117 tMenuEdit_set_on_off(StMOG_Inactive, 0);
|
|
1118
|
|
1119 if(!deco)
|
|
1120 return UPDATE_DIVESETTINGS;
|
|
1121 else
|
|
1122 return UPDATE_AND_EXIT_TO_MENU;
|
|
1123 }
|
|
1124
|
|
1125
|
|
1126 uint8_t OnAction_Travel(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
1127 {
|
|
1128 uint8_t first, travel, gasOne;
|
|
1129
|
|
1130 if(editGasPage.ccr)
|
|
1131 gasOne = 1 + NUM_OFFSET_DILUENT;
|
|
1132 else
|
|
1133 gasOne = 1;
|
|
1134
|
|
1135 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first;
|
|
1136 travel = editGasPage.pGasLine[editGasPage.gasID].note.ub.travel;
|
|
1137
|
|
1138 if(first)
|
|
1139 {
|
|
1140 if(editGasPage.gasID == gasOne)
|
|
1141 return UNSPECIFIC_RETURN;
|
|
1142 else
|
|
1143 {
|
|
1144 editGasPage.pGasLine[gasOne].note.ub.first = 1;
|
|
1145 editGasPage.pGasLine[gasOne].note.ub.active = 1;
|
|
1146 editGasPage.pGasLine[gasOne].note.ub.deco = 0;
|
|
1147 editGasPage.pGasLine[gasOne].note.ub.travel = 0;
|
|
1148 editGasPage.pGasLine[gasOne].depth_meter = 0;
|
|
1149 editGasPage.pGasLine[gasOne].depth_meter_travel = 0;
|
|
1150 }
|
|
1151 }
|
|
1152
|
|
1153 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0;
|
|
1154 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
|
|
1155 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0;
|
|
1156 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 1;
|
|
1157 editGasPage.pGasLine[editGasPage.gasID].depth_meter = 0;
|
|
1158 editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = 0;
|
|
1159
|
|
1160 tMenuEdit_set_on_off(StMOG_First, 0);
|
|
1161 tMenuEdit_set_on_off(StMOG_Deco, 0);
|
|
1162 tMenuEdit_set_on_off(StMOG_Travel, 1);
|
|
1163 tMenuEdit_set_on_off(StMOG_Inactive, 0);
|
|
1164
|
|
1165 if(!travel)
|
|
1166 return UPDATE_DIVESETTINGS;
|
|
1167 else
|
|
1168 return UPDATE_AND_EXIT_TO_MENU;
|
|
1169 }
|
|
1170
|
|
1171
|
|
1172 uint8_t OnAction_Inactive(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
1173 {
|
|
1174 uint8_t first, inactive, gasOne;
|
|
1175
|
|
1176 if(editGasPage.ccr)
|
|
1177 gasOne = 1 + NUM_OFFSET_DILUENT;
|
|
1178 else
|
|
1179 gasOne = 1;
|
|
1180
|
|
1181 first = editGasPage.pGasLine[editGasPage.gasID].note.ub.first;
|
|
1182
|
|
1183 if(editGasPage.pGasLine[editGasPage.gasID].note.ub.active)
|
|
1184 inactive = 0;
|
|
1185 else
|
|
1186 inactive = 1;
|
|
1187
|
|
1188 if(first)
|
|
1189 {
|
|
1190 if(editGasPage.gasID == gasOne)
|
|
1191 return UNSPECIFIC_RETURN;
|
|
1192 else
|
|
1193 {
|
|
1194 editGasPage.pGasLine[gasOne].note.ub.first = 1;
|
|
1195 editGasPage.pGasLine[gasOne].note.ub.active = 1;
|
|
1196 editGasPage.pGasLine[gasOne].note.ub.deco = 0;
|
|
1197 editGasPage.pGasLine[gasOne].note.ub.travel = 0;
|
|
1198 editGasPage.pGasLine[gasOne].depth_meter = 0;
|
|
1199 editGasPage.pGasLine[gasOne].depth_meter_travel = 0;
|
|
1200 }
|
|
1201 }
|
|
1202
|
|
1203 editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 0;
|
|
1204 editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 0;
|
|
1205 editGasPage.pGasLine[editGasPage.gasID].note.ub.deco = 0;
|
|
1206 editGasPage.pGasLine[editGasPage.gasID].note.ub.travel = 0;
|
|
1207
|
|
1208 tMenuEdit_set_on_off(StMOG_First, 0);
|
|
1209 tMenuEdit_set_on_off(StMOG_Deco, 0);
|
|
1210 tMenuEdit_set_on_off(StMOG_Travel, 0);
|
|
1211 tMenuEdit_set_on_off(StMOG_Inactive, 1);
|
|
1212
|
|
1213 if(!inactive)
|
|
1214 return UPDATE_DIVESETTINGS;
|
|
1215 else
|
|
1216 return UPDATE_AND_EXIT_TO_MENU;
|
|
1217 }
|
|
1218
|
|
1219
|
|
1220 uint8_t OnAction_SetToMOD (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
1221 {
|
|
1222 uint8_t newChangeDepth = editGasPage.mod;
|
|
1223
|
|
1224 editGasPage.pGasLine[editGasPage.gasID].depth_meter = newChangeDepth;
|
|
1225 tMenuEdit_newInput(StMOG_ChangeDepth, unit_depth_integer(newChangeDepth), 0, 0, 0);
|
|
1226
|
|
1227 return UPDATE_DIVESETTINGS;
|
|
1228 }
|
|
1229
|
|
1230
|
|
1231 uint8_t OnAction_ChangeDepth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
1232 {
|
|
1233 uint8_t digitContentNew;
|
|
1234 uint32_t newDepth;
|
|
1235
|
|
1236 if(action == ACTION_BUTTON_ENTER)
|
|
1237 {
|
|
1238 return digitContent;
|
|
1239 }
|
|
1240 if(action == ACTION_BUTTON_ENTER_FINAL)
|
|
1241 {
|
|
1242 evaluateNewString(editId, &newDepth, 0, 0, 0);
|
|
1243 if(settingsGetPointer()->nonMetricalSystem != 0) // new hw 170703
|
|
1244 {
|
|
1245 newDepth += 2; // f�r rundung
|
|
1246 newDepth = (newDepth * 3) / 10;
|
|
1247 }
|
|
1248 if(newDepth > 255)
|
|
1249 newDepth = 255;
|
|
1250 editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth;
|
|
1251 tMenuEdit_newInput(editId, unit_depth_integer(newDepth), 0, 0, 0);
|
|
1252 return UPDATE_DIVESETTINGS;
|
|
1253 }
|
|
1254 if(action == ACTION_BUTTON_NEXT)
|
|
1255 {
|
|
1256 digitContentNew = digitContent + 1;
|
|
1257 if(digitContentNew > '9')
|
|
1258 digitContentNew = '0';
|
|
1259 return digitContentNew;
|
|
1260 }
|
|
1261 if(action == ACTION_BUTTON_BACK)
|
|
1262 {
|
|
1263 digitContentNew = digitContent - 1;
|
|
1264 if(digitContentNew < '0')
|
|
1265 digitContentNew = '9';
|
|
1266 return digitContentNew;
|
|
1267 }
|
|
1268
|
|
1269 return UNSPECIFIC_RETURN;
|
|
1270 }
|
|
1271
|
|
1272
|
|
1273 uint8_t OnAction_BottleSize (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
|
|
1274 {
|
|
1275 int8_t digitContentNew;
|
|
1276 uint32_t newBottleSize;
|
|
1277 // const uint8_t validSize = {4,7,8,10,12,15,16,17,20,24,30,40,255};
|
|
1278 const uint8_t validSize[] = {40,30,24,20,17,16,15,12,10,8,7,4,0};
|
|
1279
|
|
1280 if(action == ACTION_BUTTON_ENTER)
|
|
1281 {
|
|
1282 return digitContent;
|
|
1283 }
|
|
1284 if(action == ACTION_BUTTON_ENTER_FINAL)
|
|
1285 {
|
|
1286 evaluateNewString(editId, &newBottleSize, 0, 0, 0);
|
|
1287
|
|
1288 if(newBottleSize > validSize[0])
|
|
1289 newBottleSize = validSize[0];
|
|
1290
|
|
1291 editGasPage.pGasLine[editGasPage.gasID].bottle_size_liter = newBottleSize;
|
|
1292
|
|
1293 tMenuEdit_newInput(editId, newBottleSize, 0, 0, 0);
|
|
1294 return UPDATE_DIVESETTINGS;
|
|
1295 }
|
|
1296 if(action == ACTION_BUTTON_NEXT)
|
|
1297 {
|
|
1298 // new here for ease of comparison
|
|
1299 digitContentNew = digitContent - '0';
|
|
1300
|
|
1301 if(digitContentNew > 0)
|
|
1302 {
|
|
1303 int i = 0;
|
|
1304 while(digitContentNew < validSize[i])
|
|
1305 {
|
|
1306 i++;
|
|
1307 }
|
|
1308 if(i == 0)
|
|
1309 digitContentNew = 0; // off
|
|
1310 else
|
|
1311 digitContentNew = validSize[i-1];
|
|
1312 }
|
|
1313 else
|
|
1314 {
|
|
1315 int i = 0;
|
|
1316 while(validSize[i] != 0)
|
|
1317 i++;
|
|
1318 digitContentNew = validSize[i-1]; // smallest tank
|
|
1319 }
|
|
1320 digitContentNew += '0';
|
|
1321 return digitContentNew;
|
|
1322 }
|
|
1323 if(action == ACTION_BUTTON_BACK)
|
|
1324 {
|
|
1325 // new here for ease of comparison
|
|
1326 digitContentNew = digitContent - '0';
|
|
1327 if(digitContentNew > 0)
|
|
1328 {
|
|
1329 int i = 0;
|
|
1330 while(digitContentNew < validSize[i])
|
|
1331 {
|
|
1332 i++;
|
|
1333 }
|
|
1334 if(validSize[i] == 0)
|
|
1335 digitContentNew = 0; // off
|
|
1336 else if(validSize[i+1] == 0)
|
|
1337 digitContentNew = 0; // off
|
|
1338 else
|
|
1339 digitContentNew = validSize[i+1];
|
|
1340 }
|
|
1341 else
|
|
1342 {
|
|
1343 digitContentNew = validSize[0];
|
|
1344 }
|
|
1345 digitContentNew += '0';
|
|
1346
|
|
1347 return digitContentNew;
|
|
1348 }
|
|
1349 return EXIT_TO_MENU;
|
|
1350 }
|
|
1351
|
|
1352
|
|
1353 /* Private functions ---------------------------------------------------------*/
|
|
1354
|
|
1355
|
|
1356 void create_text_with_u8(char *text, const char *text1, uint8_t inputU8, const char *text2)
|
|
1357 {
|
|
1358 uint8_t digit1, digit2, digit3, count;
|
|
1359
|
|
1360 count = 0;
|
|
1361
|
|
1362 if(*text1)
|
|
1363 {
|
|
1364 strcpy(&text[count], text1);
|
|
1365 count = strlen(text1);
|
|
1366 }
|
|
1367
|
|
1368 digit1 = inputU8 / 100;
|
|
1369 inputU8 -= digit1 * 100;
|
|
1370 digit2 = inputU8 / 10;
|
|
1371 inputU8 -= digit2 * 10;
|
|
1372 digit3 = inputU8;
|
|
1373 if(digit1)
|
|
1374 text[count++] = '0' + digit1;
|
|
1375 if(count || digit2)
|
|
1376 text[count++] = '0' + digit2;
|
|
1377 text[count++] = '0' + digit3;
|
|
1378
|
|
1379 if(*text2)
|
|
1380 {
|
|
1381 strcpy(&text[count], text2);
|
|
1382 }
|
|
1383 }
|