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