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