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