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