Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditHardware.c @ 558:66aef216828b
Changed operation mode of RecoverSampleIndex:
In previous implementation the check was only done for the first 16 sector to be able to display status using a string. This may not be done by an OSTC companion function externally => changed function to handle all 192 sector used for log samples. The lastSampleIdx will now be stored immediatly (dive was necessary in previous version)
author | Ideenmodellierer |
---|---|
date | Thu, 12 Nov 2020 20:06:04 +0100 |
parents | d784f281833a |
children | ec76fa85009e |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuEditHardware.c | |
5 /// \brief BUTTONS | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 15-Sept-2016 | |
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 "tMenuEditHardware.h" | |
31 | |
32 #include "externCPU2bootloader.h" | |
33 #include "gfx_fonts.h" | |
34 #include "ostc.h" | |
35 #include "tCCR.h" | |
36 #include "tMenuEdit.h" | |
130
b7689d9e888a
Minor changes to improved code quality and to eliminate warnings
Ideenmodellierer
parents:
115
diff
changeset
|
37 #include "tHome.h" |
b7689d9e888a
Minor changes to improved code quality and to eliminate warnings
Ideenmodellierer
parents:
115
diff
changeset
|
38 #include "tInfo.h" |
b7689d9e888a
Minor changes to improved code quality and to eliminate warnings
Ideenmodellierer
parents:
115
diff
changeset
|
39 #include "tInfoLog.h" |
394
717f335cc5c9
Added start of module configuration after eache modul power on
ideenmodellierer
parents:
314
diff
changeset
|
40 #include "tComm.h" |
38 | 41 |
130
b7689d9e888a
Minor changes to improved code quality and to eliminate warnings
Ideenmodellierer
parents:
115
diff
changeset
|
42 extern void tM_build_pages(void); |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
43 |
38 | 44 /* Private function prototypes -----------------------------------------------*/ |
45 void openEdit_Bluetooth(void); | |
46 void openEdit_Compass(void); | |
47 void openEdit_O2Sensors(void); | |
48 void openEdit_Brightness(void); | |
49 //void openEdit_Luftintegration(void); | |
50 void openEdit_ButtonSens(void); | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
51 void openEdit_FlipDisplay(void); |
38 | 52 |
53 /* Announced function prototypes -----------------------------------------------*/ | |
54 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
55 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
56 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
539
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
57 uint8_t OnAction_InertiaLevel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
38 | 58 //uint8_t OnAction_ExitHardw (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
59 uint8_t OnAction_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
60 uint8_t OnAction_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
61 uint8_t OnAction_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
62 uint8_t OnAction_O2_Fallback (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
63 uint8_t OnAction_Button (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
64 uint8_t OnAction_ButtonBalance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
65 // nicht notwending uint8_t OnAction_Bluetooth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
66 | |
67 /* Exported functions --------------------------------------------------------*/ | |
68 | |
69 void openEdit_Hardware(uint8_t line) | |
70 { | |
71 set_globalState_Menu_Line(line); | |
72 resetMenuEdit(CLUT_MenuPageHardware); | |
73 | |
74 switch(line) | |
75 { | |
76 case 1: | |
77 default: | |
78 openEdit_Bluetooth(); | |
79 break; | |
80 case 2: | |
81 openEdit_Compass(); | |
82 break; | |
83 case 3: | |
84 openEdit_O2Sensors(); | |
85 break; | |
86 case 4: | |
87 openEdit_Brightness(); | |
88 break; | |
89 case 5: | |
90 openEdit_ButtonSens(); | |
91 break; | |
92 case 6: | |
138 | 93 openEdit_FlipDisplay(); |
38 | 94 break; |
95 } | |
96 } | |
97 | |
98 /* Private functions ---------------------------------------------------------*/ | |
99 void openEdit_Bluetooth(void) | |
100 { | |
101 /* does not work like this resetEnterPressedToStateBeforeButtonAction(); */ | |
102 | |
103 SSettings *pSettings = settingsGetPointer(); | |
104 | |
105 if(pSettings->bluetoothActive == 0) | |
106 { | |
107 pSettings->bluetoothActive = 1; | |
108 MX_Bluetooth_PowerOn(); | |
394
717f335cc5c9
Added start of module configuration after eache modul power on
ideenmodellierer
parents:
314
diff
changeset
|
109 tComm_StartBlueModConfig(); |
38 | 110 } |
111 else | |
112 { | |
113 pSettings->bluetoothActive = 0; | |
114 MX_Bluetooth_PowerOff(); | |
115 } | |
116 exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only(); | |
117 } | |
118 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
119 void openEdit_FlipDisplay(void) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
120 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
121 /* does not work like this resetEnterPressedToStateBeforeButtonAction(); */ |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
122 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
123 SSettings *pSettings = settingsGetPointer(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
124 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
125 if(pSettings->FlipDisplay == 0) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
126 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
127 pSettings->FlipDisplay = 1; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
128 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
129 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
130 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
131 pSettings->FlipDisplay = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
132 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
133 /* reinit all views */ |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
134 tHome_init(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
135 tI_init(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
136 tM_init(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
137 tMenuEdit_init(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
138 tInfoLog_init(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
139 tM_build_pages(); |
314 | 140 GFX_build_logo_frame(); |
141 GFX_build_hw_background_frame(); | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
142 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
143 exitEditWithUpdate(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
144 exitMenuEdit_to_Home(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
145 } |
38 | 146 |
147 void refresh_CompassEdit(void) | |
148 { | |
149 uint16_t heading; | |
150 char text[32]; | |
539
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
151 uint8_t textIndex = 0; |
38 | 152 |
153 text[0] = '\001'; | |
154 text[1] = TXT_2BYTE; | |
155 text[2] = TXT2BYTE_Compass; | |
156 text[3] = 0; | |
157 write_topline(text); | |
158 | |
539
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
159 if(settingsGetPointer()->compassInertia) |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
160 { |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
161 heading = (uint16_t)compass_getCompensated(); |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
162 } |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
163 else |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
164 { |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
165 heading = (uint16_t)stateUsed->lifeData.compass_heading; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
166 } |
38 | 167 snprintf(text,32,"\001%03i`",heading); |
168 write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text); | |
169 | |
170 tMenuEdit_refresh_field(StMHARD2_Compass_SetCourse); | |
171 tMenuEdit_refresh_field(StMHARD2_Compass_Calibrate); | |
172 tMenuEdit_refresh_field(StMHARD2_Compass_ResetCourse); | |
539
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
173 text[textIndex++] = TXT_2BYTE; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
174 text[textIndex++] = TXT2BYTE_CompassInertia; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
175 text[textIndex++] = ':'; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
176 text[textIndex++] = ' '; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
177 text[textIndex++] = '0' + settingsGetPointer()->compassInertia; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
178 |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
179 write_label_var(30, 800, ME_Y_LINE5, &FontT48, text); |
38 | 180 |
181 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
182 } | |
183 | |
184 | |
185 void openEdit_Compass(void) | |
186 { | |
539
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
187 char text[10]; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
188 uint8_t textIndex = 0; |
38 | 189 |
539
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
190 text[textIndex++] = '\001'; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
191 text[textIndex++] = TXT_2BYTE; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
192 text[textIndex++] = TXT2BYTE_Compass; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
193 text[textIndex++] = 0; |
38 | 194 write_topline(text); |
195 | |
196 text[0] = TXT_2BYTE; | |
197 text[2] = 0; | |
198 | |
199 text[1] = TXT2BYTE_SetBearing; | |
200 write_field_button(StMHARD2_Compass_SetCourse, 30, 800, ME_Y_LINE2, &FontT48, text); | |
201 | |
202 text[1] = TXT2BYTE_CompassCalib; | |
203 write_field_button(StMHARD2_Compass_Calibrate, 30, 800, ME_Y_LINE3, &FontT48, text); | |
204 | |
205 text[1] = TXT2BYTE_ResetBearing; | |
206 write_field_button(StMHARD2_Compass_ResetCourse, 30, 800, ME_Y_LINE4, &FontT48, text); | |
207 | |
539
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
208 text[1] = TXT2BYTE_CompassInertia; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
209 textIndex = 2; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
210 text[textIndex++] = ':'; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
211 text[textIndex++] = ' '; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
212 text[textIndex++] = '0' + settingsGetPointer()->compassInertia; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
213 |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
214 write_field_button(StMHARD2_Compass_Inertia, 30, 800, ME_Y_LINE5, &FontT48, text); |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
215 |
38 | 216 setEvent(StMHARD2_Compass_SetCourse, (uint32_t)OnAction_Bearing); |
217 setEvent(StMHARD2_Compass_Calibrate, (uint32_t)OnAction_Compass); | |
218 setEvent(StMHARD2_Compass_ResetCourse, (uint32_t)OnAction_BearingClear); | |
539
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
219 setEvent(StMHARD2_Compass_Inertia, (uint32_t)OnAction_InertiaLevel); |
38 | 220 |
221 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
222 } | |
223 | |
224 | |
225 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
226 { | |
227 calibrateCompass(); | |
228 return EXIT_TO_INFO_COMPASS; | |
229 } | |
230 | |
231 | |
232 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
233 { | |
234 settingsGetPointer()->compassBearing = (int16_t)stateUsed->lifeData.compass_heading; | |
235 if(settingsGetPointer()->compassBearing == 0) | |
236 settingsGetPointer()->compassBearing = 360; | |
237 return UPDATE_AND_EXIT_TO_MENU; | |
238 } | |
239 | |
240 | |
241 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
242 { | |
243 settingsGetPointer()->compassBearing = 0; | |
244 return UPDATE_AND_EXIT_TO_MENU; | |
245 } | |
246 | |
539
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
247 |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
248 uint8_t OnAction_InertiaLevel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
249 { |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
250 uint8_t newLevel = 0; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
251 |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
252 newLevel = settingsGetPointer()->compassInertia + 1; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
253 if(newLevel > MAX_COMPASS_COMP) |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
254 { |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
255 newLevel = 0; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
256 } |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
257 settingsGetPointer()->compassInertia = newLevel; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
258 return UPDATE_DIVESETTINGS; |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
259 } |
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
525
diff
changeset
|
260 |
38 | 261 /* |
262 uint8_t OnAction_ExitHardw (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
263 { | |
264 return EXIT_TO_MENU; | |
265 } | |
266 */ | |
267 | |
268 void refresh_O2Sensors(void) | |
269 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
270 char text[16]; |
38 | 271 uint16_t y_line; |
272 | |
273 text[0] = '\001'; | |
274 text[1] = TXT_o2Sensors; | |
275 text[2] = 0; | |
276 write_topline(text); | |
277 | |
278 | |
279 text[0] = TXT_2BYTE; | |
280 text[1] = TXT2BYTE_Sensor; | |
281 text[2] = ' '; | |
282 text[3] = '1'; | |
283 text[4] = 0; | |
284 write_label_var( 96, 340, ME_Y_LINE1, &FontT48, text); | |
285 text[3] = '2'; | |
286 write_label_var( 96, 340, ME_Y_LINE2, &FontT48, text); | |
287 text[3] = '3'; | |
288 write_label_var( 96, 340, ME_Y_LINE3, &FontT48, text); | |
289 | |
290 text[0] = TXT_2BYTE; | |
291 text[1] = TXT2BYTE_HUDbattery; | |
292 text[2] = 0; | |
293 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); | |
294 // write_label_var( 30, 340, ME_Y_LINE4, &FontT48, "HUD Battery"); | |
295 | |
296 for(int i=0;i<3;i++) | |
297 { | |
298 snprintf(text, 20,"%01.2f, %01.1fmV",get_ppO2Sensor_bar(i),get_sensorVoltage_mV(i)); | |
299 y_line = ME_Y_LINE1 + (i * ME_Y_LINE_STEP); | |
300 write_label_var( 400, 800, y_line, &FontT48, text); | |
301 } | |
302 | |
303 snprintf(text, 20,"%01.3fV", get_HUD_battery_voltage_V()); | |
304 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); | |
305 | |
306 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); | |
307 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); | |
308 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); | |
309 tMenuEdit_refresh_field(StMHARD3_O2_Fallback); | |
310 | |
311 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
312 } | |
313 | |
314 | |
315 void openEdit_O2Sensors(void) | |
316 { | |
317 char text[2]; | |
318 uint8_t sensorActive[3]; | |
319 | |
320 sensorActive[0] = 1; | |
321 sensorActive[1] = 1; | |
322 sensorActive[2] = 1; | |
323 if(settingsGetPointer()->ppo2sensors_deactivated & 1) | |
324 sensorActive[0] = 0; | |
325 if(settingsGetPointer()->ppo2sensors_deactivated & 2) | |
326 sensorActive[1] = 0; | |
327 if(settingsGetPointer()->ppo2sensors_deactivated & 4) | |
328 sensorActive[2] = 0; | |
329 | |
330 write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]); | |
331 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); | |
332 write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]); | |
333 | |
334 text[0] = TXT_Fallback; | |
335 text[1] = 1; | |
336 write_field_on_off(StMHARD3_O2_Fallback, 30, 500, ME_Y_LINE5, &FontT48, text, settingsGetPointer()->fallbackToFixedSetpoint); | |
337 | |
338 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); | |
339 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2); | |
340 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3); | |
341 setEvent(StMHARD3_O2_Fallback, (uint32_t)OnAction_O2_Fallback); | |
342 | |
343 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
344 } | |
345 | |
346 | |
347 uint8_t OnAction_Sensor1(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
348 { | |
349 if(settingsGetPointer()->ppo2sensors_deactivated & 1) | |
350 { | |
351 settingsGetPointer()->ppo2sensors_deactivated &= 4+2; | |
352 tMenuEdit_set_on_off(editId, 1); | |
353 } | |
354 else | |
355 { | |
356 settingsGetPointer()->ppo2sensors_deactivated |= 1; | |
357 tMenuEdit_set_on_off(editId, 0); | |
358 } | |
359 | |
360 return UPDATE_DIVESETTINGS; | |
361 } | |
362 | |
363 | |
364 uint8_t OnAction_Sensor2(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
365 { | |
366 if(settingsGetPointer()->ppo2sensors_deactivated & 2) | |
367 { | |
368 settingsGetPointer()->ppo2sensors_deactivated &= 4+1; | |
369 tMenuEdit_set_on_off(editId, 1); | |
370 } | |
371 else | |
372 { | |
373 settingsGetPointer()->ppo2sensors_deactivated |= 2; | |
374 tMenuEdit_set_on_off(editId, 0); | |
375 } | |
376 | |
377 return UPDATE_DIVESETTINGS; | |
378 } | |
379 | |
380 | |
381 uint8_t OnAction_Sensor3(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
382 { | |
383 if(settingsGetPointer()->ppo2sensors_deactivated & 4) | |
384 { | |
385 settingsGetPointer()->ppo2sensors_deactivated &= 2+1; | |
386 tMenuEdit_set_on_off(editId, 1); | |
387 } | |
388 else | |
389 { | |
390 settingsGetPointer()->ppo2sensors_deactivated |= 4; | |
391 tMenuEdit_set_on_off(editId, 0); | |
392 } | |
393 | |
394 return UPDATE_DIVESETTINGS; | |
395 } | |
396 | |
397 | |
398 uint8_t OnAction_O2_Fallback (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
399 { | |
400 uint8_t fallback = settingsGetPointer()->fallbackToFixedSetpoint; | |
401 | |
402 if(fallback) | |
403 fallback = 0; | |
404 else | |
405 fallback = 1; | |
406 | |
407 settingsGetPointer()->fallbackToFixedSetpoint = fallback; | |
408 tMenuEdit_set_on_off(editId, fallback); | |
409 return UPDATE_DIVESETTINGS; | |
410 } | |
411 | |
412 | |
413 void openEdit_Brightness(void) | |
414 { | |
415 uint8_t actualBrightness; | |
416 SSettings *pSettings = settingsGetPointer(); | |
417 | |
418 actualBrightness = pSettings->brightness; | |
419 actualBrightness++; | |
420 if(actualBrightness > 4) | |
421 actualBrightness = 0; | |
422 pSettings->brightness = actualBrightness; | |
423 exitEditWithUpdate(); | |
424 } | |
425 | |
426 | |
427 void buttonBalanceText_helper(uint8_t idOfButton, char *textOutput) | |
428 { | |
429 uint8_t txtcount = 0; | |
430 | |
431 if(idOfButton < 3) | |
432 { | |
433 textOutput[txtcount++] = '@' + settingsGetPointer()->buttonBalance[idOfButton]; | |
434 textOutput[txtcount++] = ' '; | |
435 textOutput[txtcount++] = ' '; | |
436 textOutput[txtcount++] = '('; | |
437 | |
438 switch(settingsGetPointer()->buttonBalance[idOfButton]) | |
439 { | |
440 case 1: | |
441 textOutput[txtcount++] = '-'; | |
442 textOutput[txtcount++] = '2'; | |
443 textOutput[txtcount++] = '0'; | |
444 break; | |
445 case 2: | |
446 textOutput[txtcount++] = '-'; | |
447 textOutput[txtcount++] = '1'; | |
448 textOutput[txtcount++] = '0'; | |
449 break; | |
450 case 3: | |
451 default: | |
452 textOutput[txtcount++] = '0'; | |
453 break; | |
454 case 4: | |
455 textOutput[txtcount++] = '+'; | |
456 textOutput[txtcount++] = '1'; | |
457 textOutput[txtcount++] = '0'; | |
458 break; | |
459 case 5: | |
460 textOutput[txtcount++] = '+'; | |
461 textOutput[txtcount++] = '2'; | |
462 textOutput[txtcount++] = '0'; | |
463 break; | |
464 } | |
465 textOutput[txtcount++] = ')'; | |
466 } | |
467 textOutput[txtcount++] = 0; | |
468 } | |
469 | |
470 /**# | |
471 ****************************************************************************** | |
472 * @brief BUTTONS | |
473 * @author heinrichs weikamp gmbh | |
474 * @version V 01 | |
475 * @date 15-Sept-2016 | |
476 ****************************************************************************** | |
477 * Button 0 is right, Button 1 is middle, Button 2 is left !!!! | |
478 * 2 1 0 (base value 3) | |
479 * Button 3 is used to store the base value, all others are balanced around this one! | |
480 * | |
481 */ | |
482 | |
483 void openEdit_ButtonSens(void) | |
484 { | |
485 char text[32]; | |
486 uint8_t sens; | |
487 const uint32_t eventListButtonBalance[3] = {StMHARD5_ButtonBalance1,StMHARD5_ButtonBalance2,StMHARD5_ButtonBalance3}; | |
488 | |
489 sens = (uint8_t)settingsGetPointer()->ButtonResponsiveness[3]; | |
490 write_field_3digit(StMHARD5_Button1, 360, 780, ME_Y_LINE1, &FontT48, "###", sens, 0, 0, 0); | |
491 | |
492 for(int i=2;i>=0;i--) | |
493 { | |
494 buttonBalanceText_helper(i,text); | |
495 write_field_button(eventListButtonBalance[i],360,500,ME_Y_LINE4-(i*ME_Y_LINE_STEP),&FontT48,text); | |
496 } | |
497 | |
498 | |
499 setEvent(StMHARD5_Button1, (uint32_t)OnAction_Button); | |
500 | |
501 for(int i=2;i>=0;i--) | |
502 { | |
503 setEvent(eventListButtonBalance[i], (uint32_t)OnAction_ButtonBalance); | |
504 } | |
505 | |
506 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
507 } | |
508 | |
509 | |
510 void refresh_ButtonValuesFromPIC(void) | |
511 { | |
512 uint8_t sens[3]; | |
513 char text[64]; | |
514 | |
515 text[0] = '\001'; | |
516 text[1] = TXT_2BYTE; | |
517 text[2] = TXT2BYTE_ButtonSensitivity; | |
518 text[3] = 0; | |
519 write_topline(text); | |
520 | |
521 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
522 | |
525
1f557e5f4b5a
Change color ID used in strings for light grey:
Ideenmodellierer
parents:
394
diff
changeset
|
523 text[0] = '\020'; // '\031'; |
38 | 524 text[1] = TXT_2BYTE; |
525 text[2] = TXT2BYTE_LowerIsLess; | |
526 text[3] = 0; | |
527 write_label_var( 20, 780, ME_Y_LINE5, &FontT42, text); | |
528 | |
529 for(int i=0;i<3;i++) | |
530 { | |
531 text[0] = TXT_2BYTE; | |
532 text[1] = TXT2BYTE_ButtonLeft+i; | |
533 text[2] = 0; | |
534 write_label_var( 20, 300, ME_Y_LINE2+(i*ME_Y_LINE_STEP), &FontT48, text); | |
535 } | |
536 | |
537 for(int i=0;i<3;i++) | |
538 { | |
539 sens[i] = settingsHelperButtonSens_translate_hwOS_values_to_percentage(stateRealGetPointer()->lifeData.buttonPICdata[i]); | |
540 } | |
541 snprintf(text,64,"(%03u %03u %03u)",sens[2],sens[1],sens[0]); | |
542 write_label_var( 20, 340, ME_Y_LINE6, &FontT42, text); | |
543 | |
544 tMenuEdit_refresh_field(StMHARD5_Button1); | |
545 tMenuEdit_refresh_field(StMHARD5_ButtonBalance1); | |
546 tMenuEdit_refresh_field(StMHARD5_ButtonBalance2); | |
547 tMenuEdit_refresh_field(StMHARD5_ButtonBalance3); | |
548 } | |
549 | |
550 | |
551 uint8_t OnAction_Button(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
552 { | |
553 uint8_t digitContentNew, remainder; | |
554 uint32_t newSensitivityGlobal; | |
555 | |
556 if(action == ACTION_BUTTON_NEXT) | |
557 { | |
558 digitContentNew = digitContent - '0'; | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
559 if(digitContentNew >= MAX_BUTTONRESPONSIVENESS_GUI) |
38 | 560 { |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
561 digitContentNew = MIN_BUTTONRESPONSIVENESS_GUI; |
38 | 562 } |
563 else | |
564 { | |
565 remainder = digitContentNew%5; | |
566 digitContentNew += 5 - remainder; | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
567 if(digitContentNew >= MAX_BUTTONRESPONSIVENESS_GUI) |
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
568 digitContentNew = MAX_BUTTONRESPONSIVENESS_GUI; |
38 | 569 } |
570 return '0' + digitContentNew; | |
571 } | |
572 | |
573 if(action == ACTION_BUTTON_BACK) | |
574 { | |
575 digitContentNew = digitContent - '0'; | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
576 if(digitContentNew <= MIN_BUTTONRESPONSIVENESS_GUI) |
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
577 digitContentNew = MAX_BUTTONRESPONSIVENESS_GUI; |
38 | 578 else |
579 { | |
580 remainder = digitContentNew%5; | |
581 if(remainder) | |
582 digitContentNew -= remainder; | |
583 else | |
584 digitContentNew -= 5; | |
585 } | |
586 return '0' + digitContentNew; | |
587 } | |
588 | |
589 if(action == ACTION_BUTTON_ENTER_FINAL) | |
590 { | |
591 evaluateNewString(editId, &newSensitivityGlobal, 0, 0, 0); | |
592 settingsHelperButtonSens_keepPercentageValues(newSensitivityGlobal, settingsGetPointer()->ButtonResponsiveness); | |
593 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); | |
594 return UNSPECIFIC_RETURN; | |
595 } | |
596 return digitContent; | |
597 } | |
598 | |
599 | |
600 uint8_t OnAction_ButtonBalance(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
601 { | |
602 int8_t idBalance = -1; | |
603 uint8_t *ptrSetting; | |
604 char text[32]; | |
605 | |
606 const uint32_t eventListButtonBalance[3] = {StMHARD5_ButtonBalance1,StMHARD5_ButtonBalance2,StMHARD5_ButtonBalance3}; | |
607 | |
608 idBalance = -1; | |
609 for(int i=0;i<3;i++) | |
610 { | |
611 if(editId == eventListButtonBalance[i]) | |
612 { | |
613 idBalance = i; | |
614 break; | |
615 } | |
616 } | |
617 | |
618 if((idBalance >= 0) && (idBalance < 3)) | |
619 { | |
620 ptrSetting = &settingsGetPointer()->buttonBalance[idBalance]; | |
621 | |
622 *ptrSetting += 1; | |
623 | |
624 if(*ptrSetting > 5) | |
625 *ptrSetting = 2; | |
626 | |
627 buttonBalanceText_helper(idBalance,text); | |
628 tMenuEdit_newButtonText(eventListButtonBalance[idBalance],text); | |
629 } | |
630 | |
631 return UNSPECIFIC_RETURN; | |
632 } |