Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditPlanner.c @ 809:9602a7338f28
DevBugfix CO2 sensor in streaming mode:
In standalone mode (no multiplexer) the CO2 sensor is working in streaming mode => it could happen that the OSTC received data before the scaling factor was requested. As result the CO2 values were calculated with a zero value. This problem has been fixed.
In addition some code cleanup has been done. Unifying usage of changeBaudrate function instead of old baud selection based on protocol request of Discovery firmware.
author | Ideenmodellierer |
---|---|
date | Sun, 27 Aug 2023 20:51:13 +0200 |
parents | dd7ce655db26 |
children | b7d93ff6b3b2 |
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 { | |
452 if(stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0) | |
453 break; | |
454 depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; | |
455 if(depthPrev <= depthChange) | |
456 { | |
457 GasIdPrev = i; | |
458 } | |
459 else | |
460 { | |
461 break; | |
462 } | |
463 } | |
464 | |
465 for(int i = GasIdPrev + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++) | |
466 { | |
467 if(stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0) | |
468 break; | |
469 depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; | |
470 if((depthChange < depthPrev) && (depthChange >= depthNext)) | |
471 { | |
472 GasIdNextList[ListCount++] = i; | |
473 if(ListCount > 3) | |
474 break; | |
475 } | |
476 } | |
477 | |
478 /* text output */ | |
479 if(pDecoinfo->output_stop_length_seconds[start]) | |
480 { | |
481 textptr = snprintf(text,20,"\034%2u\016\016m\017 ",depthNext); | |
482 lengthInMinutes = (pDecoinfo->output_stop_length_seconds[start]+59)/60; | |
483 | |
484 int i = 0; | |
485 while((i<lengthInMinutes) && (i<15)) | |
486 { | |
487 text[textptr++] = '_'; | |
488 i++; | |
489 } | |
490 for(int j=i;j<15;j++) | |
491 { | |
492 text[textptr++] = '\177'; | |
493 text[textptr++] = '_'; | |
494 } | |
495 textptr += snprintf(&text[textptr],20," %3i'", lengthInMinutes); | |
496 } | |
497 else | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
498 textptr = snprintf(text,20,"\031\034%2u\016\016m\017 ",depthNext); |
38 | 499 |
500 for(int i = 0; i < ListCount; i++) | |
501 { | |
502 if(stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].setPoint_cbar != stateSimGetPointer()->diveSettings.decogaslist[GasIdPrev].setPoint_cbar) | |
503 snprintf(&text[textptr],20," %01.2f ", ((float)(stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].setPoint_cbar))/100); | |
504 else | |
505 { | |
506 oxygen_percentage = 100; | |
507 oxygen_percentage -= stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].nitrogen_percentage; | |
508 oxygen_percentage -= stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].helium_percentage; | |
509 | |
510 text[textptr++] = ' '; | |
511 textptr += tHome_gas_writer(oxygen_percentage, stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].helium_percentage, &text[textptr]); | |
512 text[textptr++] = ' '; | |
513 text[textptr] = 0; | |
514 } | |
515 GasIdPrev = GasIdNextList[i]; | |
516 } | |
517 } | |
518 | |
519 | |
520 void refresh_PlanResult(void) | |
521 { | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
522 char text[256]; |
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
523 uint8_t textpointer; |
38 | 524 uint16_t y_line; |
525 uint8_t oxygen_percentage; | |
526 int now; | |
527 | |
528 if(resultPage < 0xF0) | |
529 { | |
530 textpointer = snprintf(text,256,"\001 %u' @ %um",tMplan_dive_time_minutes,tMplan_depth_meter); | |
531 if(tMplan_intervall_time_minutes) | |
532 snprintf(&text[textpointer],256-textpointer," in %u'",tMplan_intervall_time_minutes); | |
533 } | |
534 else if(resultPage == 0xFE) | |
535 { | |
536 textpointer = snprintf(text,30,"%c%c", TXT_2BYTE, TXT2BYTE_SimConsumption); | |
537 } | |
538 else | |
539 { | |
540 textpointer = snprintf(text,30,"%c%c", TXT_2BYTE, TXT2BYTE_SimSummary); | |
541 } | |
542 write_topline(text); | |
543 | |
544 switch (resultPage) | |
545 { | |
546 case 0: | |
547 break; | |
548 case 0xFF: // summary | |
549 for(int j=0;j<4;j++) | |
550 { | |
551 y_line = ME_Y_LINE_BASE + ((j + 1) * ME_Y_LINE_STEP); | |
552 | |
553 // text | |
554 textpointer = 0; | |
555 *text = 0; | |
556 text[textpointer] = 0; | |
557 text[textpointer++] = TXT_2BYTE; | |
558 text[textpointer++] = TXT2BYTE_SimDecTo + j; // see text_multilanguage.h | |
559 text[textpointer] = 0; | |
560 write_label_var( 10, 200, y_line, &FontT42, text); | |
561 | |
562 // depth | |
563 textpointer = 0; | |
564 *text = 0; | |
565 switch(j) | |
566 { | |
567 case 0: // descent | |
568 case 1: // level | |
569 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m\017",tMplan_depth_meter); | |
570 break; | |
571 case 2: // first stop | |
572 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m\017",tMplan_Summary.depthMeterFirstStop); | |
573 break; | |
574 default: | |
575 break; | |
576 } | |
577 text[textpointer] = 0; | |
578 write_label_var( 180, 400, y_line, &FontT42, text); | |
579 | |
580 // total time | |
581 textpointer = 0; | |
582 *text = 0; | |
583 switch(j) | |
584 { | |
585 case 0: // descent | |
586 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToBottom); | |
587 break; | |
588 case 1: // level | |
589 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeAtBottom); | |
590 break; | |
591 case 2: // first stop | |
592 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToFirstStop); | |
593 break; | |
594 case 3: // surface | |
595 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToSurface); | |
596 break; | |
597 default: | |
598 break; | |
599 } | |
600 text[textpointer] = 0; | |
601 write_label_var( 320, 500, y_line, &FontT42, text); | |
602 | |
603 // ascent or descent rate or ppO2@bottom | |
604 textpointer = 0; | |
605 *text = 0; | |
606 switch(j) | |
607 { | |
608 case 0: // descent | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
609 textpointer = snprintf(&text[textpointer],20,"-%u\016\016 m/min\017",tMplan_Summary.descentRateMeterPerMinute); |
38 | 610 break; |
611 case 1: // level | |
612 textpointer = snprintf(&text[textpointer],20,"%1.2f\016\016 %c\017",tMplan_Summary.ppO2AtBottom, TXT_ppO2); | |
613 break; | |
614 case 2: // first stop | |
615 case 3: // surface | |
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
616 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m/min\017",tMplan_Summary.ascentRateMeterPerMinute); |
38 | 617 break; |
618 default: | |
619 break; | |
620 } | |
621 text[textpointer] = 0; | |
622 write_label_var( 500, 800, y_line, &FontT42, text); | |
623 } | |
624 break; | |
625 case 0xFE: // gas consumption | |
626 for(int j=1;j<6;j++) | |
627 { | |
628 y_line = ME_Y_LINE_BASE + ((j + 0) * ME_Y_LINE_STEP); | |
629 | |
630 textpointer = 0; | |
631 *text = 0; | |
632 text[textpointer] = 0; | |
633 | |
634 if(tMplan_pGasConsumption[j] == 0) | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
635 text[textpointer++] = '\031'; |
38 | 636 |
637 textpointer += write_gas(&text[textpointer], settingsGetPointer()->gas[j].oxygen_percentage, settingsGetPointer()->gas[j].helium_percentage ); | |
638 text[textpointer] = 0; | |
639 write_label_var( 10, 390, y_line, &FontT42, text); | |
640 | |
641 textpointer = 0; | |
642 *text = 0; | |
643 text[textpointer] = 0; | |
644 | |
645 if(tMplan_pGasConsumption[j] == 0) | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
646 text[textpointer++] = '\031'; |
38 | 647 |
648 textpointer += snprintf(&text[textpointer],20,"\002%u\016\016 ltr\017",tMplan_pGasConsumption[j]); | |
649 text[textpointer] = 0; | |
650 write_label_var( 350, 560, y_line, &FontT42, text); | |
651 } | |
652 break; | |
653 | |
654 default: | |
655 now = first -(5*(resultPage-1)); | |
656 for(int j=0;j<5;j++) | |
657 { | |
658 /* deco list */ | |
659 refresh_PlanResult_helper(text, now-j); | |
660 y_line = ME_Y_LINE_BASE + ((j + 1) * ME_Y_LINE_STEP); | |
661 if(*text != 0) | |
662 write_label_var( 300, 790, y_line, &FontT42, text); | |
663 | |
664 /* common infos */ | |
665 textpointer = 0; | |
666 *text = 0; | |
667 switch (j) | |
668 { | |
669 case 0: | |
670 if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) | |
671 textpointer += snprintf(&text[textpointer],20,"VPM +%u",stateUsed->diveSettings.vpm_conservatism); | |
672 else | |
673 textpointer += snprintf(&text[textpointer],20,"GF %u/%u", stateUsed->diveSettings.gf_low, stateUsed->diveSettings.gf_high); | |
674 break; | |
675 case 1: | |
662 | 676 if(isLoopMode(settingsGetPointer()->dive_mode)) |
38 | 677 text[textpointer++] = 'C'; |
678 else | |
679 text[textpointer++] = 'O'; | |
680 text[textpointer++] = 'C'; | |
681 text[textpointer++] = ','; | |
682 text[textpointer++] = ' '; | |
683 oxygen_percentage = 100; | |
684 oxygen_percentage -= stateSimGetPointer()->lifeData.actualGas.nitrogen_percentage; | |
685 oxygen_percentage -= stateSimGetPointer()->lifeData.actualGas.helium_percentage; | |
686 textpointer += tHome_gas_writer(oxygen_percentage, stateSimGetPointer()->lifeData.actualGas.helium_percentage, &text[textpointer]); | |
687 break; | |
688 case 2: | |
689 textpointer += snprintf(&text[textpointer],20,"TTS: %u'", ((pDecoinfo->output_time_to_surface_seconds+59)/60)); | |
690 // alt: textpointer += snprintf(&text[textpointer],20,"TTS: %u'",tMplan_dive_time_minutes + ((pDecoinfo->output_time_to_surface_seconds+59)/60)); | |
691 break; | |
692 case 3: | |
693 textpointer += snprintf(&text[textpointer],20,"CNS:"); | |
694 break; | |
695 case 4: | |
696 textpointer += snprintf(&text[textpointer],20,"%.0f%%->%.0f%%",stateRealGetPointer()->lifeData.cns,stateSimGetPointer()->lifeData.cns); | |
697 break; | |
698 } | |
699 text[textpointer] = 0; | |
700 if(*text != 0) | |
701 write_label_var( 10, 790, y_line, &FontT42, text); | |
702 } | |
703 break; | |
704 }; | |
705 | |
706 text[0] = TXT_2BYTE; | |
707 // if(first < (resultPage * 5)) | |
708 if(resultPage == 0xFF) | |
709 text[1] = TXT2BYTE_Exit; | |
710 else | |
711 text[1] = TXT2BYTE_ButtonNext; | |
712 text[2] = 0; | |
713 tMenuEdit_newButtonText(StMPLAN5_ExitResult, text); | |
714 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonNext,0); | |
715 } | |
716 | |
717 uint8_t OnAction_PlanResultExit (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
718 { | |
719 resetEnterPressedToStateBeforeButtonAction(); | |
720 if(resultPage == 0xFF) // last extra page | |
721 { | |
722 resultPage = 0; | |
723 return EXIT_TO_MENU; | |
724 } | |
725 if(resultPage >= 0xF0) | |
726 { | |
727 resultPage++; | |
728 return UNSPECIFIC_RETURN; | |
729 } | |
730 else if(first < (resultPage * 5)) | |
731 { | |
732 resultPage = 0xFE; | |
733 return UNSPECIFIC_RETURN; | |
734 } | |
735 else | |
736 { | |
737 resultPage++; | |
738 return UNSPECIFIC_RETURN; | |
739 } | |
740 } |