comparison Discovery/Src/tMenuEditXtra.c @ 38:5f11787b4f42

include in ostc4 repository
author heinrichsweikamp
date Sat, 28 Apr 2018 11:52:34 +0200
parents
children 74a8296a2318
comparison
equal deleted inserted replaced
37:ccc45c0e1ea2 38:5f11787b4f42
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 {
124 if(is_stateUsedSetToSim())
125 stateSimGetPointerWrite()->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading;
126 else
127 stateRealGetPointerWrite()->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading;
128 exitMenuEdit_to_Home_with_Menu_Update();
129 return EXIT_TO_HOME;
130 }
131
132
133 /*
134 uint8_t digitContentNew;
135 uint32_t newHeading;
136
137 if(action == ACTION_BUTTON_ENTER)
138 {
139 return digitContent;
140 }
141 if(action == ACTION_BUTTON_ENTER_FINAL)
142 {
143 evaluateNewString(editId, &newHeading, 0, 0, 0);
144 if(newHeading > 359)
145 newHeading = 0;
146
147 if(is_stateUsedSetToSim())
148 stateSimGetPointerWrite()->diveSettings.compassHeading = newHeading;
149 else
150 stateRealGetPointerWrite()->diveSettings.compassHeading = newHeading;
151 exitMenuEdit_to_Home_with_Menu_Update();
152 return EXIT_TO_HOME;
153 }
154 if(action == ACTION_BUTTON_NEXT)
155 {
156 digitContentNew = digitContent + 1;
157 if((digitNumber == 0) && (digitContentNew > '3'))
158 digitContentNew = '0';
159 else
160 if(digitContentNew > '9')
161 digitContentNew = '0';
162 return digitContentNew;
163 }
164 if(action == ACTION_BUTTON_BACK)
165 {
166 digitContentNew = digitContent - 1;
167 if((digitNumber == 0) && (digitContentNew < '0'))
168 digitContentNew = '3';
169 else
170 if(digitContentNew < '0')
171 digitContentNew = '9';
172 return digitContentNew;
173 }
174
175 return EXIT_TO_MENU;
176 */