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