comparison Discovery/Src/tMenuEditPlanner.c @ 38:5f11787b4f42

include in ostc4 repository
author heinrichsweikamp
date Sat, 28 Apr 2018 11:52:34 +0200
parents
children 255eedad4155
comparison
equal deleted inserted replaced
37:ccc45c0e1ea2 38:5f11787b4f42
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
496 textptr = snprintf(text,20,"\021\034%2u\016\016m\017 ",depthNext);
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 {
520 char text[256], textpointer;
521 uint16_t y_line;
522 uint8_t oxygen_percentage;
523 int now;
524
525 if(resultPage < 0xF0)
526 {
527 textpointer = snprintf(text,256,"\001 %u' @ %um",tMplan_dive_time_minutes,tMplan_depth_meter);
528 if(tMplan_intervall_time_minutes)
529 snprintf(&text[textpointer],256-textpointer," in %u'",tMplan_intervall_time_minutes);
530 }
531 else if(resultPage == 0xFE)
532 {
533 textpointer = snprintf(text,30,"%c%c", TXT_2BYTE, TXT2BYTE_SimConsumption);
534 }
535 else
536 {
537 textpointer = snprintf(text,30,"%c%c", TXT_2BYTE, TXT2BYTE_SimSummary);
538 }
539 write_topline(text);
540
541 switch (resultPage)
542 {
543 case 0:
544 break;
545 case 0xFF: // summary
546 for(int j=0;j<4;j++)
547 {
548 y_line = ME_Y_LINE_BASE + ((j + 1) * ME_Y_LINE_STEP);
549
550 // text
551 textpointer = 0;
552 *text = 0;
553 text[textpointer] = 0;
554 text[textpointer++] = TXT_2BYTE;
555 text[textpointer++] = TXT2BYTE_SimDecTo + j; // see text_multilanguage.h
556 text[textpointer] = 0;
557 write_label_var( 10, 200, y_line, &FontT42, text);
558
559 // depth
560 textpointer = 0;
561 *text = 0;
562 switch(j)
563 {
564 case 0: // descent
565 case 1: // level
566 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m\017",tMplan_depth_meter);
567 break;
568 case 2: // first stop
569 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m\017",tMplan_Summary.depthMeterFirstStop);
570 break;
571 default:
572 break;
573 }
574 text[textpointer] = 0;
575 write_label_var( 180, 400, y_line, &FontT42, text);
576
577 // total time
578 textpointer = 0;
579 *text = 0;
580 switch(j)
581 {
582 case 0: // descent
583 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToBottom);
584 break;
585 case 1: // level
586 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeAtBottom);
587 break;
588 case 2: // first stop
589 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToFirstStop);
590 break;
591 case 3: // surface
592 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToSurface);
593 break;
594 default:
595 break;
596 }
597 text[textpointer] = 0;
598 write_label_var( 320, 500, y_line, &FontT42, text);
599
600 // ascent or descent rate or ppO2@bottom
601 textpointer = 0;
602 *text = 0;
603 switch(j)
604 {
605 case 0: // descent
606 textpointer = snprintf(&text[textpointer],20,"-%u\016\016 m\\min\017",tMplan_Summary.descentRateMeterPerMinute);
607 break;
608 case 1: // level
609 textpointer = snprintf(&text[textpointer],20,"%1.2f\016\016 %c\017",tMplan_Summary.ppO2AtBottom, TXT_ppO2);
610 break;
611 case 2: // first stop
612 case 3: // surface
613 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m\\min\017",tMplan_Summary.ascentRateMeterPerMinute);
614 break;
615 default:
616 break;
617 }
618 text[textpointer] = 0;
619 write_label_var( 500, 800, y_line, &FontT42, text);
620 }
621 break;
622 case 0xFE: // gas consumption
623 for(int j=1;j<6;j++)
624 {
625 y_line = ME_Y_LINE_BASE + ((j + 0) * ME_Y_LINE_STEP);
626
627 textpointer = 0;
628 *text = 0;
629 text[textpointer] = 0;
630
631 if(tMplan_pGasConsumption[j] == 0)
632 text[textpointer++] = '\021';
633
634 textpointer += write_gas(&text[textpointer], settingsGetPointer()->gas[j].oxygen_percentage, settingsGetPointer()->gas[j].helium_percentage );
635 text[textpointer] = 0;
636 write_label_var( 10, 390, y_line, &FontT42, text);
637
638 textpointer = 0;
639 *text = 0;
640 text[textpointer] = 0;
641
642 if(tMplan_pGasConsumption[j] == 0)
643 text[textpointer++] = '\021';
644
645 textpointer += snprintf(&text[textpointer],20,"\002%u\016\016 ltr\017",tMplan_pGasConsumption[j]);
646 text[textpointer] = 0;
647 write_label_var( 350, 560, y_line, &FontT42, text);
648 }
649 break;
650
651 default:
652 now = first -(5*(resultPage-1));
653 for(int j=0;j<5;j++)
654 {
655 /* deco list */
656 refresh_PlanResult_helper(text, now-j);
657 y_line = ME_Y_LINE_BASE + ((j + 1) * ME_Y_LINE_STEP);
658 if(*text != 0)
659 write_label_var( 300, 790, y_line, &FontT42, text);
660
661 /* common infos */
662 textpointer = 0;
663 *text = 0;
664 switch (j)
665 {
666 case 0:
667 if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE)
668 textpointer += snprintf(&text[textpointer],20,"VPM +%u",stateUsed->diveSettings.vpm_conservatism);
669 else
670 textpointer += snprintf(&text[textpointer],20,"GF %u/%u", stateUsed->diveSettings.gf_low, stateUsed->diveSettings.gf_high);
671 break;
672 case 1:
673 if(settingsGetPointer()->dive_mode == DIVEMODE_CCR)
674 text[textpointer++] = 'C';
675 else
676 text[textpointer++] = 'O';
677 text[textpointer++] = 'C';
678 text[textpointer++] = ',';
679 text[textpointer++] = ' ';
680 oxygen_percentage = 100;
681 oxygen_percentage -= stateSimGetPointer()->lifeData.actualGas.nitrogen_percentage;
682 oxygen_percentage -= stateSimGetPointer()->lifeData.actualGas.helium_percentage;
683 textpointer += tHome_gas_writer(oxygen_percentage, stateSimGetPointer()->lifeData.actualGas.helium_percentage, &text[textpointer]);
684 break;
685 case 2:
686 textpointer += snprintf(&text[textpointer],20,"TTS: %u'", ((pDecoinfo->output_time_to_surface_seconds+59)/60));
687 // alt: textpointer += snprintf(&text[textpointer],20,"TTS: %u'",tMplan_dive_time_minutes + ((pDecoinfo->output_time_to_surface_seconds+59)/60));
688 break;
689 case 3:
690 textpointer += snprintf(&text[textpointer],20,"CNS:");
691 break;
692 case 4:
693 textpointer += snprintf(&text[textpointer],20,"%.0f%%->%.0f%%",stateRealGetPointer()->lifeData.cns,stateSimGetPointer()->lifeData.cns);
694 break;
695 }
696 text[textpointer] = 0;
697 if(*text != 0)
698 write_label_var( 10, 790, y_line, &FontT42, text);
699 }
700 break;
701 };
702
703 text[0] = TXT_2BYTE;
704 // if(first < (resultPage * 5))
705 if(resultPage == 0xFF)
706 text[1] = TXT2BYTE_Exit;
707 else
708 text[1] = TXT2BYTE_ButtonNext;
709 text[2] = 0;
710 tMenuEdit_newButtonText(StMPLAN5_ExitResult, text);
711 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonNext,0);
712 }
713
714 uint8_t OnAction_PlanResultExit (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
715 {
716 resetEnterPressedToStateBeforeButtonAction();
717 if(resultPage == 0xFF) // last extra page
718 {
719 resultPage = 0;
720 return EXIT_TO_MENU;
721 }
722 if(resultPage >= 0xF0)
723 {
724 resultPage++;
725 return UNSPECIFIC_RETURN;
726 }
727 else if(first < (resultPage * 5))
728 {
729 resultPage = 0xFE;
730 return UNSPECIFIC_RETURN;
731 }
732 else
733 {
734 resultPage++;
735 return UNSPECIFIC_RETURN;
736 }
737 }