Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditPlanner.c @ 690:fca2bd25e6e2 Betatest
Added Sentinel protocoll support:
Added function for evaluation of the Sentinel protocoll. At the moment only O2 sensor values are extracted.
author | Ideenmodellierer |
---|---|
date | Fri, 05 Aug 2022 15:22:26 +0200 |
parents | 52df13712fa3 |
children | 01f40cb1057e |
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" | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
310 " l/min" |
38 | 311 "\017" |
312 " " | |
313 "\016\016" | |
314 " deco" | |
315 "\017" | |
316 " " | |
317 "\016\016" | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
318 " l/min" |
38 | 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 // 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 | |
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 | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
607 textpointer = snprintf(&text[textpointer],20,"-%u\016\016 m/min\017",tMplan_Summary.descentRateMeterPerMinute); |
38 | 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 | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
614 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m/min\017",tMplan_Summary.ascentRateMeterPerMinute); |
38 | 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: | |
662 | 674 if(isLoopMode(settingsGetPointer()->dive_mode)) |
38 | 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 } |