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