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