38
+ − 1 ///////////////////////////////////////////////////////////////////////////////
+ − 2 /// -*- coding: UTF-8 -*-
+ − 3 ///
+ − 4 /// \file Discovery/Src/tMenuEditDecoParameter.c
+ − 5 /// \brief Main Template file for Menu Edit Deco Parameters
+ − 6 /// \author heinrichs weikamp gmbh
+ − 7 /// \date 31-July-2014
+ − 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 "tMenuEditDecoParameter.h"
+ − 31
+ − 32 #include "gfx_fonts.h"
+ − 33 #include "tMenuEdit.h"
+ − 34 #include "unit.h" // last stop in meter and feet
+ − 35
902
+ − 36 #define MEDP_TAB (525)
38
+ − 37
+ − 38 /* Private function prototypes -----------------------------------------------*/
288
+ − 39 static void openEdit_DecoAlgorithm(void);
+ − 40 static void openEdit_DecoGF(void);
+ − 41 static void openEdit_DecoAltGF(void);
+ − 42 static void openEdit_DecoVPM(void);
+ − 43 static void openEdit_DecoLastStop(void);
902
+ − 44 static void openEdit_DecoVpmTable(void);
288
+ − 45 static void openEdit_DM_SwitchAlgorithm(uint8_t line);
38
+ − 46
+ − 47 //void openEdit_DecoGasUsage(void);
+ − 48
+ − 49 /* Announced function prototypes -----------------------------------------------*/
+ − 50 uint8_t OnAction_GF (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 51 uint8_t OnAction_VPM (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 52 uint8_t OnAction_AltGF (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 53 uint8_t OnAction_LastStop (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 54 uint8_t OnAction_DM_ActiveGF (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 55 uint8_t OnAction_DM_ActiveVPM (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 56 uint8_t OnAction_DM_AltActiveGF (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+ − 57 /* Exported functions --------------------------------------------------------*/
+ − 58
+ − 59 void openEdit_DecoParameter(uint8_t line)
+ − 60 {
+ − 61 set_globalState_Menu_Line(line);
+ − 62 resetMenuEdit(CLUT_MenuPageDecoParameter);
+ − 63
+ − 64 if(actual_menu_content == MENU_SURFACE)
+ − 65 {
+ − 66 switch(line)
+ − 67 {
+ − 68 case 1:
+ − 69 default:
+ − 70 openEdit_DecoAlgorithm();
+ − 71 break;
+ − 72 case 2:
+ − 73 openEdit_DecoVPM();
+ − 74 break;
+ − 75 case 3:
+ − 76 openEdit_DecoGF();
+ − 77 break;
+ − 78 case 4:
+ − 79 openEdit_DecoAltGF();
+ − 80 break;
+ − 81 case 5:
+ − 82 openEdit_DecoLastStop();
+ − 83 break;
+ − 84 case 6:
902
+ − 85 openEdit_DecoVpmTable();
38
+ − 86 break;
+ − 87 }
+ − 88 }
+ − 89 else
+ − 90 openEdit_DM_SwitchAlgorithm(line);
+ − 91 }
+ − 92
+ − 93 /* Private functions ---------------------------------------------------------*/
+ − 94
288
+ − 95 static void openEdit_DM_SwitchAlgorithm(uint8_t line)
38
+ − 96 {
+ − 97 switch(line)
+ − 98 {
+ − 99 case 1:
+ − 100 default:
288
+ − 101 stateUsedWrite->diveSettings.deco_type.ub.standard = VPM_MODE;
38
+ − 102 break;
+ − 103 case 2:
+ − 104
288
+ − 105 stateUsedWrite->diveSettings.gf_high = settingsGetPointer()->GF_high;
+ − 106 stateUsedWrite->diveSettings.gf_low = settingsGetPointer()->GF_low;
+ − 107 stateUsedWrite->diveSettings.deco_type.ub.standard = GF_MODE;
38
+ − 108 break;
+ − 109 case 3:
288
+ − 110 stateUsedWrite->diveSettings.gf_high = settingsGetPointer()->aGF_high;
+ − 111 stateUsedWrite->diveSettings.gf_low = settingsGetPointer()->aGF_low;
+ − 112 stateUsedWrite->diveSettings.deco_type.ub.standard = GF_MODE;
38
+ − 113 break;
+ − 114 }
+ − 115 exitMenuEdit_to_Home_with_Menu_Update();
+ − 116 }
+ − 117
+ − 118
288
+ − 119 static void openEdit_DecoAlgorithm(void)
38
+ − 120 {
+ − 121 SSettings *pSettings = settingsGetPointer();
+ − 122
+ − 123 if(pSettings->deco_type.ub.standard == VPM_MODE)
+ − 124 pSettings->deco_type.ub.standard = GF_MODE;
+ − 125 else
+ − 126 pSettings->deco_type.ub.standard = VPM_MODE;
+ − 127
+ − 128 exitEditWithUpdate();
+ − 129 }
+ − 130
+ − 131
288
+ − 132 static void openEdit_DecoVPM(void)
38
+ − 133 {
+ − 134 uint8_t vpm;
+ − 135 char text[32];
+ − 136 SSettings *pSettings = settingsGetPointer();
+ − 137
+ − 138 vpm = pSettings->VPM_conservatism.ub.standard;
+ − 139
+ − 140 text[0] = '\001';
+ − 141 text[1] = TXT_Decoparameters;
+ − 142 text[2] = 0;
+ − 143 write_topline(text);
+ − 144
+ − 145 write_label_var( 20, 800, ME_Y_LINE2, &FontT48, "VPM");
+ − 146
+ − 147 write_field_udigit(StMDECOP2_VPM, MEDP_TAB, 800, ME_Y_LINE2, &FontT48, "+#", (uint32_t)vpm, 0, 0, 0);
+ − 148
+ − 149 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus);
+ − 150
+ − 151 setEvent(StMDECOP2_VPM, (uint32_t)OnAction_VPM);
+ − 152 startEdit();
+ − 153 }
+ − 154
+ − 155
288
+ − 156 static void openEdit_DecoGF(void)
38
+ − 157 {
+ − 158 uint8_t gfLow,gfHigh;
+ − 159 char text[32];
+ − 160 SSettings *pSettings = settingsGetPointer();
+ − 161
+ − 162 gfLow = pSettings->GF_low;
+ − 163 gfHigh = pSettings->GF_high;
+ − 164
+ − 165 text[0] = '\001';
+ − 166 text[1] = TXT_Decoparameters;
+ − 167 text[2] = 0;
+ − 168 write_topline(text);
+ − 169
+ − 170 write_label_var( 20, 800, ME_Y_LINE3, &FontT48, "GF\016\016low/high\017");
+ − 171
+ − 172 write_field_udigit(StMDECOP3_GF, MEDP_TAB, 800, ME_Y_LINE3, &FontT48, "##/##", (uint32_t)gfLow, (uint32_t)gfHigh, 0, 0);
+ − 173
+ − 174 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus);
+ − 175
+ − 176 setEvent(StMDECOP3_GF, (uint32_t)OnAction_GF);
+ − 177 startEdit();
+ − 178 }
+ − 179
+ − 180
288
+ − 181 static void openEdit_DecoAltGF(void)
38
+ − 182 {
+ − 183 uint8_t aGfLow,aGfHigh;
+ − 184 char text[32];
+ − 185 SSettings *pSettings = settingsGetPointer();
+ − 186
+ − 187 aGfLow = pSettings->aGF_low;
+ − 188 aGfHigh = pSettings->aGF_high;
+ − 189
+ − 190 text[0] = '\001';
+ − 191 text[1] = TXT_Decoparameters;
+ − 192 text[2] = 0;
+ − 193 write_topline(text);
+ − 194
+ − 195 write_label_var( 20, 800, ME_Y_LINE4, &FontT48, "aGF\016\016low/high\017");
+ − 196 write_field_udigit(StMDECOP4_AltGF, MEDP_TAB, 800, ME_Y_LINE4, &FontT48, "##/##", (uint32_t)aGfLow, (uint32_t)aGfHigh, 0, 0);
+ − 197
+ − 198 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus);
+ − 199
+ − 200 setEvent(StMDECOP4_AltGF, (uint32_t)OnAction_AltGF);
+ − 201 startEdit();
+ − 202 }
+ − 203
+ − 204
288
+ − 205 static void openEdit_DecoLastStop(void)
38
+ − 206 {
+ − 207 uint8_t lastStop;
+ − 208 char text[32];
+ − 209 SSettings *pSettings = settingsGetPointer();
+ − 210
+ − 211 lastStop = pSettings->last_stop_depth_meter;
+ − 212
+ − 213 text[0] = '\001';
+ − 214 text[1] = TXT_LastDecostop;
+ − 215 text[2] = 0;
+ − 216 write_topline(text);
+ − 217
+ − 218 write_label_fix( 20, 800, ME_Y_LINE5, &FontT48, TXT_LastDecostop);
+ − 219
+ − 220 if(settingsGetPointer()->nonMetricalSystem)
+ − 221 {
+ − 222 write_label_var( MEDP_TAB + 40, 800, ME_Y_LINE5, &FontT48, "\016\016 ft\017");
+ − 223 write_field_2digit(StMDECOP5_LASTSTOP, MEDP_TAB, 800, ME_Y_LINE5, &FontT48, "##", (uint32_t)unit_depth_integer(lastStop), 0, 0, 0);
+ − 224 }
+ − 225 else
+ − 226 {
+ − 227 write_label_var( MEDP_TAB + 20, 800, ME_Y_LINE5, &FontT48, "\016\016 meter\017");
+ − 228 write_field_udigit(StMDECOP5_LASTSTOP, MEDP_TAB, 800, ME_Y_LINE5, &FontT48, "#", (uint32_t)lastStop, 0, 0, 0);
+ − 229 }
+ − 230 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus);
+ − 231
+ − 232 setEvent(StMDECOP5_LASTSTOP, (uint32_t)OnAction_LastStop);
+ − 233 startEdit();
+ − 234 }
+ − 235
902
+ − 236 static void openEdit_DecoVpmTable(void)
+ − 237 {
+ − 238 SSettings *pSettings = settingsGetPointer();
+ − 239
+ − 240 if(pSettings->VPM_conservatism.ub.alternative == 0)
+ − 241 {
+ − 242 pSettings->VPM_conservatism.ub.alternative = 1;
+ − 243 }
+ − 244 else
+ − 245 {
+ − 246 pSettings->VPM_conservatism.ub.alternative = 0;
+ − 247 }
+ − 248 exitEditWithUpdate();
+ − 249 }
+ − 250
38
+ − 251 uint8_t OnAction_VPM(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 252 {
+ − 253 SSettings *pSettings;
+ − 254 uint8_t digitContentNew;
+ − 255 uint32_t newConservatism;
+ − 256
+ − 257 if(action == ACTION_BUTTON_ENTER)
+ − 258 {
+ − 259 return digitContent;
+ − 260 }
+ − 261 if(action == ACTION_BUTTON_ENTER_FINAL)
+ − 262 {
+ − 263 evaluateNewString(editId, &newConservatism, 0, 0, 0);
+ − 264 if(newConservatism > 5)
+ − 265 newConservatism = 5;
+ − 266
+ − 267 pSettings = settingsGetPointer();
+ − 268 pSettings->VPM_conservatism.ub.standard = newConservatism;
+ − 269
+ − 270 tMenuEdit_newInput(editId, newConservatism, 0, 0, 0);
+ − 271 return UPDATE_AND_EXIT_TO_MENU;
+ − 272 }
+ − 273 if(action == ACTION_BUTTON_NEXT)
+ − 274 {
+ − 275 digitContentNew = digitContent + 1;
+ − 276 if(digitContentNew > '5')
+ − 277 digitContentNew = '0';
+ − 278 return digitContentNew;
+ − 279 }
+ − 280 if(action == ACTION_BUTTON_BACK)
+ − 281 {
+ − 282 digitContentNew = digitContent - 1;
+ − 283 if(digitContentNew < '0')
+ − 284 digitContentNew = '5';
+ − 285 return digitContentNew;
+ − 286 }
+ − 287
+ − 288 return EXIT_TO_MENU;
+ − 289 }
+ − 290
+ − 291
+ − 292 uint8_t OnAction_GF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 293 {
+ − 294 SSettings *pSettings;
+ − 295 uint8_t digitContentNew;
+ − 296 uint32_t newGFlow, newGFhigh;
+ − 297
+ − 298 if(action == ACTION_BUTTON_ENTER)
+ − 299 {
+ − 300 return digitContent;
+ − 301 }
+ − 302 if(action == ACTION_BUTTON_ENTER_FINAL)
+ − 303 {
+ − 304 evaluateNewString(editId, &newGFlow, &newGFhigh, 0, 0);
+ − 305 if(newGFlow < 10)
+ − 306 newGFlow = 10;
+ − 307 if(newGFhigh < 45)
+ − 308 newGFhigh = 45;
+ − 309 if(newGFlow > 99)
+ − 310 newGFlow = 99;
+ − 311 if(newGFhigh > 99)
+ − 312 newGFhigh = 99;
+ − 313
+ − 314 pSettings = settingsGetPointer();
+ − 315 pSettings->GF_low = newGFlow;
+ − 316 pSettings->GF_high= newGFhigh;
+ − 317
+ − 318 tMenuEdit_newInput(editId, newGFlow, newGFhigh, 0, 0);
+ − 319 return UPDATE_AND_EXIT_TO_MENU;
+ − 320 }
+ − 321 if(action == ACTION_BUTTON_NEXT)
+ − 322 {
+ − 323 digitContentNew = digitContent + 1;
+ − 324 if(digitContentNew > '9')
+ − 325 digitContentNew = '0';
+ − 326 return digitContentNew;
+ − 327 }
+ − 328 if(action == ACTION_BUTTON_BACK)
+ − 329 {
+ − 330 digitContentNew = digitContent - 1;
+ − 331 if(digitContentNew < '0')
+ − 332 digitContentNew = '9';
+ − 333 return digitContentNew;
+ − 334 }
+ − 335 return EXIT_TO_MENU;
+ − 336 }
+ − 337
+ − 338 uint8_t OnAction_AltGF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 339 {
+ − 340 SSettings *pSettings;
+ − 341 uint8_t digitContentNew;
+ − 342 uint32_t newGFlow, newGFhigh;
+ − 343
+ − 344 if(action == ACTION_BUTTON_ENTER)
+ − 345 {
+ − 346 return digitContent;
+ − 347 }
+ − 348 if(action == ACTION_BUTTON_ENTER_FINAL)
+ − 349 {
+ − 350 evaluateNewString(editId, &newGFlow, &newGFhigh, 0, 0);
+ − 351 if(newGFlow < 10)
+ − 352 newGFlow = 10;
+ − 353 if(newGFhigh < 45)
+ − 354 newGFhigh = 45;
+ − 355 if(newGFlow > 99)
+ − 356 newGFlow = 99;
+ − 357 if(newGFhigh > 99)
+ − 358 newGFhigh = 99;
+ − 359
+ − 360 pSettings = settingsGetPointer();
+ − 361 pSettings->aGF_low = newGFlow;
+ − 362 pSettings->aGF_high= newGFhigh;
+ − 363
+ − 364 tMenuEdit_newInput(editId, newGFlow, newGFhigh, 0, 0);
+ − 365 return UPDATE_AND_EXIT_TO_MENU;
+ − 366 }
+ − 367 if(action == ACTION_BUTTON_NEXT)
+ − 368 {
+ − 369 digitContentNew = digitContent + 1;
+ − 370 if(digitContentNew > '9')
+ − 371 digitContentNew = '0';
+ − 372 return digitContentNew;
+ − 373 }
+ − 374 if(action == ACTION_BUTTON_BACK)
+ − 375 {
+ − 376 digitContentNew = digitContent - 1;
+ − 377 if(digitContentNew < '0')
+ − 378 digitContentNew = '9';
+ − 379 return digitContentNew;
+ − 380 }
+ − 381
+ − 382 return EXIT_TO_MENU;
+ − 383 }
+ − 384
+ − 385
+ − 386 uint8_t OnAction_LastStop(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 387 {
+ − 388 SSettings *pSettings;
+ − 389 uint8_t digitContentNew;
+ − 390 uint32_t lastStop;
+ − 391
+ − 392 if(action == ACTION_BUTTON_ENTER)
+ − 393 {
+ − 394 return digitContent;
+ − 395 }
+ − 396 if(action == ACTION_BUTTON_ENTER_FINAL)
+ − 397 {
+ − 398 evaluateNewString(editId, &lastStop, 0, 0, 0);
+ − 399
+ − 400 if(settingsGetPointer()->nonMetricalSystem != 0) // new hw 170718
+ − 401 {
+ − 402 lastStop += 2; // f�r rundung
+ − 403 lastStop = (lastStop * 3) / 10;
+ − 404 }
+ − 405
+ − 406 pSettings = settingsGetPointer();
+ − 407
+ − 408 pSettings->last_stop_depth_meter = lastStop;
+ − 409
+ − 410 tMenuEdit_newInput(editId, lastStop, 0, 0, 0);
+ − 411 return UPDATE_AND_EXIT_TO_MENU;
+ − 412 }
+ − 413
+ − 414 if(settingsGetPointer()->nonMetricalSystem)
+ − 415 {
+ − 416 // 10, 13, 17, 20
+ − 417 if(action == ACTION_BUTTON_NEXT)
+ − 418 {
+ − 419 if(digitContent < 13 + '0')
+ − 420 digitContentNew = 13 + '0';
+ − 421 else if(digitContent < 16 + '0')
+ − 422 digitContentNew = 16 + '0';
+ − 423 else if(digitContent < 20 + '0')
+ − 424 digitContentNew = 20 + '0';
+ − 425 else
+ − 426 digitContentNew = 10 + '0';
+ − 427
+ − 428
+ − 429 return digitContentNew;
+ − 430 }
+ − 431 if(action == ACTION_BUTTON_BACK)
+ − 432 {
+ − 433 if(digitContent >= 20 + '0')
+ − 434 digitContentNew = 16 + '0';
+ − 435 else if(digitContent >= 16 + '0')
+ − 436 digitContentNew = 13 + '0';
+ − 437 else if(digitContent >= 13 + '0')
+ − 438 digitContentNew = 10 + '0';
+ − 439 else
+ − 440 digitContentNew = 20 + '0';
+ − 441
+ − 442 return digitContentNew;
+ − 443 }
+ − 444 }
+ − 445 else
+ − 446 {
+ − 447 if(action == ACTION_BUTTON_NEXT)
+ − 448 {
+ − 449 digitContentNew = digitContent + 1;
+ − 450 if(digitContentNew > '6')
+ − 451 digitContentNew = '3';
+ − 452 return digitContentNew;
+ − 453 }
+ − 454 if(action == ACTION_BUTTON_BACK)
+ − 455 {
+ − 456 digitContentNew = digitContent - 1;
+ − 457 if(digitContentNew < '3')
+ − 458 digitContentNew = '6';
+ − 459 return digitContentNew;
+ − 460 }
+ − 461 }
+ − 462
+ − 463 return EXIT_TO_MENU;
+ − 464 }
+ − 465
+ − 466 uint8_t OnAction_DM_ActiveVPM(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 467 {
288
+ − 468 stateUsedWrite->diveSettings.deco_type.ub.standard = VPM_MODE;
38
+ − 469 return EXIT_TO_HOME;
+ − 470 }
+ − 471
+ − 472
+ − 473 uint8_t OnAction_DM_ActiveGF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 474 {
+ − 475 SSettings *pSettings = settingsGetPointer();
288
+ − 476
+ − 477 stateUsedWrite->diveSettings.gf_high = pSettings->GF_high;
+ − 478 stateUsedWrite->diveSettings.gf_low = pSettings->GF_low;
+ − 479 stateUsedWrite->diveSettings.deco_type.ub.standard = GF_MODE;
38
+ − 480 return EXIT_TO_HOME;
+ − 481 }
+ − 482
+ − 483
+ − 484 uint8_t OnAction_DM_AltActiveGF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+ − 485 {
288
+ − 486 SSettings *pSettings = settingsGetPointer();
+ − 487
+ − 488 stateUsedWrite->diveSettings.gf_high = pSettings->aGF_high;
+ − 489 stateUsedWrite->diveSettings.gf_low = pSettings->aGF_low;
+ − 490 stateUsedWrite->diveSettings.deco_type.ub.standard = GF_MODE;
38
+ − 491 return EXIT_TO_HOME;
+ − 492 }