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