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