comparison Discovery/Src/tMenuEditDecoParameter.c @ 288:ba229a012ac7 div-fixes-6

cleanup: no useless checks for simulator state and some more in the style of commit 74a8296a2318. And in addition more cleanup like removing commented and unused code, and making things static. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Mon, 29 Apr 2019 19:43:05 +0200
parents 5f11787b4f42
children d4622533271d
comparison
equal deleted inserted replaced
287:ba9d99a2e310 288:ba229a012ac7
34 #include "unit.h" // last stop in meter and feet 34 #include "unit.h" // last stop in meter and feet
35 35
36 #define MEDP_TAB (380) 36 #define MEDP_TAB (380)
37 37
38 /* Private function prototypes -----------------------------------------------*/ 38 /* Private function prototypes -----------------------------------------------*/
39 void openEdit_DecoAlgorithm(void); 39 static void openEdit_DecoAlgorithm(void);
40 void openEdit_DecoGF(void); 40 static void openEdit_DecoGF(void);
41 void openEdit_DecoAltGF(void); 41 static void openEdit_DecoAltGF(void);
42 void openEdit_DecoVPM(void); 42 static void openEdit_DecoVPM(void);
43 void openEdit_DecoLastStop(void); 43 static void openEdit_DecoLastStop(void);
44 void openEdit_DM_SwitchAlgorithm(uint8_t line); 44 static void openEdit_DM_SwitchAlgorithm(uint8_t line);
45 45
46 //void openEdit_DecoGasUsage(void); 46 //void openEdit_DecoGasUsage(void);
47 47
48 /* Announced function prototypes -----------------------------------------------*/ 48 /* Announced function prototypes -----------------------------------------------*/
49 uint8_t OnAction_GF (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 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); 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); 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); 52 uint8_t OnAction_LastStop (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
53
54 uint8_t OnAction_GasAMV (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
55 uint8_t OnAction_DefaultAMV (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
56 uint8_t OnAction_GasReserve (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
57
58 uint8_t OnAction_DM_ActiveGF (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);
59 uint8_t OnAction_DM_ActiveVPM (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);
60 uint8_t OnAction_DM_AltActiveGF (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);
61 /* Exported functions --------------------------------------------------------*/ 56 /* Exported functions --------------------------------------------------------*/
62 57
93 openEdit_DM_SwitchAlgorithm(line); 88 openEdit_DM_SwitchAlgorithm(line);
94 } 89 }
95 90
96 /* Private functions ---------------------------------------------------------*/ 91 /* Private functions ---------------------------------------------------------*/
97 92
98 void openEdit_DM_SwitchAlgorithm(uint8_t line) 93 static void openEdit_DM_SwitchAlgorithm(uint8_t line)
99 { 94 {
100 SDiveState * pState;
101
102 if(actual_menu_content == MENU_DIVE_REAL)
103 {
104 pState = stateRealGetPointerWrite();
105 }
106 else
107 {
108 pState = stateSimGetPointerWrite();
109 }
110
111 switch(line) 95 switch(line)
112 { 96 {
113 case 1: 97 case 1:
114 default: 98 default:
115 pState->diveSettings.deco_type.ub.standard = VPM_MODE; 99 stateUsedWrite->diveSettings.deco_type.ub.standard = VPM_MODE;
116 break; 100 break;
117 case 2: 101 case 2:
118 102
119 pState->diveSettings.gf_high = settingsGetPointer()->GF_high; 103 stateUsedWrite->diveSettings.gf_high = settingsGetPointer()->GF_high;
120 pState->diveSettings.gf_low = settingsGetPointer()->GF_low; 104 stateUsedWrite->diveSettings.gf_low = settingsGetPointer()->GF_low;
121 pState->diveSettings.deco_type.ub.standard = GF_MODE; 105 stateUsedWrite->diveSettings.deco_type.ub.standard = GF_MODE;
122 break; 106 break;
123 case 3: 107 case 3:
124 pState->diveSettings.gf_high = settingsGetPointer()->aGF_high; 108 stateUsedWrite->diveSettings.gf_high = settingsGetPointer()->aGF_high;
125 pState->diveSettings.gf_low = settingsGetPointer()->aGF_low; 109 stateUsedWrite->diveSettings.gf_low = settingsGetPointer()->aGF_low;
126 pState->diveSettings.deco_type.ub.standard = GF_MODE; 110 stateUsedWrite->diveSettings.deco_type.ub.standard = GF_MODE;
127 break; 111 break;
128 } 112 }
129 exitMenuEdit_to_Home_with_Menu_Update(); 113 exitMenuEdit_to_Home_with_Menu_Update();
130 } 114 }
131 115
132 116
133 void openEdit_DecoAlgorithm(void) 117 static void openEdit_DecoAlgorithm(void)
134 { 118 {
135 SSettings *pSettings = settingsGetPointer(); 119 SSettings *pSettings = settingsGetPointer();
136 120
137 if(pSettings->deco_type.ub.standard == VPM_MODE) 121 if(pSettings->deco_type.ub.standard == VPM_MODE)
138 pSettings->deco_type.ub.standard = GF_MODE; 122 pSettings->deco_type.ub.standard = GF_MODE;
141 125
142 exitEditWithUpdate(); 126 exitEditWithUpdate();
143 } 127 }
144 128
145 129
146 void openEdit_DecoVPM(void) 130 static void openEdit_DecoVPM(void)
147 { 131 {
148 uint8_t vpm; 132 uint8_t vpm;
149 char text[32]; 133 char text[32];
150 SSettings *pSettings = settingsGetPointer(); 134 SSettings *pSettings = settingsGetPointer();
151 135
165 setEvent(StMDECOP2_VPM, (uint32_t)OnAction_VPM); 149 setEvent(StMDECOP2_VPM, (uint32_t)OnAction_VPM);
166 startEdit(); 150 startEdit();
167 } 151 }
168 152
169 153
170 void openEdit_DecoGF(void) 154 static void openEdit_DecoGF(void)
171 { 155 {
172 uint8_t gfLow,gfHigh; 156 uint8_t gfLow,gfHigh;
173 char text[32]; 157 char text[32];
174 SSettings *pSettings = settingsGetPointer(); 158 SSettings *pSettings = settingsGetPointer();
175 159
190 setEvent(StMDECOP3_GF, (uint32_t)OnAction_GF); 174 setEvent(StMDECOP3_GF, (uint32_t)OnAction_GF);
191 startEdit(); 175 startEdit();
192 } 176 }
193 177
194 178
195 void openEdit_DecoAltGF(void) 179 static void openEdit_DecoAltGF(void)
196 { 180 {
197 uint8_t aGfLow,aGfHigh; 181 uint8_t aGfLow,aGfHigh;
198 char text[32]; 182 char text[32];
199 SSettings *pSettings = settingsGetPointer(); 183 SSettings *pSettings = settingsGetPointer();
200 184
214 setEvent(StMDECOP4_AltGF, (uint32_t)OnAction_AltGF); 198 setEvent(StMDECOP4_AltGF, (uint32_t)OnAction_AltGF);
215 startEdit(); 199 startEdit();
216 } 200 }
217 201
218 202
219 void openEdit_DecoLastStop(void) 203 static void openEdit_DecoLastStop(void)
220 { 204 {
221 uint8_t lastStop; 205 uint8_t lastStop;
222 char text[32]; 206 char text[32];
223 SSettings *pSettings = settingsGetPointer(); 207 SSettings *pSettings = settingsGetPointer();
224 208
244 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); 228 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus);
245 229
246 setEvent(StMDECOP5_LASTSTOP, (uint32_t)OnAction_LastStop); 230 setEvent(StMDECOP5_LASTSTOP, (uint32_t)OnAction_LastStop);
247 startEdit(); 231 startEdit();
248 } 232 }
249
250 /*
251 void openEdit_DecoGF_DM(void)
252 {
253 const SDiveSettings * pDiveSettings;
254 uint8_t activeGF, activeVPM, aActiveGF;
255 SSettings *pSettings = settingsGetPointer();
256
257 if(actual_menu_content == MENU_DIVE_REAL)
258 {
259 const SDiveState * pState = stateRealGetPointer();
260 pDiveSettings = &pState->diveSettings;
261 }
262 else
263 {
264 const SDiveState * pState = stateSimGetPointer();
265 pDiveSettings = &pState->diveSettings;
266 }
267 if(pDiveSettings->deco_type.ub.standard == VPM_MODE)
268 {
269 aActiveGF = 0;
270 activeGF = 0;
271 activeVPM = 1;
272 }
273 else
274 if((pDiveSettings->gf_high == pSettings->GF_high) && (pDiveSettings->gf_low == pSettings->GF_low))
275 {
276 aActiveGF = 0;
277 activeGF = 1;
278 activeVPM = 0;
279 }
280 else
281 {
282 aActiveGF = 1;
283 activeGF = 0;
284 activeVPM = 0;
285 }
286
287 write_label_fix( 30, 340, 90, &FontT42, TXT_ZHL16GF);
288 write_label_fix( 30, 340, 140, &FontT42, TXT_low_high);
289 write_label_fix( 400, 600, 90, &FontT42, TXT_VPM);
290 write_label_fix( 400, 600, 140, &FontT42, TXT_Conservatism);
291 write_label_fix( 660, 799, 90, &FontT42, TXT_aGF);
292
293 write_field_on_off(StMDECOP7_ActiveGF, 30, 170, 405, &FontT48, "Active", activeGF);
294
295 write_field_on_off(StMDECOP8_ActiveVPM, 400, 600, 405, &FontT48, "Active", activeVPM);
296
297 write_field_on_off(StMDECOP9_ActiveAltGF, 660, 799, 405, &FontT48, "Active", aActiveGF);
298
299
300 setEvent(StMDECOP7_ActiveGF, (uint32_t)OnAction_DM_ActiveGF);
301 setEvent(StMDECOP8_ActiveVPM, (uint32_t)OnAction_DM_ActiveVPM);
302 setEvent(StMDECOP9_ActiveAltGF, (uint32_t)OnAction_DM_AltActiveGF);
303 }
304 */
305 233
306 uint8_t OnAction_VPM(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 234 uint8_t OnAction_VPM(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
307 { 235 {
308 SSettings *pSettings; 236 SSettings *pSettings;
309 uint8_t digitContentNew; 237 uint8_t digitContentNew;
516 } 444 }
517 445
518 return EXIT_TO_MENU; 446 return EXIT_TO_MENU;
519 } 447 }
520 448
521
522 uint8_t OnAction_ActiveGF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
523 {
524 SSettings *pSettings;
525 pSettings = settingsGetPointer();
526
527 if(pSettings->deco_type.ub.standard == GF_MODE)
528 return 255;
529
530 pSettings->deco_type.ub.standard = GF_MODE;
531 tMenuEdit_set_on_off(editId, 1);
532 tMenuEdit_set_on_off(StMDECOP8_ActiveVPM, 0);
533
534 return UPDATE_DIVESETTINGS;
535 }
536
537
538 uint8_t OnAction_ActiveVPM(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
539 {
540 SSettings *pSettings;
541 pSettings = settingsGetPointer();
542
543 if(pSettings->deco_type.ub.standard == VPM_MODE)
544 return 255;
545
546 pSettings->deco_type.ub.standard = VPM_MODE;
547 tMenuEdit_set_on_off(editId, 1);
548 tMenuEdit_set_on_off(StMDECOP7_ActiveGF, 0);
549
550 return UPDATE_DIVESETTINGS;
551 }
552
553
554 uint8_t OnAction_DM_ActiveVPM(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 449 uint8_t OnAction_DM_ActiveVPM(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
555 { 450 {
556 SDiveSettings * pDiveSettings; 451 stateUsedWrite->diveSettings.deco_type.ub.standard = VPM_MODE;
557 if(actual_menu_content == MENU_DIVE_REAL)
558 {
559 SDiveState * pState = stateRealGetPointerWrite();
560 pDiveSettings = &pState->diveSettings;
561 }
562 else
563 {
564 SDiveState * pState = stateSimGetPointerWrite();
565 pDiveSettings = &pState->diveSettings;
566 }
567 pDiveSettings->deco_type.ub.standard = VPM_MODE;
568 return EXIT_TO_HOME; 452 return EXIT_TO_HOME;
569 } 453 }
570 454
571 455
572 uint8_t OnAction_DM_ActiveGF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 456 uint8_t OnAction_DM_ActiveGF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
573 { 457 {
574 SSettings *pSettings = settingsGetPointer(); 458 SSettings *pSettings = settingsGetPointer();
575 SDiveSettings * pDiveSettings; 459
576 if(actual_menu_content == MENU_DIVE_REAL) 460 stateUsedWrite->diveSettings.gf_high = pSettings->GF_high;
577 { 461 stateUsedWrite->diveSettings.gf_low = pSettings->GF_low;
578 SDiveState * pState = stateRealGetPointerWrite(); 462 stateUsedWrite->diveSettings.deco_type.ub.standard = GF_MODE;
579 pDiveSettings = &pState->diveSettings;
580 }
581 else
582 {
583 SDiveState * pState = stateSimGetPointerWrite();
584 pDiveSettings = &pState->diveSettings;
585 }
586 pDiveSettings->gf_high = pSettings->GF_high;
587 pDiveSettings->gf_low = pSettings->GF_low;
588 pDiveSettings->deco_type.ub.standard = GF_MODE;
589 return EXIT_TO_HOME; 463 return EXIT_TO_HOME;
590 } 464 }
591 465
592 466
593 uint8_t OnAction_DM_AltActiveGF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 467 uint8_t OnAction_DM_AltActiveGF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
594 { 468 {
595 SSettings *pSettings = settingsGetPointer(); 469 SSettings *pSettings = settingsGetPointer();
596 SDiveSettings * pDiveSettings; 470
597 if(actual_menu_content == MENU_DIVE_REAL) 471 stateUsedWrite->diveSettings.gf_high = pSettings->aGF_high;
598 { 472 stateUsedWrite->diveSettings.gf_low = pSettings->aGF_low;
599 SDiveState * pState = stateRealGetPointerWrite(); 473 stateUsedWrite->diveSettings.deco_type.ub.standard = GF_MODE;
600 pDiveSettings = &pState->diveSettings;
601 }
602 else
603 {
604 SDiveState * pState = stateSimGetPointerWrite();
605 pDiveSettings = &pState->diveSettings;
606 }
607 pDiveSettings->gf_high = pSettings->aGF_high;
608 pDiveSettings->gf_low = pSettings->aGF_low;
609 pDiveSettings->deco_type.ub.standard = GF_MODE;
610 return EXIT_TO_HOME; 474 return EXIT_TO_HOME;
611 } 475 }
612
613
614 /*
615 void openEdit_DecoGasUsage(void)
616 {
617 uint8_t amv, reserve;
618 char text[32];
619 SSettings *pSettings;
620
621 pSettings = settingsGetPointer();
622
623 amv = pSettings->AtemMinutenVolumenLiter;
624 reserve = pSettings->ReserveFractionDenominator;
625
626 text[0] = '\a';
627 text[1] = TXT_AtemGasVorrat;
628 text[2] = 0;
629
630 write_topline(text);
631
632 write_label_fix( 30, 340, 90, &FontT42, TXT_LiterproMinute);
633 write_label_fix( 30, 340, 250, &FontT42, TXT_Default);
634 write_label_fix( 430, 740, 90, &FontT42, TXT_Reserve);
635
636 strcpy(text, "1/0");
637 text[2] += reserve;
638 write_field_udigit(StMDECOP5_AMV, 30, 320, 150, &FontT105, "###", (uint32_t)amv, 0, 0, 0);
639 write_field_button(StMDECOP5_DefaultAMV, 30, 170, 290, &FontT48, "25");
640 write_field_button(StMDECOP5_RESERVE, 430, 640, 150, &FontT105, text);
641
642 setEvent(StMDECOP5_AMV, (uint32_t)OnAction_GasAMV);
643 setEvent(StMDECOP5_DefaultAMV, (uint32_t)OnAction_DefaultAMV);
644 setEvent(StMDECOP5_RESERVE, (uint32_t)OnAction_GasReserve);
645 }
646
647
648 uint8_t OnAction_GasAMV (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
649 {
650 uint8_t digitContentNew;
651 uint32_t newAMV;
652 SSettings *pSettings;
653
654 if(action == ACTION_BUTTON_ENTER)
655 {
656 return digitContent;
657 }
658 if(action == ACTION_BUTTON_ENTER_FINAL)
659 {
660 evaluateNewString(editId, &newAMV, 0, 0, 0);
661
662 if(newAMV < 5)
663 newAMV = 5;
664 if(newAMV > 190)
665 newAMV = 190;
666
667 pSettings = settingsGetPointer();
668 pSettings->AtemMinutenVolumenLiter = newAMV;
669
670 tMenuEdit_newInput(editId, newAMV, 0, 0, 0);
671
672 return 255;
673 }
674 if(action == ACTION_BUTTON_NEXT)
675 {
676 if((digitNumber == 0) && (digitContentNew >= '1'))
677 digitContentNew = '0';
678 else
679 digitContentNew = digitContent + 1;
680 if(digitContentNew > '9')
681 digitContentNew = '0';
682 return digitContentNew;
683 }
684 if(action == ACTION_BUTTON_BACK)
685 {
686 if((digitNumber == 0) && (digitContentNew == '0'))
687 digitContentNew = '1';
688 else
689 digitContentNew = digitContent - 1;
690 if(digitContentNew < '0')
691 digitContentNew = '9';
692 return digitContentNew;
693 }
694
695 return UNSPECIFIC_RETURN;
696 }
697
698
699 uint8_t OnAction_DefaultAMV (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
700 {
701 uint32_t newAMV;
702 SSettings *pSettings;
703
704 newAMV = 25;
705
706 pSettings = settingsGetPointer();
707 pSettings->AtemMinutenVolumenLiter = newAMV;
708 tMenuEdit_newInput(StMDECOP5_AMV, newAMV, 0, 0, 0);
709
710 return UNSPECIFIC_RETURN;
711 }
712
713
714 uint8_t OnAction_GasReserve (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
715 {
716 uint32_t reserve;
717 SSettings *pSettings;
718 char text[32];
719
720 pSettings = settingsGetPointer();
721 reserve = pSettings->ReserveFractionDenominator;
722 if(reserve <= 3)
723 reserve = 4;
724 else
725 reserve = 3;
726
727 pSettings->ReserveFractionDenominator = reserve;
728
729 strcpy(text, "1/0");
730 text[2] += reserve;
731 tMenuEdit_newButtonText(editId, text);
732
733 return UNSPECIFIC_RETURN;
734 }
735 */