Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditPlanner.c @ 757:39ff186b6f98
Dev Bugfix: ignore analog out of bounds limits for DiveO2 sensor:
The DiveO2 sensor provides a status information which may be used to identify if the value is valid or not. The sensor does not provide a voltage => to have a value for the voltage the value of the ppo2 is taken (equals calibration coeff of 1). For the analog out of bounds detection this value is too high and the DiveO2 is marked as out of bounds. To avoid this problem DiveO2 sensors are now excluded from the analog out of bounds detection.
author | Ideenmodellierer |
---|---|
date | Tue, 07 Mar 2023 22:14:20 +0100 |
parents | 01f40cb1057e |
children | 21949c88da90 |
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 | |
699 | 307 strcpy(text, |
38 | 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" |
699 | 319 "\017" |
38 | 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 // note : text max is 32 byte! -> ok and it does not like small fonts in between -> problem | |
325 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); | |
326 | |
327 setEvent(StMPLAN4_Settings, (uint32_t)OnAction_PlanSettings); | |
328 startEdit(); | |
329 } | |
330 | |
331 | |
332 uint8_t OnAction_PlanSettings (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
333 { | |
334 uint32_t newValueTravel, newValueDeco; | |
335 | |
336 if(action == ACTION_BUTTON_ENTER_FINAL) | |
337 { | |
338 evaluateNewString(editId, &newValueTravel, &newValueDeco, 0, 0); | |
339 if(newValueTravel < 5 ) | |
340 newValueTravel = 5; | |
341 if(newValueTravel > 30 ) | |
342 newValueTravel = 30; | |
343 if(newValueDeco < 5 ) | |
344 newValueDeco = 5; | |
345 if(newValueDeco > 30 ) | |
346 newValueDeco = 30; | |
347 | |
348 settingsGetPointer()->gasConsumption_travel_l_min = (uint8_t)newValueTravel; | |
349 settingsGetPointer()->gasConsumption_deco_l_min = (uint8_t)newValueDeco; | |
350 | |
351 return EXIT_TO_MENU; | |
352 } | |
353 else if(action == ACTION_BUTTON_NEXT) | |
354 { | |
355 digitContent++; | |
356 if((digitNumber == 0) && (digitContent > '3')) | |
357 digitContent = '0'; | |
358 if(digitContent > '9') | |
359 digitContent = '0'; | |
360 } | |
361 else if(action == ACTION_BUTTON_BACK) | |
362 { | |
363 digitContent--; | |
364 if((digitNumber == 0) && (digitContent < '0')) | |
365 digitContent = '3'; | |
366 if(digitContent < '0') | |
367 digitContent = '9'; | |
368 } | |
369 | |
370 return digitContent; | |
371 } | |
372 | |
373 | |
374 void openEdit_PlanResult(void) | |
375 { | |
376 char text[256]; | |
377 | |
378 text[0] = '\001'; | |
379 text[1] = TXT_2BYTE; | |
380 text[2] = TXT2BYTE_Calculating; | |
381 text[3] = 0; | |
382 | |
383 write_topline(text); | |
384 | |
385 text[2] = TXT2BYTE_PleaseWait; | |
386 write_label_var( 10, 790, ME_Y_LINE1, &FontT42, text); | |
387 | |
388 SSettings *pSettings = settingsGetPointer(); | |
389 uint8_t tMplan_gasConsumTravel = pSettings->gasConsumption_travel_l_min; | |
390 uint8_t tMplan_gasConsumDeco = pSettings->gasConsumption_deco_l_min; | |
391 | |
392 resultPage = 0; | |
393 pDecoinfo = simulation_decoplaner(tMplan_depth_meter, tMplan_intervall_time_minutes, tMplan_dive_time_minutes, gasChangeListDepthGasId); | |
394 simulation_gas_consumption(tMplan_pGasConsumption, tMplan_depth_meter, tMplan_dive_time_minutes, pDecoinfo, tMplan_gasConsumTravel, tMplan_gasConsumDeco, gasChangeListDepthGasId); | |
395 simulation_helper_change_points(&tMplan_Summary, tMplan_depth_meter, tMplan_dive_time_minutes, pDecoinfo, gasChangeListDepthGasId); | |
396 | |
397 first = 0; | |
398 while((first < DECOINFO_STRUCT_MAX_STOPS-1) && pDecoinfo->output_stop_length_seconds[first+1]) | |
399 first++; | |
400 resultPage = 1; | |
401 | |
402 text[0] = TXT_2BYTE; | |
403 text[1] = TXT2BYTE_ButtonNext; | |
404 text[2] = 0; | |
405 write_field_button(StMPLAN5_ExitResult, 30, 800, ME_Y_LINE6, &FontT48, text); | |
406 setEvent(StMPLAN5_ExitResult, (uint32_t)OnAction_PlanResultExit); | |
407 } | |
408 | |
409 | |
410 | |
411 void refresh_PlanResult_helper(char *text, int start) | |
412 { | |
413 uint8_t depthPrev, depthNext, depthLast, depthSecond, depthInc, depthChange, GasIdPrev, GasIdNextList[3], ListCount, oxygen_percentage, textptr; | |
414 int lengthInMinutes; | |
415 | |
416 depthLast = (uint8_t)(stateUsed->diveSettings.last_stop_depth_bar * 10); | |
417 depthSecond = (uint8_t)(stateUsed->diveSettings.input_second_to_last_stop_depth_bar * 10); | |
418 depthInc = (uint8_t)(stateUsed->diveSettings.input_next_stop_increment_depth_bar * 10); | |
419 | |
420 | |
421 if((start < 0) || (start >= DECOINFO_STRUCT_MAX_STOPS)) | |
422 { | |
423 *text = 0; | |
424 return; | |
425 } | |
426 | |
427 if(start == 0) | |
428 { | |
429 depthNext = depthLast; | |
430 depthPrev = depthSecond; | |
431 } | |
432 else if(start == 1) | |
433 { | |
434 depthNext = depthSecond; | |
435 depthPrev = depthSecond + depthInc; | |
436 } | |
437 else | |
438 { | |
439 depthNext = depthSecond + (start - 1) * depthInc; | |
440 depthPrev = depthNext + depthInc; | |
441 } | |
442 | |
443 /* gas changes ? */ | |
444 GasIdPrev = 0; | |
445 ListCount = 0; | |
446 | |
447 for(int i = 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++) | |
448 { | |
449 if(stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0) | |
450 break; | |
451 depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; | |
452 if(depthPrev <= depthChange) | |
453 { | |
454 GasIdPrev = i; | |
455 } | |
456 else | |
457 { | |
458 break; | |
459 } | |
460 } | |
461 | |
462 for(int i = GasIdPrev + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++) | |
463 { | |
464 if(stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0) | |
465 break; | |
466 depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; | |
467 if((depthChange < depthPrev) && (depthChange >= depthNext)) | |
468 { | |
469 GasIdNextList[ListCount++] = i; | |
470 if(ListCount > 3) | |
471 break; | |
472 } | |
473 } | |
474 | |
475 /* text output */ | |
476 if(pDecoinfo->output_stop_length_seconds[start]) | |
477 { | |
478 textptr = snprintf(text,20,"\034%2u\016\016m\017 ",depthNext); | |
479 lengthInMinutes = (pDecoinfo->output_stop_length_seconds[start]+59)/60; | |
480 | |
481 int i = 0; | |
482 while((i<lengthInMinutes) && (i<15)) | |
483 { | |
484 text[textptr++] = '_'; | |
485 i++; | |
486 } | |
487 for(int j=i;j<15;j++) | |
488 { | |
489 text[textptr++] = '\177'; | |
490 text[textptr++] = '_'; | |
491 } | |
492 textptr += snprintf(&text[textptr],20," %3i'", lengthInMinutes); | |
493 } | |
494 else | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
495 textptr = snprintf(text,20,"\031\034%2u\016\016m\017 ",depthNext); |
38 | 496 |
497 for(int i = 0; i < ListCount; i++) | |
498 { | |
499 if(stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].setPoint_cbar != stateSimGetPointer()->diveSettings.decogaslist[GasIdPrev].setPoint_cbar) | |
500 snprintf(&text[textptr],20," %01.2f ", ((float)(stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].setPoint_cbar))/100); | |
501 else | |
502 { | |
503 oxygen_percentage = 100; | |
504 oxygen_percentage -= stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].nitrogen_percentage; | |
505 oxygen_percentage -= stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].helium_percentage; | |
506 | |
507 text[textptr++] = ' '; | |
508 textptr += tHome_gas_writer(oxygen_percentage, stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].helium_percentage, &text[textptr]); | |
509 text[textptr++] = ' '; | |
510 text[textptr] = 0; | |
511 } | |
512 GasIdPrev = GasIdNextList[i]; | |
513 } | |
514 } | |
515 | |
516 | |
517 void refresh_PlanResult(void) | |
518 { | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
519 char text[256]; |
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
520 uint8_t textpointer; |
38 | 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 | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
606 textpointer = snprintf(&text[textpointer],20,"-%u\016\016 m/min\017",tMplan_Summary.descentRateMeterPerMinute); |
38 | 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 | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
613 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m/min\017",tMplan_Summary.ascentRateMeterPerMinute); |
38 | 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) | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
632 text[textpointer++] = '\031'; |
38 | 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) | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
643 text[textpointer++] = '\031'; |
38 | 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: | |
662 | 673 if(isLoopMode(settingsGetPointer()->dive_mode)) |
38 | 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 } |