Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditXtra.c @ 272:74a8296a2318 write-from-sim
cleanup: simplify stateUsed usage
Get rid of some local stateUsed pointers used to differentiate between
normal dive and simulator mode. Simply use the (properly set) global
data for this. Its rather useless to do this test on countless locations.
Trivial cleanup.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Sat, 27 Apr 2019 12:27:46 +0200 |
parents | 5f11787b4f42 |
children | ba229a012ac7 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuEditXtra.c | |
5 /// \brief Menu Edit Xtra - Specials in Divemode like Reset Stopwatch | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 02-Mar-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 "tMenuEditXtra.h" | |
31 | |
32 #include "gfx_fonts.h" | |
33 #include "simulation.h" | |
34 #include "timer.h" | |
35 #include "tMenuEdit.h" | |
36 | |
37 /* Private function prototypes -----------------------------------------------*/ | |
38 void openEdit_CompassHeading(void); | |
39 void openEdit_ResetStopwatch(void); | |
40 void openEdit_SimFollowDecostops(void); | |
41 void openEdit_SetManualMarker(void); | |
42 | |
43 /* Announced function prototypes -----------------------------------------------*/ | |
44 uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
45 | |
46 /* Exported functions --------------------------------------------------------*/ | |
47 | |
48 void openEdit_Xtra(uint8_t line) | |
49 { | |
50 set_globalState_Menu_Line(line); | |
51 resetMenuEdit(CLUT_MenuPageXtra); | |
52 | |
53 switch(line) | |
54 { | |
55 case 1: | |
56 default: | |
57 openEdit_ResetStopwatch(); | |
58 break; | |
59 case 2: | |
60 openEdit_CompassHeading(); | |
61 break; | |
62 case 3: | |
63 openEdit_SetManualMarker(); | |
64 break; | |
65 case 4: | |
66 openEdit_SimFollowDecostops(); | |
67 break; | |
68 } | |
69 } | |
70 | |
71 /* Private functions ---------------------------------------------------------*/ | |
72 void openEdit_ResetStopwatch(void) | |
73 { | |
74 timer_Stopwatch_Restart(); | |
75 exitMenuEdit_to_Home(); | |
76 } | |
77 | |
78 void openEdit_SetManualMarker(void) | |
79 { | |
80 if(stateUsed == stateRealGetPointer()) | |
81 stateRealGetPointerWrite()->events.manualMarker = 1; | |
82 else | |
83 stateSimGetPointerWrite()->events.manualMarker = 1; | |
84 | |
85 exitMenuEdit_to_Home(); | |
86 } | |
87 | |
88 void openEdit_SimFollowDecostops(void) | |
89 { | |
90 simulation_set_heed_decostops(!simulation_get_heed_decostops()); | |
91 exitMenuEdit_to_Menu_with_Menu_Update(); | |
92 } | |
93 | |
94 void refresh_CompassHeading(void) | |
95 { | |
96 uint16_t heading; | |
97 char text[32]; | |
98 | |
99 text[0] = '\001'; | |
100 text[1] = TXT_2BYTE; | |
101 text[2] = TXT2BYTE_CompassHeading; | |
102 text[3] = 0; | |
103 write_topline(text); | |
104 | |
105 heading = (uint16_t)stateUsed->lifeData.compass_heading; | |
106 snprintf(text,32,"\001%03i`",heading); | |
107 write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text); | |
108 | |
109 tMenuEdit_refresh_field(StMXTRA_CompassHeading); | |
110 } | |
111 | |
112 void openEdit_CompassHeading(void) | |
113 { | |
114 | |
115 write_field_button(StMXTRA_CompassHeading,20, 800, ME_Y_LINE4, &FontT48, "Set"); | |
116 | |
117 setEvent(StMXTRA_CompassHeading, (uint32_t)OnAction_CompassHeading); | |
118 // startEdit(); | |
119 } | |
120 | |
121 | |
122 uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
123 { | |
272
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
124 stateUsedWrite->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; |
38 | 125 exitMenuEdit_to_Home_with_Menu_Update(); |
126 return EXIT_TO_HOME; | |
127 } |