Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditXtra.c @ 299:b70c26be71a0
Merged in janlmulder/ostc4/cleanup-3 (pull request #24)
1 bug fix, 1 possible bug fix and some cleanup.
author | heinrichsweikamp <bitbucket@heinrichsweikamp.com> |
---|---|
date | Fri, 17 May 2019 06:38:56 +0000 |
parents | ba229a012ac7 |
children | 77de014928d6 |
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 { | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
272
diff
changeset
|
80 stateUsedWrite->events.manualMarker = 1; |
38 | 81 exitMenuEdit_to_Home(); |
82 } | |
83 | |
84 void openEdit_SimFollowDecostops(void) | |
85 { | |
86 simulation_set_heed_decostops(!simulation_get_heed_decostops()); | |
87 exitMenuEdit_to_Menu_with_Menu_Update(); | |
88 } | |
89 | |
90 void refresh_CompassHeading(void) | |
91 { | |
92 uint16_t heading; | |
93 char text[32]; | |
94 | |
95 text[0] = '\001'; | |
96 text[1] = TXT_2BYTE; | |
97 text[2] = TXT2BYTE_CompassHeading; | |
98 text[3] = 0; | |
99 write_topline(text); | |
100 | |
101 heading = (uint16_t)stateUsed->lifeData.compass_heading; | |
102 snprintf(text,32,"\001%03i`",heading); | |
103 write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text); | |
104 | |
105 tMenuEdit_refresh_field(StMXTRA_CompassHeading); | |
106 } | |
107 | |
108 void openEdit_CompassHeading(void) | |
109 { | |
110 | |
111 write_field_button(StMXTRA_CompassHeading,20, 800, ME_Y_LINE4, &FontT48, "Set"); | |
112 | |
113 setEvent(StMXTRA_CompassHeading, (uint32_t)OnAction_CompassHeading); | |
114 // startEdit(); | |
115 } | |
116 | |
117 | |
118 uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
119 { | |
272
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
120 stateUsedWrite->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; |
38 | 121 exitMenuEdit_to_Home_with_Menu_Update(); |
122 return EXIT_TO_HOME; | |
123 } |