Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditPlanner.c @ 837:18946846b95b Evo_2_23
Bugfixes and code cleanup for BF views:
BF views gauge and apnoe were using "dive computer" T3 view functions which caused some problem because these legacy views were not intended to work with customer view selection. A switch condition has been added to skip these kind of functions in case a design other T3 is in use.
Another potential problem was that there were two definitions for T3 and T7 views which were basically the same. If they wold not be the same the switching functionality wold not work properly. To avoid this problem in futur the arrays have been merged => the view are handled sing the (newer) cv_view arrays instead of the standard_views which were in used before the user could the views which should be shown.
author | ideenmodellierer |
---|---|
date | Wed, 27 Dec 2023 19:37:17 +0100 |
parents | b7d93ff6b3b2 |
children | 07af9efd7c13 |
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); | |
410 } | |
411 | |
412 | |
413 | |
414 void refresh_PlanResult_helper(char *text, int start) | |
415 { | |
416 uint8_t depthPrev, depthNext, depthLast, depthSecond, depthInc, depthChange, GasIdPrev, GasIdNextList[3], ListCount, oxygen_percentage, textptr; | |
417 int lengthInMinutes; | |
418 | |
419 depthLast = (uint8_t)(stateUsed->diveSettings.last_stop_depth_bar * 10); | |
420 depthSecond = (uint8_t)(stateUsed->diveSettings.input_second_to_last_stop_depth_bar * 10); | |
421 depthInc = (uint8_t)(stateUsed->diveSettings.input_next_stop_increment_depth_bar * 10); | |
422 | |
423 | |
424 if((start < 0) || (start >= DECOINFO_STRUCT_MAX_STOPS)) | |
425 { | |
426 *text = 0; | |
427 return; | |
428 } | |
429 | |
430 if(start == 0) | |
431 { | |
432 depthNext = depthLast; | |
433 depthPrev = depthSecond; | |
434 } | |
435 else if(start == 1) | |
436 { | |
437 depthNext = depthSecond; | |
438 depthPrev = depthSecond + depthInc; | |
439 } | |
440 else | |
441 { | |
442 depthNext = depthSecond + (start - 1) * depthInc; | |
443 depthPrev = depthNext + depthInc; | |
444 } | |
445 | |
446 /* gas changes ? */ | |
447 GasIdPrev = 0; | |
448 ListCount = 0; | |
449 | |
450 for(int i = 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++) | |
451 { | |
830
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
805
diff
changeset
|
452 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
|
453 || (stateSimGetPointer()->diveSettings.gas[stateSimGetPointer()->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0)) |
38 | 454 break; |
455 depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; | |
456 if(depthPrev <= depthChange) | |
457 { | |
458 GasIdPrev = i; | |
459 } | |
460 else | |
461 { | |
462 break; | |
463 } | |
464 } | |
465 | |
466 for(int i = GasIdPrev + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++) | |
467 { | |
830
b7d93ff6b3b2
Added selection if an active gas shall be used for deco calculation or not:
Ideenmodellierer
parents:
805
diff
changeset
|
468 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
|
469 || (stateSimGetPointer()->diveSettings.gas[stateSimGetPointer()->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0)) |
38 | 470 break; |
471 depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; | |
472 if((depthChange < depthPrev) && (depthChange >= depthNext)) | |
473 { | |
474 GasIdNextList[ListCount++] = i; | |
475 if(ListCount > 3) | |
476 break; | |
477 } | |
478 } | |
479 | |
480 /* text output */ | |
481 if(pDecoinfo->output_stop_length_seconds[start]) | |
482 { | |
483 textptr = snprintf(text,20,"\034%2u\016\016m\017 ",depthNext); | |
484 lengthInMinutes = (pDecoinfo->output_stop_length_seconds[start]+59)/60; | |
485 | |
486 int i = 0; | |
487 while((i<lengthInMinutes) && (i<15)) | |
488 { | |
489 text[textptr++] = '_'; | |
490 i++; | |
491 } | |
492 for(int j=i;j<15;j++) | |
493 { | |
494 text[textptr++] = '\177'; | |
495 text[textptr++] = '_'; | |
496 } | |
497 textptr += snprintf(&text[textptr],20," %3i'", lengthInMinutes); | |
498 } | |
499 else | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
500 textptr = snprintf(text,20,"\031\034%2u\016\016m\017 ",depthNext); |
38 | 501 |
502 for(int i = 0; i < ListCount; i++) | |
503 { | |
504 if(stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].setPoint_cbar != stateSimGetPointer()->diveSettings.decogaslist[GasIdPrev].setPoint_cbar) | |
505 snprintf(&text[textptr],20," %01.2f ", ((float)(stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].setPoint_cbar))/100); | |
506 else | |
507 { | |
508 oxygen_percentage = 100; | |
509 oxygen_percentage -= stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].nitrogen_percentage; | |
510 oxygen_percentage -= stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].helium_percentage; | |
511 | |
512 text[textptr++] = ' '; | |
513 textptr += tHome_gas_writer(oxygen_percentage, stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].helium_percentage, &text[textptr]); | |
514 text[textptr++] = ' '; | |
515 text[textptr] = 0; | |
516 } | |
517 GasIdPrev = GasIdNextList[i]; | |
518 } | |
519 } | |
520 | |
521 | |
522 void refresh_PlanResult(void) | |
523 { | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
524 char text[256]; |
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
525 uint8_t textpointer; |
38 | 526 uint16_t y_line; |
527 uint8_t oxygen_percentage; | |
528 int now; | |
529 | |
530 if(resultPage < 0xF0) | |
531 { | |
532 textpointer = snprintf(text,256,"\001 %u' @ %um",tMplan_dive_time_minutes,tMplan_depth_meter); | |
533 if(tMplan_intervall_time_minutes) | |
534 snprintf(&text[textpointer],256-textpointer," in %u'",tMplan_intervall_time_minutes); | |
535 } | |
536 else if(resultPage == 0xFE) | |
537 { | |
538 textpointer = snprintf(text,30,"%c%c", TXT_2BYTE, TXT2BYTE_SimConsumption); | |
539 } | |
540 else | |
541 { | |
542 textpointer = snprintf(text,30,"%c%c", TXT_2BYTE, TXT2BYTE_SimSummary); | |
543 } | |
544 write_topline(text); | |
545 | |
546 switch (resultPage) | |
547 { | |
548 case 0: | |
549 break; | |
550 case 0xFF: // summary | |
551 for(int j=0;j<4;j++) | |
552 { | |
553 y_line = ME_Y_LINE_BASE + ((j + 1) * ME_Y_LINE_STEP); | |
554 | |
555 // text | |
556 textpointer = 0; | |
557 *text = 0; | |
558 text[textpointer] = 0; | |
559 text[textpointer++] = TXT_2BYTE; | |
560 text[textpointer++] = TXT2BYTE_SimDecTo + j; // see text_multilanguage.h | |
561 text[textpointer] = 0; | |
562 write_label_var( 10, 200, y_line, &FontT42, text); | |
563 | |
564 // depth | |
565 textpointer = 0; | |
566 *text = 0; | |
567 switch(j) | |
568 { | |
569 case 0: // descent | |
570 case 1: // level | |
571 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m\017",tMplan_depth_meter); | |
572 break; | |
573 case 2: // first stop | |
574 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m\017",tMplan_Summary.depthMeterFirstStop); | |
575 break; | |
576 default: | |
577 break; | |
578 } | |
579 text[textpointer] = 0; | |
580 write_label_var( 180, 400, y_line, &FontT42, text); | |
581 | |
582 // total time | |
583 textpointer = 0; | |
584 *text = 0; | |
585 switch(j) | |
586 { | |
587 case 0: // descent | |
588 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToBottom); | |
589 break; | |
590 case 1: // level | |
591 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeAtBottom); | |
592 break; | |
593 case 2: // first stop | |
594 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToFirstStop); | |
595 break; | |
596 case 3: // surface | |
597 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToSurface); | |
598 break; | |
599 default: | |
600 break; | |
601 } | |
602 text[textpointer] = 0; | |
603 write_label_var( 320, 500, y_line, &FontT42, text); | |
604 | |
605 // ascent or descent rate or ppO2@bottom | |
606 textpointer = 0; | |
607 *text = 0; | |
608 switch(j) | |
609 { | |
610 case 0: // descent | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
611 textpointer = snprintf(&text[textpointer],20,"-%u\016\016 m/min\017",tMplan_Summary.descentRateMeterPerMinute); |
38 | 612 break; |
613 case 1: // level | |
614 textpointer = snprintf(&text[textpointer],20,"%1.2f\016\016 %c\017",tMplan_Summary.ppO2AtBottom, TXT_ppO2); | |
615 break; | |
616 case 2: // first stop | |
617 case 3: // surface | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
618 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m/min\017",tMplan_Summary.ascentRateMeterPerMinute); |
38 | 619 break; |
620 default: | |
621 break; | |
622 } | |
623 text[textpointer] = 0; | |
624 write_label_var( 500, 800, y_line, &FontT42, text); | |
625 } | |
626 break; | |
627 case 0xFE: // gas consumption | |
628 for(int j=1;j<6;j++) | |
629 { | |
630 y_line = ME_Y_LINE_BASE + ((j + 0) * ME_Y_LINE_STEP); | |
631 | |
632 textpointer = 0; | |
633 *text = 0; | |
634 text[textpointer] = 0; | |
635 | |
636 if(tMplan_pGasConsumption[j] == 0) | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
637 text[textpointer++] = '\031'; |
38 | 638 |
639 textpointer += write_gas(&text[textpointer], settingsGetPointer()->gas[j].oxygen_percentage, settingsGetPointer()->gas[j].helium_percentage ); | |
640 text[textpointer] = 0; | |
641 write_label_var( 10, 390, y_line, &FontT42, text); | |
642 | |
643 textpointer = 0; | |
644 *text = 0; | |
645 text[textpointer] = 0; | |
646 | |
647 if(tMplan_pGasConsumption[j] == 0) | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
648 text[textpointer++] = '\031'; |
38 | 649 |
650 textpointer += snprintf(&text[textpointer],20,"\002%u\016\016 ltr\017",tMplan_pGasConsumption[j]); | |
651 text[textpointer] = 0; | |
652 write_label_var( 350, 560, y_line, &FontT42, text); | |
653 } | |
654 break; | |
655 | |
656 default: | |
657 now = first -(5*(resultPage-1)); | |
658 for(int j=0;j<5;j++) | |
659 { | |
660 /* deco list */ | |
661 refresh_PlanResult_helper(text, now-j); | |
662 y_line = ME_Y_LINE_BASE + ((j + 1) * ME_Y_LINE_STEP); | |
663 if(*text != 0) | |
664 write_label_var( 300, 790, y_line, &FontT42, text); | |
665 | |
666 /* common infos */ | |
667 textpointer = 0; | |
668 *text = 0; | |
669 switch (j) | |
670 { | |
671 case 0: | |
672 if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) | |
673 textpointer += snprintf(&text[textpointer],20,"VPM +%u",stateUsed->diveSettings.vpm_conservatism); | |
674 else | |
675 textpointer += snprintf(&text[textpointer],20,"GF %u/%u", stateUsed->diveSettings.gf_low, stateUsed->diveSettings.gf_high); | |
676 break; | |
677 case 1: | |
662 | 678 if(isLoopMode(settingsGetPointer()->dive_mode)) |
38 | 679 text[textpointer++] = 'C'; |
680 else | |
681 text[textpointer++] = 'O'; | |
682 text[textpointer++] = 'C'; | |
683 text[textpointer++] = ','; | |
684 text[textpointer++] = ' '; | |
685 oxygen_percentage = 100; | |
686 oxygen_percentage -= stateSimGetPointer()->lifeData.actualGas.nitrogen_percentage; | |
687 oxygen_percentage -= stateSimGetPointer()->lifeData.actualGas.helium_percentage; | |
688 textpointer += tHome_gas_writer(oxygen_percentage, stateSimGetPointer()->lifeData.actualGas.helium_percentage, &text[textpointer]); | |
689 break; | |
690 case 2: | |
691 textpointer += snprintf(&text[textpointer],20,"TTS: %u'", ((pDecoinfo->output_time_to_surface_seconds+59)/60)); | |
692 // alt: textpointer += snprintf(&text[textpointer],20,"TTS: %u'",tMplan_dive_time_minutes + ((pDecoinfo->output_time_to_surface_seconds+59)/60)); | |
693 break; | |
694 case 3: | |
695 textpointer += snprintf(&text[textpointer],20,"CNS:"); | |
696 break; | |
697 case 4: | |
698 textpointer += snprintf(&text[textpointer],20,"%.0f%%->%.0f%%",stateRealGetPointer()->lifeData.cns,stateSimGetPointer()->lifeData.cns); | |
699 break; | |
700 } | |
701 text[textpointer] = 0; | |
702 if(*text != 0) | |
703 write_label_var( 10, 790, y_line, &FontT42, text); | |
704 } | |
705 break; | |
706 }; | |
707 | |
708 text[0] = TXT_2BYTE; | |
709 // if(first < (resultPage * 5)) | |
710 if(resultPage == 0xFF) | |
711 text[1] = TXT2BYTE_Exit; | |
712 else | |
713 text[1] = TXT2BYTE_ButtonNext; | |
714 text[2] = 0; | |
715 tMenuEdit_newButtonText(StMPLAN5_ExitResult, text); | |
716 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonNext,0); | |
717 } | |
718 | |
719 uint8_t OnAction_PlanResultExit (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
720 { | |
721 resetEnterPressedToStateBeforeButtonAction(); | |
722 if(resultPage == 0xFF) // last extra page | |
723 { | |
724 resultPage = 0; | |
725 return EXIT_TO_MENU; | |
726 } | |
727 if(resultPage >= 0xF0) | |
728 { | |
729 resultPage++; | |
730 return UNSPECIFIC_RETURN; | |
731 } | |
732 else if(first < (resultPage * 5)) | |
733 { | |
734 resultPage = 0xFE; | |
735 return UNSPECIFIC_RETURN; | |
736 } | |
737 else | |
738 { | |
739 resultPage++; | |
740 return UNSPECIFIC_RETURN; | |
741 } | |
742 } |