Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditPlanner.c @ 980:7149f372b0ba Evo_2_23
Fix a couple of bugs in the scrubber timer:
- double speed scrubber countdown in simulator mode
- unwanted updating of last scrubber use date in simulator mode
- invalid remaining scrubber display in surface mode
(mikeller)
author | heinrichsweikamp |
---|---|
date | Tue, 04 Feb 2025 13:49:43 +0100 (6 weeks ago) |
parents | 79b522fbabe6 |
children | 7891160acde3 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuEditPlanner.c | |
5 /// \brief Menu Edit Planner Parameters | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 08-Jan-2015 | |
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 "tMenuEditPlanner.h" | |
31 | |
32 #include "gfx_fonts.h" | |
33 #include "ostc.h" // for MX_Bluetooth_PowerOff(); | |
34 #include "simulation.h" | |
35 #include "tHome.h" //for tHome_gas_writer() | |
36 #include "tMenuEdit.h" | |
584 | 37 #include "unit.h" |
38 | 38 |
39 /* Private types -------------------------------------------------------------*/ | |
40 uint8_t resultPage = 0; | |
41 int8_t first = 0; | |
42 | |
43 SDecoinfo* pDecoinfo; | |
44 | |
45 uint16_t tMplan_pGasConsumption[6] = {0,0,0,0,0,0}; | |
46 SSimDataSummary tMplan_Summary = {0}; | |
47 | |
48 /* Importend function prototypes ---------------------------------------------*/ | |
49 extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium); | |
50 | |
51 /* Imported variables --------------------------------------------------------*/ | |
52 | |
567 | 53 extern uint16_t tMplan_depth_meter, tMplan_intervall_time_minutes, tMplan_dive_time_minutes, tMplan_depth_editor; |
38 | 54 |
55 /* Private variables ---------------------------------------------------------*/ | |
56 uint8_t gasChangeListDepthGasId[40]; | |
57 | |
58 /* Private function prototypes -----------------------------------------------*/ | |
59 void openEdit_PlanInterval(void); | |
60 void openEdit_PlanDiveTime(void); | |
61 void openEdit_PlanMaxDepth(void); | |
62 void openEdit_PlanSettings(void); | |
63 void openEdit_PlanResult(void); | |
64 | |
65 /* Announced function prototypes -----------------------------------------------*/ | |
66 uint8_t OnAction_PlanInterval (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
67 uint8_t OnAction_PlanDiveTime (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
68 uint8_t OnAction_PlanMaxDepth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
69 uint8_t OnAction_PlanResultExit (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
70 uint8_t OnAction_PlanSettings (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
71 | |
72 /* Exported functions --------------------------------------------------------*/ | |
73 | |
74 void openEdit_Planner(uint8_t line) | |
75 { | |
76 set_globalState_Menu_Line(line); | |
77 resetMenuEdit(CLUT_MenuPageDivePlanner); | |
78 resultPage = 0; | |
79 | |
80 switch(line) | |
81 { | |
82 case 1: | |
83 default: | |
84 if(settingsGetPointer()->bluetoothActive != 0) | |
85 { | |
86 settingsGetPointer()->bluetoothActive = 0; | |
87 MX_Bluetooth_PowerOff(); | |
88 } | |
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
760
diff
changeset
|
89 |
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
760
diff
changeset
|
90 disableTimer(); |
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
760
diff
changeset
|
91 |
760
21949c88da90
Quit simualted dives after the dive time set in the SIM tab.
heinrichsweikamp
parents:
699
diff
changeset
|
92 simulation_start(tMplan_depth_meter, tMplan_dive_time_minutes); |
38 | 93 exitMenuEdit_to_Home(); |
94 break; | |
95 case 2: | |
96 openEdit_PlanInterval(); | |
97 break; | |
98 case 3: | |
99 openEdit_PlanDiveTime(); | |
100 break; | |
101 case 4: | |
102 openEdit_PlanMaxDepth(); | |
103 break; | |
104 case 5: | |
105 openEdit_PlanResult(); | |
106 break; | |
107 case 6: | |
108 openEdit_PlanSettings(); | |
109 break; | |
110 } | |
111 } | |
112 | |
113 /* Private functions ---------------------------------------------------------*/ | |
114 | |
115 void openEdit_PlanInterval(void) | |
116 { | |
117 char text[32]; | |
118 | |
119 text[0] = '\001'; | |
120 text[1] = TXT_2BYTE; | |
121 text[2] = TXT2BYTE_Simulator; | |
122 text[3] = 0; | |
123 write_topline(text); | |
124 | |
125 text[0] = TXT_2BYTE; | |
126 text[1] = TXT2BYTE_Intervall; | |
127 text[2] = 0; | |
128 write_label_var( 20, 550, ME_Y_LINE2, &FontT48, text); | |
129 | |
567 | 130 write_field_udigit(StMPLAN2_Interval, 400, 800, ME_Y_LINE2, &FontT48, "###\016\016min\017", (uint32_t)tMplan_intervall_time_minutes, 0, 0, 0); |
38 | 131 setEvent(StMPLAN2_Interval, (uint32_t)OnAction_PlanInterval); |
132 startEdit(); | |
133 } | |
134 | |
135 | |
136 void openEdit_PlanDiveTime(void) | |
137 { | |
138 char text[32]; | |
139 | |
140 text[0] = '\001'; | |
141 text[1] = TXT_2BYTE; | |
142 text[2] = TXT2BYTE_Simulator; | |
143 text[3] = 0; | |
144 write_topline(text); | |
145 | |
146 text[0] = TXT_2BYTE; | |
147 text[1] = TXT2BYTE_SimDiveTime; | |
148 text[2] = 0; | |
149 write_label_var( 20, 550, ME_Y_LINE3, &FontT48, text); | |
150 | |
567 | 151 write_field_udigit(StMPLAN3_DiveTime, 400, 800, ME_Y_LINE3, &FontT48, "###\016\016min\017", (uint32_t)tMplan_dive_time_minutes, 0, 0, 0); |
38 | 152 setEvent(StMPLAN3_DiveTime, (uint32_t)OnAction_PlanDiveTime); |
153 startEdit(); | |
154 } | |
155 | |
156 | |
157 void openEdit_PlanMaxDepth(void) | |
158 { | |
159 char text[32]; | |
567 | 160 tMplan_depth_editor = unit_depth_integer(tMplan_depth_meter); |
38 | 161 |
162 text[0] = '\001'; | |
163 text[1] = TXT_2BYTE; | |
164 text[2] = TXT2BYTE_Simulator; | |
165 text[3] = 0; | |
166 write_topline(text); | |
167 | |
168 text[0] = TXT_2BYTE; | |
169 text[1] = TXT2BYTE_SimMaxDepth; | |
170 text[2] = 0; | |
171 write_label_var( 20, 550, ME_Y_LINE4, &FontT48, text); | |
172 | |
567 | 173 if(settingsGetPointer()->nonMetricalSystem) |
174 { | |
175 write_field_udigit(StMPLAN4_MaxDepth, 400, 800, ME_Y_LINE4, &FontT48, "###\016\016ft\017", (uint32_t)tMplan_depth_editor, 0, 0, 0); | |
176 } | |
177 else | |
178 { | |
179 write_field_udigit(StMPLAN4_MaxDepth, 400, 800, ME_Y_LINE4, &FontT48, "###\016\016m\017", (uint32_t)tMplan_depth_editor, 0, 0, 0); | |
180 } | |
181 | |
38 | 182 setEvent(StMPLAN4_MaxDepth, (uint32_t)OnAction_PlanMaxDepth); |
183 startEdit(); | |
184 } | |
185 | |
186 | |
187 uint8_t OnAction_PlanInterval (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
188 { | |
189 uint32_t newValue; | |
190 | |
191 if(action == ACTION_BUTTON_ENTER_FINAL) | |
192 { | |
193 evaluateNewString(editId, &newValue, 0, 0, 0); | |
194 tMplan_intervall_time_minutes = newValue; | |
195 return EXIT_TO_MENU; | |
196 } | |
197 else | |
198 if(action == ACTION_BUTTON_NEXT) | |
199 { | |
200 digitContent++; | |
201 if(digitContent > '9') | |
202 digitContent = '0'; | |
203 } | |
204 else | |
205 if(action == ACTION_BUTTON_BACK) | |
206 { | |
207 digitContent--; | |
208 if(digitContent < '0') | |
209 digitContent = '9'; | |
210 } | |
211 return digitContent; | |
212 } | |
213 | |
214 | |
215 uint8_t OnAction_PlanDiveTime (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
216 { | |
217 uint32_t newValue; | |
218 | |
219 if(action == ACTION_BUTTON_ENTER_FINAL) | |
220 { | |
221 evaluateNewString(editId, &newValue, 0, 0, 0); | |
222 tMplan_dive_time_minutes = newValue; | |
223 return EXIT_TO_MENU; | |
224 } | |
225 else | |
226 if(action == ACTION_BUTTON_NEXT) | |
227 { | |
228 digitContent++; | |
229 if((digitNumber == 0) && (digitContent > '3')) | |
230 digitContent = '0'; | |
231 if(digitContent > '9') | |
232 digitContent = '0'; | |
233 } | |
234 else | |
235 if(action == ACTION_BUTTON_BACK) | |
236 { | |
237 digitContent--; | |
238 if((digitNumber == 0) && (digitContent < '0')) | |
239 digitContent = '3'; | |
240 if(digitContent < '0') | |
241 digitContent = '9'; | |
242 } | |
243 return digitContent; | |
244 } | |
245 | |
246 | |
247 uint8_t OnAction_PlanMaxDepth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
248 { | |
249 uint32_t newValue; | |
250 | |
251 if(action == ACTION_BUTTON_ENTER_FINAL) | |
252 { | |
253 evaluateNewString(editId, &newValue, 0, 0, 0); | |
567 | 254 if(settingsGetPointer()->nonMetricalSystem) |
255 { | |
256 tMplan_depth_editor = newValue * 10 / 33; | |
257 } | |
258 else | |
259 { | |
260 tMplan_depth_editor = newValue; | |
261 } | |
262 tMplan_depth_meter = tMplan_depth_editor; | |
38 | 263 return EXIT_TO_MENU; |
264 } | |
265 else | |
266 if(action == ACTION_BUTTON_NEXT) | |
267 { | |
268 digitContent++; | |
269 if((digitNumber == 0) && (digitContent > '3')) | |
270 digitContent = '0'; | |
271 if(digitContent > '9') | |
272 digitContent = '0'; | |
273 } | |
274 else | |
275 if(action == ACTION_BUTTON_BACK) | |
276 { | |
277 digitContent--; | |
278 if((digitNumber == 0) && (digitContent < '0')) | |
279 digitContent = '3'; | |
280 if(digitContent < '0') | |
281 digitContent = '9'; | |
282 } | |
283 return digitContent; | |
284 } | |
285 | |
286 | |
287 void openEdit_PlanSettings(void) | |
288 { | |
289 uint8_t travel_lbar, deco_lbar; | |
290 uint16_t y_line; | |
291 char text[40]; | |
292 SSettings *pSettings = settingsGetPointer(); | |
293 | |
294 travel_lbar = pSettings->gasConsumption_travel_l_min; | |
295 deco_lbar = pSettings->gasConsumption_deco_l_min; | |
296 | |
297 y_line = ME_Y_LINE_BASE + (6 * ME_Y_LINE_STEP); | |
298 | |
299 text[0] = '\001'; | |
300 text[1] = TXT_2BYTE; | |
301 text[2] = TXT2BYTE_SimConsumption; | |
302 text[3] = 0; | |
303 write_topline(text); | |
304 | |
305 text[0] = TXT_2BYTE; | |
306 text[1] = TXT2BYTE_SimConsumption; | |
307 text[2] = 0; | |
308 write_label_var( 20, 800, y_line, &FontT48, text); | |
309 | |
699 | 310 strcpy(text, |
38 | 311 " " |
312 "\016\016" | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
313 " l/min" |
38 | 314 "\017" |
315 " " | |
316 "\016\016" | |
317 " deco" | |
318 "\017" | |
319 " " | |
320 "\016\016" | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
321 " l/min" |
699 | 322 "\017" |
38 | 323 ); |
324 write_label_var( 400, 800, y_line, &FontT48, text); | |
325 | |
326 write_field_udigit(StMPLAN4_Settings, 400, 800, y_line, &FontT48, "## ##", (uint32_t)travel_lbar, (uint32_t)deco_lbar, 0, 0); | |
327 // note : text max is 32 byte! -> ok and it does not like small fonts in between -> problem | |
328 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); | |
329 | |
330 setEvent(StMPLAN4_Settings, (uint32_t)OnAction_PlanSettings); | |
331 startEdit(); | |
332 } | |
333 | |
334 | |
335 uint8_t OnAction_PlanSettings (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
336 { | |
337 uint32_t newValueTravel, newValueDeco; | |
338 | |
339 if(action == ACTION_BUTTON_ENTER_FINAL) | |
340 { | |
341 evaluateNewString(editId, &newValueTravel, &newValueDeco, 0, 0); | |
342 if(newValueTravel < 5 ) | |
343 newValueTravel = 5; | |
344 if(newValueTravel > 30 ) | |
345 newValueTravel = 30; | |
346 if(newValueDeco < 5 ) | |
347 newValueDeco = 5; | |
348 if(newValueDeco > 30 ) | |
349 newValueDeco = 30; | |
350 | |
351 settingsGetPointer()->gasConsumption_travel_l_min = (uint8_t)newValueTravel; | |
352 settingsGetPointer()->gasConsumption_deco_l_min = (uint8_t)newValueDeco; | |
353 | |
354 return EXIT_TO_MENU; | |
355 } | |
356 else if(action == ACTION_BUTTON_NEXT) | |
357 { | |
358 digitContent++; | |
359 if((digitNumber == 0) && (digitContent > '3')) | |
360 digitContent = '0'; | |
361 if(digitContent > '9') | |
362 digitContent = '0'; | |
363 } | |
364 else if(action == ACTION_BUTTON_BACK) | |
365 { | |
366 digitContent--; | |
367 if((digitNumber == 0) && (digitContent < '0')) | |
368 digitContent = '3'; | |
369 if(digitContent < '0') | |
370 digitContent = '9'; | |
371 } | |
372 | |
373 return digitContent; | |
374 } | |
375 | |
376 | |
377 void openEdit_PlanResult(void) | |
378 { | |
379 char text[256]; | |
380 | |
381 text[0] = '\001'; | |
382 text[1] = TXT_2BYTE; | |
383 text[2] = TXT2BYTE_Calculating; | |
384 text[3] = 0; | |
385 | |
386 write_topline(text); | |
387 | |
388 text[2] = TXT2BYTE_PleaseWait; | |
389 write_label_var( 10, 790, ME_Y_LINE1, &FontT42, text); | |
390 | |
391 SSettings *pSettings = settingsGetPointer(); | |
392 uint8_t tMplan_gasConsumTravel = pSettings->gasConsumption_travel_l_min; | |
393 uint8_t tMplan_gasConsumDeco = pSettings->gasConsumption_deco_l_min; | |
394 | |
395 resultPage = 0; | |
396 pDecoinfo = simulation_decoplaner(tMplan_depth_meter, tMplan_intervall_time_minutes, tMplan_dive_time_minutes, gasChangeListDepthGasId); | |
397 simulation_gas_consumption(tMplan_pGasConsumption, tMplan_depth_meter, tMplan_dive_time_minutes, pDecoinfo, tMplan_gasConsumTravel, tMplan_gasConsumDeco, gasChangeListDepthGasId); | |
398 simulation_helper_change_points(&tMplan_Summary, tMplan_depth_meter, tMplan_dive_time_minutes, pDecoinfo, gasChangeListDepthGasId); | |
399 | |
400 first = 0; | |
401 while((first < DECOINFO_STRUCT_MAX_STOPS-1) && pDecoinfo->output_stop_length_seconds[first+1]) | |
402 first++; | |
403 resultPage = 1; | |
404 | |
405 text[0] = TXT_2BYTE; | |
406 text[1] = TXT2BYTE_ButtonNext; | |
407 text[2] = 0; | |
408 write_field_button(StMPLAN5_ExitResult, 30, 800, ME_Y_LINE6, &FontT48, text); | |
409 setEvent(StMPLAN5_ExitResult, (uint32_t)OnAction_PlanResultExit); | |
888
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
410 tMenuEdit_select(StMPLAN5_ExitResult); |
38 | 411 } |
412 | |
413 | |
414 | |
415 void refresh_PlanResult_helper(char *text, int start) | |
416 { | |
417 uint8_t depthPrev, depthNext, depthLast, depthSecond, depthInc, depthChange, GasIdPrev, GasIdNextList[3], ListCount, oxygen_percentage, textptr; | |
418 int lengthInMinutes; | |
419 | |
420 depthLast = (uint8_t)(stateUsed->diveSettings.last_stop_depth_bar * 10); | |
421 depthSecond = (uint8_t)(stateUsed->diveSettings.input_second_to_last_stop_depth_bar * 10); | |
422 depthInc = (uint8_t)(stateUsed->diveSettings.input_next_stop_increment_depth_bar * 10); | |
423 | |
424 | |
425 if((start < 0) || (start >= DECOINFO_STRUCT_MAX_STOPS)) | |
426 { | |
427 *text = 0; | |
428 return; | |
429 } | |
430 | |
431 if(start == 0) | |
432 { | |
433 depthNext = depthLast; | |
434 depthPrev = depthSecond; | |
435 } | |
436 else if(start == 1) | |
437 { | |
438 depthNext = depthSecond; | |
439 depthPrev = depthSecond + depthInc; | |
440 } | |
441 else | |
442 { | |
443 depthNext = depthSecond + (start - 1) * depthInc; | |
444 depthPrev = depthNext + depthInc; | |
445 } | |
446 | |
447 /* gas changes ? */ | |
448 GasIdPrev = 0; | |
449 ListCount = 0; | |
450 | |
451 for(int i = 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++) | |
452 { | |
830
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
805
diff
changeset
|
453 if((stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0) |
973 | 454 #ifdef ENABLE_DECOCALC_OPTION |
455 || (stateSimGetPointer()->diveSettings.gas[stateSimGetPointer()->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0) | |
456 #endif | |
457 ) | |
38 | 458 break; |
459 depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; | |
460 if(depthPrev <= depthChange) | |
461 { | |
462 GasIdPrev = i; | |
463 } | |
464 else | |
465 { | |
466 break; | |
467 } | |
468 } | |
469 | |
470 for(int i = GasIdPrev + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++) | |
471 { | |
830
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
805
diff
changeset
|
472 if((stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0) |
973 | 473 #ifdef ENABLE_DECOCALC_OPTION |
474 || (stateSimGetPointer()->diveSettings.gas[stateSimGetPointer()->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0) | |
475 #endif | |
476 ) | |
38 | 477 break; |
478 depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; | |
479 if((depthChange < depthPrev) && (depthChange >= depthNext)) | |
480 { | |
481 GasIdNextList[ListCount++] = i; | |
482 if(ListCount > 3) | |
483 break; | |
484 } | |
485 } | |
486 | |
487 /* text output */ | |
488 if(pDecoinfo->output_stop_length_seconds[start]) | |
489 { | |
490 textptr = snprintf(text,20,"\034%2u\016\016m\017 ",depthNext); | |
491 lengthInMinutes = (pDecoinfo->output_stop_length_seconds[start]+59)/60; | |
492 | |
493 int i = 0; | |
494 while((i<lengthInMinutes) && (i<15)) | |
495 { | |
496 text[textptr++] = '_'; | |
497 i++; | |
498 } | |
499 for(int j=i;j<15;j++) | |
500 { | |
501 text[textptr++] = '\177'; | |
502 text[textptr++] = '_'; | |
503 } | |
504 textptr += snprintf(&text[textptr],20," %3i'", lengthInMinutes); | |
505 } | |
506 else | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
507 textptr = snprintf(text,20,"\031\034%2u\016\016m\017 ",depthNext); |
38 | 508 |
509 for(int i = 0; i < ListCount; i++) | |
510 { | |
511 if(stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].setPoint_cbar != stateSimGetPointer()->diveSettings.decogaslist[GasIdPrev].setPoint_cbar) | |
512 snprintf(&text[textptr],20," %01.2f ", ((float)(stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].setPoint_cbar))/100); | |
513 else | |
514 { | |
515 oxygen_percentage = 100; | |
516 oxygen_percentage -= stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].nitrogen_percentage; | |
517 oxygen_percentage -= stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].helium_percentage; | |
518 | |
519 text[textptr++] = ' '; | |
520 textptr += tHome_gas_writer(oxygen_percentage, stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].helium_percentage, &text[textptr]); | |
521 text[textptr++] = ' '; | |
522 text[textptr] = 0; | |
523 } | |
524 GasIdPrev = GasIdNextList[i]; | |
525 } | |
526 } | |
527 | |
528 | |
529 void refresh_PlanResult(void) | |
530 { | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
531 char text[256]; |
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
532 uint8_t textpointer; |
38 | 533 uint16_t y_line; |
534 uint8_t oxygen_percentage; | |
535 int now; | |
536 | |
537 if(resultPage < 0xF0) | |
538 { | |
539 textpointer = snprintf(text,256,"\001 %u' @ %um",tMplan_dive_time_minutes,tMplan_depth_meter); | |
540 if(tMplan_intervall_time_minutes) | |
541 snprintf(&text[textpointer],256-textpointer," in %u'",tMplan_intervall_time_minutes); | |
542 } | |
543 else if(resultPage == 0xFE) | |
544 { | |
545 textpointer = snprintf(text,30,"%c%c", TXT_2BYTE, TXT2BYTE_SimConsumption); | |
546 } | |
547 else | |
548 { | |
549 textpointer = snprintf(text,30,"%c%c", TXT_2BYTE, TXT2BYTE_SimSummary); | |
550 } | |
551 write_topline(text); | |
552 | |
553 switch (resultPage) | |
554 { | |
555 case 0: | |
556 break; | |
557 case 0xFF: // summary | |
558 for(int j=0;j<4;j++) | |
559 { | |
560 y_line = ME_Y_LINE_BASE + ((j + 1) * ME_Y_LINE_STEP); | |
561 | |
562 // text | |
563 textpointer = 0; | |
564 *text = 0; | |
565 text[textpointer] = 0; | |
566 text[textpointer++] = TXT_2BYTE; | |
567 text[textpointer++] = TXT2BYTE_SimDecTo + j; // see text_multilanguage.h | |
568 text[textpointer] = 0; | |
569 write_label_var( 10, 200, y_line, &FontT42, text); | |
570 | |
571 // depth | |
572 textpointer = 0; | |
573 *text = 0; | |
574 switch(j) | |
575 { | |
576 case 0: // descent | |
577 case 1: // level | |
578 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m\017",tMplan_depth_meter); | |
579 break; | |
580 case 2: // first stop | |
581 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m\017",tMplan_Summary.depthMeterFirstStop); | |
582 break; | |
583 default: | |
584 break; | |
585 } | |
586 text[textpointer] = 0; | |
587 write_label_var( 180, 400, y_line, &FontT42, text); | |
588 | |
589 // total time | |
590 textpointer = 0; | |
591 *text = 0; | |
592 switch(j) | |
593 { | |
594 case 0: // descent | |
595 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToBottom); | |
596 break; | |
597 case 1: // level | |
598 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeAtBottom); | |
599 break; | |
600 case 2: // first stop | |
601 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToFirstStop); | |
602 break; | |
603 case 3: // surface | |
604 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToSurface); | |
605 break; | |
606 default: | |
607 break; | |
608 } | |
609 text[textpointer] = 0; | |
610 write_label_var( 320, 500, y_line, &FontT42, text); | |
611 | |
612 // ascent or descent rate or ppO2@bottom | |
613 textpointer = 0; | |
614 *text = 0; | |
615 switch(j) | |
616 { | |
617 case 0: // descent | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
618 textpointer = snprintf(&text[textpointer],20,"-%u\016\016 m/min\017",tMplan_Summary.descentRateMeterPerMinute); |
38 | 619 break; |
620 case 1: // level | |
621 textpointer = snprintf(&text[textpointer],20,"%1.2f\016\016 %c\017",tMplan_Summary.ppO2AtBottom, TXT_ppO2); | |
622 break; | |
623 case 2: // first stop | |
624 case 3: // surface | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
625 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m/min\017",tMplan_Summary.ascentRateMeterPerMinute); |
38 | 626 break; |
627 default: | |
628 break; | |
629 } | |
630 text[textpointer] = 0; | |
631 write_label_var( 500, 800, y_line, &FontT42, text); | |
632 } | |
633 break; | |
634 case 0xFE: // gas consumption | |
635 for(int j=1;j<6;j++) | |
636 { | |
637 y_line = ME_Y_LINE_BASE + ((j + 0) * ME_Y_LINE_STEP); | |
638 | |
639 textpointer = 0; | |
640 *text = 0; | |
641 text[textpointer] = 0; | |
642 | |
643 if(tMplan_pGasConsumption[j] == 0) | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
644 text[textpointer++] = '\031'; |
38 | 645 |
646 textpointer += write_gas(&text[textpointer], settingsGetPointer()->gas[j].oxygen_percentage, settingsGetPointer()->gas[j].helium_percentage ); | |
647 text[textpointer] = 0; | |
648 write_label_var( 10, 390, y_line, &FontT42, text); | |
649 | |
650 textpointer = 0; | |
651 *text = 0; | |
652 text[textpointer] = 0; | |
653 | |
654 if(tMplan_pGasConsumption[j] == 0) | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
655 text[textpointer++] = '\031'; |
38 | 656 |
657 textpointer += snprintf(&text[textpointer],20,"\002%u\016\016 ltr\017",tMplan_pGasConsumption[j]); | |
658 text[textpointer] = 0; | |
659 write_label_var( 350, 560, y_line, &FontT42, text); | |
660 } | |
661 break; | |
662 | |
663 default: | |
664 now = first -(5*(resultPage-1)); | |
665 for(int j=0;j<5;j++) | |
666 { | |
667 /* deco list */ | |
668 refresh_PlanResult_helper(text, now-j); | |
669 y_line = ME_Y_LINE_BASE + ((j + 1) * ME_Y_LINE_STEP); | |
670 if(*text != 0) | |
671 write_label_var( 300, 790, y_line, &FontT42, text); | |
672 | |
673 /* common infos */ | |
674 textpointer = 0; | |
675 *text = 0; | |
676 switch (j) | |
677 { | |
678 case 0: | |
679 if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) | |
680 textpointer += snprintf(&text[textpointer],20,"VPM +%u",stateUsed->diveSettings.vpm_conservatism); | |
681 else | |
682 textpointer += snprintf(&text[textpointer],20,"GF %u/%u", stateUsed->diveSettings.gf_low, stateUsed->diveSettings.gf_high); | |
683 break; | |
684 case 1: | |
662 | 685 if(isLoopMode(settingsGetPointer()->dive_mode)) |
38 | 686 text[textpointer++] = 'C'; |
687 else | |
688 text[textpointer++] = 'O'; | |
689 text[textpointer++] = 'C'; | |
690 text[textpointer++] = ','; | |
691 text[textpointer++] = ' '; | |
692 oxygen_percentage = 100; | |
693 oxygen_percentage -= stateSimGetPointer()->lifeData.actualGas.nitrogen_percentage; | |
694 oxygen_percentage -= stateSimGetPointer()->lifeData.actualGas.helium_percentage; | |
695 textpointer += tHome_gas_writer(oxygen_percentage, stateSimGetPointer()->lifeData.actualGas.helium_percentage, &text[textpointer]); | |
696 break; | |
697 case 2: | |
698 textpointer += snprintf(&text[textpointer],20,"TTS: %u'", ((pDecoinfo->output_time_to_surface_seconds+59)/60)); | |
699 // alt: textpointer += snprintf(&text[textpointer],20,"TTS: %u'",tMplan_dive_time_minutes + ((pDecoinfo->output_time_to_surface_seconds+59)/60)); | |
700 break; | |
701 case 3: | |
702 textpointer += snprintf(&text[textpointer],20,"CNS:"); | |
703 break; | |
704 case 4: | |
705 textpointer += snprintf(&text[textpointer],20,"%.0f%%->%.0f%%",stateRealGetPointer()->lifeData.cns,stateSimGetPointer()->lifeData.cns); | |
706 break; | |
707 } | |
708 text[textpointer] = 0; | |
709 if(*text != 0) | |
710 write_label_var( 10, 790, y_line, &FontT42, text); | |
711 } | |
712 break; | |
713 }; | |
714 | |
715 text[0] = TXT_2BYTE; | |
716 // if(first < (resultPage * 5)) | |
717 if(resultPage == 0xFF) | |
718 text[1] = TXT2BYTE_Exit; | |
719 else | |
720 text[1] = TXT2BYTE_ButtonNext; | |
721 text[2] = 0; | |
722 tMenuEdit_newButtonText(StMPLAN5_ExitResult, text); | |
723 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonNext,0); | |
724 } | |
725 | |
726 uint8_t OnAction_PlanResultExit (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
727 { | |
728 resetEnterPressedToStateBeforeButtonAction(); | |
729 if(resultPage == 0xFF) // last extra page | |
730 { | |
731 resultPage = 0; | |
732 return EXIT_TO_MENU; | |
733 } | |
734 if(resultPage >= 0xF0) | |
735 { | |
736 resultPage++; | |
737 return UNSPECIFIC_RETURN; | |
738 } | |
739 else if(first < (resultPage * 5)) | |
740 { | |
741 resultPage = 0xFE; | |
742 return UNSPECIFIC_RETURN; | |
743 } | |
744 else | |
745 { | |
746 resultPage++; | |
747 return UNSPECIFIC_RETURN; | |
748 } | |
749 } |