Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditPlanner.c @ 985:aeafa631147d BootloaderOstc5
Exchange shared files with Bootloader specific mini version
| author | Ideenmodellierer |
|---|---|
| date | Sun, 30 Mar 2025 21:32:37 +0200 |
| parents | 7891160acde3 |
| children | 8c0134a287da |
| 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); |
| 399 simulation_evaluate_profil( &tMplan_pGasConsumption, | |
| 400 &tMplan_Summary, | |
| 401 tMplan_depth_meter, tMplan_dive_time_minutes, tMplan_gasConsumTravel, tMplan_gasConsumDeco, | |
| 402 pDecoinfo, | |
| 403 gasChangeList); | |
| 404 // simulation_gas_consumption(tMplan_pGasConsumption, tMplan_depth_meter, tMplan_dive_time_minutes, pDecoinfo, tMplan_gasConsumTravel, tMplan_gasConsumDeco, gasChangeList); | |
| 405 // simulation_helper_change_points(&tMplan_Summary, tMplan_depth_meter, tMplan_dive_time_minutes, pDecoinfo, gasChangeListDepth); | |
| 38 | 406 |
| 407 first = 0; | |
| 408 while((first < DECOINFO_STRUCT_MAX_STOPS-1) && pDecoinfo->output_stop_length_seconds[first+1]) | |
| 409 first++; | |
| 410 resultPage = 1; | |
| 411 | |
| 412 text[0] = TXT_2BYTE; | |
| 413 text[1] = TXT2BYTE_ButtonNext; | |
| 414 text[2] = 0; | |
| 415 write_field_button(StMPLAN5_ExitResult, 30, 800, ME_Y_LINE6, &FontT48, text); | |
| 416 setEvent(StMPLAN5_ExitResult, (uint32_t)OnAction_PlanResultExit); | |
|
888
07af9efd7c13
Dev bugfix: Consider decogas in planner independen from calculation setting:
Ideenmodellierer
parents:
830
diff
changeset
|
417 tMenuEdit_select(StMPLAN5_ExitResult); |
| 38 | 418 } |
| 419 | |
| 420 | |
| 421 | |
| 422 void refresh_PlanResult_helper(char *text, int start) | |
| 423 { | |
| 424 uint8_t depthPrev, depthNext, depthLast, depthSecond, depthInc, depthChange, GasIdPrev, GasIdNextList[3], ListCount, oxygen_percentage, textptr; | |
| 425 int lengthInMinutes; | |
| 426 | |
| 427 depthLast = (uint8_t)(stateUsed->diveSettings.last_stop_depth_bar * 10); | |
| 428 depthSecond = (uint8_t)(stateUsed->diveSettings.input_second_to_last_stop_depth_bar * 10); | |
| 429 depthInc = (uint8_t)(stateUsed->diveSettings.input_next_stop_increment_depth_bar * 10); | |
| 430 | |
| 431 | |
| 432 if((start < 0) || (start >= DECOINFO_STRUCT_MAX_STOPS)) | |
| 433 { | |
| 434 *text = 0; | |
| 435 return; | |
| 436 } | |
| 437 | |
| 438 if(start == 0) | |
| 439 { | |
| 440 depthNext = depthLast; | |
| 441 depthPrev = depthSecond; | |
| 442 } | |
| 443 else if(start == 1) | |
| 444 { | |
| 445 depthNext = depthSecond; | |
| 446 depthPrev = depthSecond + depthInc; | |
| 447 } | |
| 448 else | |
| 449 { | |
| 450 depthNext = depthSecond + (start - 1) * depthInc; | |
| 451 depthPrev = depthNext + depthInc; | |
| 452 } | |
| 453 | |
| 454 /* gas changes ? */ | |
| 455 GasIdPrev = 0; | |
| 456 ListCount = 0; | |
| 457 | |
| 458 for(int i = 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++) | |
| 459 { | |
| 983 | 460 if(stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0) |
| 38 | 461 break; |
| 462 depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; | |
| 463 if(depthPrev <= depthChange) | |
| 464 { | |
| 465 GasIdPrev = i; | |
| 466 } | |
| 467 else | |
| 468 { | |
| 469 break; | |
| 470 } | |
| 471 } | |
| 472 | |
| 473 for(int i = GasIdPrev + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++) | |
| 474 { | |
| 983 | 475 if(stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0) |
| 38 | 476 break; |
| 477 depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; | |
| 478 if((depthChange < depthPrev) && (depthChange >= depthNext)) | |
| 479 { | |
| 480 GasIdNextList[ListCount++] = i; | |
| 481 if(ListCount > 3) | |
| 482 break; | |
| 483 } | |
| 484 } | |
| 485 | |
| 486 /* text output */ | |
| 487 if(pDecoinfo->output_stop_length_seconds[start]) | |
| 488 { | |
| 489 textptr = snprintf(text,20,"\034%2u\016\016m\017 ",depthNext); | |
| 490 lengthInMinutes = (pDecoinfo->output_stop_length_seconds[start]+59)/60; | |
| 491 | |
| 492 int i = 0; | |
| 493 while((i<lengthInMinutes) && (i<15)) | |
| 494 { | |
| 495 text[textptr++] = '_'; | |
| 496 i++; | |
| 497 } | |
| 498 for(int j=i;j<15;j++) | |
| 499 { | |
| 500 text[textptr++] = '\177'; | |
| 501 text[textptr++] = '_'; | |
| 502 } | |
| 503 textptr += snprintf(&text[textptr],20," %3i'", lengthInMinutes); | |
| 504 } | |
| 505 else | |
|
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
506 textptr = snprintf(text,20,"\031\034%2u\016\016m\017 ",depthNext); |
| 38 | 507 |
| 508 for(int i = 0; i < ListCount; i++) | |
| 509 { | |
| 510 if(stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].setPoint_cbar != stateSimGetPointer()->diveSettings.decogaslist[GasIdPrev].setPoint_cbar) | |
| 511 snprintf(&text[textptr],20," %01.2f ", ((float)(stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].setPoint_cbar))/100); | |
| 512 else | |
| 513 { | |
| 514 oxygen_percentage = 100; | |
| 515 oxygen_percentage -= stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].nitrogen_percentage; | |
| 516 oxygen_percentage -= stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].helium_percentage; | |
| 517 | |
| 518 text[textptr++] = ' '; | |
| 519 textptr += tHome_gas_writer(oxygen_percentage, stateSimGetPointer()->diveSettings.decogaslist[GasIdNextList[i]].helium_percentage, &text[textptr]); | |
| 520 text[textptr++] = ' '; | |
| 521 text[textptr] = 0; | |
| 522 } | |
| 523 GasIdPrev = GasIdNextList[i]; | |
| 524 } | |
| 525 } | |
| 526 | |
| 527 | |
| 528 void refresh_PlanResult(void) | |
| 529 { | |
|
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
530 char text[256]; |
|
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
531 uint8_t textpointer; |
| 38 | 532 uint16_t y_line; |
| 533 uint8_t oxygen_percentage; | |
| 534 int now; | |
| 535 | |
| 536 if(resultPage < 0xF0) | |
| 537 { | |
| 538 textpointer = snprintf(text,256,"\001 %u' @ %um",tMplan_dive_time_minutes,tMplan_depth_meter); | |
| 539 if(tMplan_intervall_time_minutes) | |
| 540 snprintf(&text[textpointer],256-textpointer," in %u'",tMplan_intervall_time_minutes); | |
| 541 } | |
| 542 else if(resultPage == 0xFE) | |
| 543 { | |
| 544 textpointer = snprintf(text,30,"%c%c", TXT_2BYTE, TXT2BYTE_SimConsumption); | |
| 545 } | |
| 546 else | |
| 547 { | |
| 548 textpointer = snprintf(text,30,"%c%c", TXT_2BYTE, TXT2BYTE_SimSummary); | |
| 549 } | |
| 550 write_topline(text); | |
| 551 | |
| 552 switch (resultPage) | |
| 553 { | |
| 554 case 0: | |
| 555 break; | |
| 556 case 0xFF: // summary | |
| 557 for(int j=0;j<4;j++) | |
| 558 { | |
| 559 y_line = ME_Y_LINE_BASE + ((j + 1) * ME_Y_LINE_STEP); | |
| 560 | |
| 561 // text | |
| 562 textpointer = 0; | |
| 563 *text = 0; | |
| 564 text[textpointer] = 0; | |
| 565 text[textpointer++] = TXT_2BYTE; | |
| 566 text[textpointer++] = TXT2BYTE_SimDecTo + j; // see text_multilanguage.h | |
| 567 text[textpointer] = 0; | |
| 568 write_label_var( 10, 200, y_line, &FontT42, text); | |
| 569 | |
| 570 // depth | |
| 571 textpointer = 0; | |
| 572 *text = 0; | |
| 573 switch(j) | |
| 574 { | |
| 575 case 0: // descent | |
| 576 case 1: // level | |
| 577 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m\017",tMplan_depth_meter); | |
| 578 break; | |
| 579 case 2: // first stop | |
| 580 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m\017",tMplan_Summary.depthMeterFirstStop); | |
| 581 break; | |
| 582 default: | |
| 583 break; | |
| 584 } | |
| 585 text[textpointer] = 0; | |
| 586 write_label_var( 180, 400, y_line, &FontT42, text); | |
| 587 | |
| 588 // total time | |
| 589 textpointer = 0; | |
| 590 *text = 0; | |
| 591 switch(j) | |
| 592 { | |
| 593 case 0: // descent | |
| 594 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToBottom); | |
| 595 break; | |
| 596 case 1: // level | |
| 597 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeAtBottom); | |
| 598 break; | |
| 599 case 2: // first stop | |
| 600 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToFirstStop); | |
| 601 break; | |
| 602 case 3: // surface | |
| 603 textpointer = snprintf(&text[textpointer],20,"(%u')",tMplan_Summary.timeToSurface); | |
| 604 break; | |
| 605 default: | |
| 606 break; | |
| 607 } | |
| 608 text[textpointer] = 0; | |
| 609 write_label_var( 320, 500, y_line, &FontT42, text); | |
| 610 | |
| 611 // ascent or descent rate or ppO2@bottom | |
| 612 textpointer = 0; | |
| 613 *text = 0; | |
| 614 switch(j) | |
| 615 { | |
| 616 case 0: // descent | |
|
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
617 textpointer = snprintf(&text[textpointer],20,"-%u\016\016 m/min\017",tMplan_Summary.descentRateMeterPerMinute); |
| 38 | 618 break; |
| 619 case 1: // level | |
| 620 textpointer = snprintf(&text[textpointer],20,"%1.2f\016\016 %c\017",tMplan_Summary.ppO2AtBottom, TXT_ppO2); | |
| 621 break; | |
| 622 case 2: // first stop | |
| 623 case 3: // surface | |
|
679
52df13712fa3
cleanup: Use correct "per" symbol
Jan Mulder <jan@jlmulder.nl>
parents:
662
diff
changeset
|
624 textpointer = snprintf(&text[textpointer],20,"%u\016\016 m/min\017",tMplan_Summary.ascentRateMeterPerMinute); |
| 38 | 625 break; |
| 626 default: | |
| 627 break; | |
| 628 } | |
| 629 text[textpointer] = 0; | |
| 630 write_label_var( 500, 800, y_line, &FontT42, text); | |
| 631 } | |
| 632 break; | |
| 633 case 0xFE: // gas consumption | |
| 634 for(int j=1;j<6;j++) | |
| 635 { | |
| 636 y_line = ME_Y_LINE_BASE + ((j + 0) * ME_Y_LINE_STEP); | |
| 637 | |
| 638 textpointer = 0; | |
| 639 *text = 0; | |
| 640 text[textpointer] = 0; | |
| 641 | |
| 642 if(tMplan_pGasConsumption[j] == 0) | |
|
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
643 text[textpointer++] = '\031'; |
| 38 | 644 |
| 645 textpointer += write_gas(&text[textpointer], settingsGetPointer()->gas[j].oxygen_percentage, settingsGetPointer()->gas[j].helium_percentage ); | |
| 646 text[textpointer] = 0; | |
| 647 write_label_var( 10, 390, y_line, &FontT42, text); | |
| 648 | |
| 649 textpointer = 0; | |
| 650 *text = 0; | |
| 651 text[textpointer] = 0; | |
| 652 | |
| 653 if(tMplan_pGasConsumption[j] == 0) | |
|
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
166
diff
changeset
|
654 text[textpointer++] = '\031'; |
| 38 | 655 |
| 656 textpointer += snprintf(&text[textpointer],20,"\002%u\016\016 ltr\017",tMplan_pGasConsumption[j]); | |
| 657 text[textpointer] = 0; | |
| 658 write_label_var( 350, 560, y_line, &FontT42, text); | |
| 659 } | |
| 660 break; | |
| 661 | |
| 662 default: | |
| 663 now = first -(5*(resultPage-1)); | |
| 664 for(int j=0;j<5;j++) | |
| 665 { | |
| 666 /* deco list */ | |
| 667 refresh_PlanResult_helper(text, now-j); | |
| 668 y_line = ME_Y_LINE_BASE + ((j + 1) * ME_Y_LINE_STEP); | |
| 669 if(*text != 0) | |
| 670 write_label_var( 300, 790, y_line, &FontT42, text); | |
| 671 | |
| 672 /* common infos */ | |
| 673 textpointer = 0; | |
| 674 *text = 0; | |
| 675 switch (j) | |
| 676 { | |
| 677 case 0: | |
| 678 if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) | |
| 679 textpointer += snprintf(&text[textpointer],20,"VPM +%u",stateUsed->diveSettings.vpm_conservatism); | |
| 680 else | |
| 681 textpointer += snprintf(&text[textpointer],20,"GF %u/%u", stateUsed->diveSettings.gf_low, stateUsed->diveSettings.gf_high); | |
| 682 break; | |
| 683 case 1: | |
| 662 | 684 if(isLoopMode(settingsGetPointer()->dive_mode)) |
| 38 | 685 text[textpointer++] = 'C'; |
| 686 else | |
| 687 text[textpointer++] = 'O'; | |
| 688 text[textpointer++] = 'C'; | |
| 689 text[textpointer++] = ','; | |
| 690 text[textpointer++] = ' '; | |
| 691 oxygen_percentage = 100; | |
| 692 oxygen_percentage -= stateSimGetPointer()->lifeData.actualGas.nitrogen_percentage; | |
| 693 oxygen_percentage -= stateSimGetPointer()->lifeData.actualGas.helium_percentage; | |
| 694 textpointer += tHome_gas_writer(oxygen_percentage, stateSimGetPointer()->lifeData.actualGas.helium_percentage, &text[textpointer]); | |
| 695 break; | |
| 696 case 2: | |
| 697 textpointer += snprintf(&text[textpointer],20,"TTS: %u'", ((pDecoinfo->output_time_to_surface_seconds+59)/60)); | |
| 698 // alt: textpointer += snprintf(&text[textpointer],20,"TTS: %u'",tMplan_dive_time_minutes + ((pDecoinfo->output_time_to_surface_seconds+59)/60)); | |
| 699 break; | |
| 700 case 3: | |
| 701 textpointer += snprintf(&text[textpointer],20,"CNS:"); | |
| 702 break; | |
| 703 case 4: | |
| 704 textpointer += snprintf(&text[textpointer],20,"%.0f%%->%.0f%%",stateRealGetPointer()->lifeData.cns,stateSimGetPointer()->lifeData.cns); | |
| 705 break; | |
| 706 } | |
| 707 text[textpointer] = 0; | |
| 708 if(*text != 0) | |
| 709 write_label_var( 10, 790, y_line, &FontT42, text); | |
| 710 } | |
| 711 break; | |
| 712 }; | |
| 713 | |
| 714 text[0] = TXT_2BYTE; | |
| 715 // if(first < (resultPage * 5)) | |
| 716 if(resultPage == 0xFF) | |
| 717 text[1] = TXT2BYTE_Exit; | |
| 718 else | |
| 719 text[1] = TXT2BYTE_ButtonNext; | |
| 720 text[2] = 0; | |
| 721 tMenuEdit_newButtonText(StMPLAN5_ExitResult, text); | |
| 722 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonNext,0); | |
| 723 } | |
| 724 | |
| 725 uint8_t OnAction_PlanResultExit (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
| 726 { | |
| 727 resetEnterPressedToStateBeforeButtonAction(); | |
| 728 if(resultPage == 0xFF) // last extra page | |
| 729 { | |
| 730 resultPage = 0; | |
| 731 return EXIT_TO_MENU; | |
| 732 } | |
| 733 if(resultPage >= 0xF0) | |
| 734 { | |
| 735 resultPage++; | |
| 736 return UNSPECIFIC_RETURN; | |
| 737 } | |
| 738 else if(first < (resultPage * 5)) | |
| 739 { | |
| 740 resultPage = 0xFE; | |
| 741 return UNSPECIFIC_RETURN; | |
| 742 } | |
| 743 else | |
| 744 { | |
| 745 resultPage++; | |
| 746 return UNSPECIFIC_RETURN; | |
| 747 } | |
| 748 } |
