Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditHardware.c @ 379:0dbf550dc743 MotionDetection
Added missing customerview selection
In the previous version only 6 out of 10 custom views could be configurated => Added a second page for the dive menu system tab
In case all views are deactivated the none / debug page will be set as default
author | ideenmodellierer |
---|---|
date | Mon, 16 Sep 2019 22:49:34 +0200 |
parents | e141b571a03d |
children | 717f335cc5c9 |
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(); |
314 | 137 GFX_build_logo_frame(); |
138 GFX_build_hw_background_frame(); | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
139 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
140 exitEditWithUpdate(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
141 exitMenuEdit_to_Home(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
142 } |
38 | 143 |
144 void refresh_CompassEdit(void) | |
145 { | |
146 uint16_t heading; | |
147 char text[32]; | |
148 | |
149 text[0] = '\001'; | |
150 text[1] = TXT_2BYTE; | |
151 text[2] = TXT2BYTE_Compass; | |
152 text[3] = 0; | |
153 write_topline(text); | |
154 | |
155 heading = (uint16_t)stateUsed->lifeData.compass_heading; | |
156 snprintf(text,32,"\001%03i`",heading); | |
157 write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text); | |
158 | |
159 tMenuEdit_refresh_field(StMHARD2_Compass_SetCourse); | |
160 tMenuEdit_refresh_field(StMHARD2_Compass_Calibrate); | |
161 tMenuEdit_refresh_field(StMHARD2_Compass_ResetCourse); | |
162 | |
163 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
164 } | |
165 | |
166 | |
167 void openEdit_Compass(void) | |
168 { | |
169 char text[4]; | |
170 | |
171 text[0] = '\001'; | |
172 text[1] = TXT_2BYTE; | |
173 text[2] = TXT2BYTE_Compass; | |
174 text[3] = 0; | |
175 write_topline(text); | |
176 | |
177 text[0] = TXT_2BYTE; | |
178 text[2] = 0; | |
179 | |
180 text[1] = TXT2BYTE_SetBearing; | |
181 write_field_button(StMHARD2_Compass_SetCourse, 30, 800, ME_Y_LINE2, &FontT48, text); | |
182 | |
183 text[1] = TXT2BYTE_CompassCalib; | |
184 write_field_button(StMHARD2_Compass_Calibrate, 30, 800, ME_Y_LINE3, &FontT48, text); | |
185 | |
186 text[1] = TXT2BYTE_ResetBearing; | |
187 write_field_button(StMHARD2_Compass_ResetCourse, 30, 800, ME_Y_LINE4, &FontT48, text); | |
188 | |
189 setEvent(StMHARD2_Compass_SetCourse, (uint32_t)OnAction_Bearing); | |
190 setEvent(StMHARD2_Compass_Calibrate, (uint32_t)OnAction_Compass); | |
191 setEvent(StMHARD2_Compass_ResetCourse, (uint32_t)OnAction_BearingClear); | |
192 | |
193 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
194 } | |
195 | |
196 | |
197 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
198 { | |
199 calibrateCompass(); | |
200 return EXIT_TO_INFO_COMPASS; | |
201 } | |
202 | |
203 | |
204 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
205 { | |
206 settingsGetPointer()->compassBearing = (int16_t)stateUsed->lifeData.compass_heading; | |
207 if(settingsGetPointer()->compassBearing == 0) | |
208 settingsGetPointer()->compassBearing = 360; | |
209 return UPDATE_AND_EXIT_TO_MENU; | |
210 } | |
211 | |
212 | |
213 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
214 { | |
215 settingsGetPointer()->compassBearing = 0; | |
216 return UPDATE_AND_EXIT_TO_MENU; | |
217 } | |
218 | |
219 /* | |
220 uint8_t OnAction_ExitHardw (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
221 { | |
222 return EXIT_TO_MENU; | |
223 } | |
224 */ | |
225 | |
226 void refresh_O2Sensors(void) | |
227 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
228 char text[16]; |
38 | 229 uint16_t y_line; |
230 | |
231 text[0] = '\001'; | |
232 text[1] = TXT_o2Sensors; | |
233 text[2] = 0; | |
234 write_topline(text); | |
235 | |
236 | |
237 text[0] = TXT_2BYTE; | |
238 text[1] = TXT2BYTE_Sensor; | |
239 text[2] = ' '; | |
240 text[3] = '1'; | |
241 text[4] = 0; | |
242 write_label_var( 96, 340, ME_Y_LINE1, &FontT48, text); | |
243 text[3] = '2'; | |
244 write_label_var( 96, 340, ME_Y_LINE2, &FontT48, text); | |
245 text[3] = '3'; | |
246 write_label_var( 96, 340, ME_Y_LINE3, &FontT48, text); | |
247 | |
248 text[0] = TXT_2BYTE; | |
249 text[1] = TXT2BYTE_HUDbattery; | |
250 text[2] = 0; | |
251 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); | |
252 // write_label_var( 30, 340, ME_Y_LINE4, &FontT48, "HUD Battery"); | |
253 | |
254 for(int i=0;i<3;i++) | |
255 { | |
256 snprintf(text, 20,"%01.2f, %01.1fmV",get_ppO2Sensor_bar(i),get_sensorVoltage_mV(i)); | |
257 y_line = ME_Y_LINE1 + (i * ME_Y_LINE_STEP); | |
258 write_label_var( 400, 800, y_line, &FontT48, text); | |
259 } | |
260 | |
261 snprintf(text, 20,"%01.3fV", get_HUD_battery_voltage_V()); | |
262 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); | |
263 | |
264 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); | |
265 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); | |
266 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); | |
267 tMenuEdit_refresh_field(StMHARD3_O2_Fallback); | |
268 | |
269 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
270 } | |
271 | |
272 | |
273 void openEdit_O2Sensors(void) | |
274 { | |
275 char text[2]; | |
276 uint8_t sensorActive[3]; | |
277 | |
278 sensorActive[0] = 1; | |
279 sensorActive[1] = 1; | |
280 sensorActive[2] = 1; | |
281 if(settingsGetPointer()->ppo2sensors_deactivated & 1) | |
282 sensorActive[0] = 0; | |
283 if(settingsGetPointer()->ppo2sensors_deactivated & 2) | |
284 sensorActive[1] = 0; | |
285 if(settingsGetPointer()->ppo2sensors_deactivated & 4) | |
286 sensorActive[2] = 0; | |
287 | |
288 write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]); | |
289 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); | |
290 write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]); | |
291 | |
292 text[0] = TXT_Fallback; | |
293 text[1] = 1; | |
294 write_field_on_off(StMHARD3_O2_Fallback, 30, 500, ME_Y_LINE5, &FontT48, text, settingsGetPointer()->fallbackToFixedSetpoint); | |
295 | |
296 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); | |
297 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2); | |
298 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3); | |
299 setEvent(StMHARD3_O2_Fallback, (uint32_t)OnAction_O2_Fallback); | |
300 | |
301 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
302 } | |
303 | |
304 | |
305 uint8_t OnAction_Sensor1(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
306 { | |
307 if(settingsGetPointer()->ppo2sensors_deactivated & 1) | |
308 { | |
309 settingsGetPointer()->ppo2sensors_deactivated &= 4+2; | |
310 tMenuEdit_set_on_off(editId, 1); | |
311 } | |
312 else | |
313 { | |
314 settingsGetPointer()->ppo2sensors_deactivated |= 1; | |
315 tMenuEdit_set_on_off(editId, 0); | |
316 } | |
317 | |
318 return UPDATE_DIVESETTINGS; | |
319 } | |
320 | |
321 | |
322 uint8_t OnAction_Sensor2(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
323 { | |
324 if(settingsGetPointer()->ppo2sensors_deactivated & 2) | |
325 { | |
326 settingsGetPointer()->ppo2sensors_deactivated &= 4+1; | |
327 tMenuEdit_set_on_off(editId, 1); | |
328 } | |
329 else | |
330 { | |
331 settingsGetPointer()->ppo2sensors_deactivated |= 2; | |
332 tMenuEdit_set_on_off(editId, 0); | |
333 } | |
334 | |
335 return UPDATE_DIVESETTINGS; | |
336 } | |
337 | |
338 | |
339 uint8_t OnAction_Sensor3(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
340 { | |
341 if(settingsGetPointer()->ppo2sensors_deactivated & 4) | |
342 { | |
343 settingsGetPointer()->ppo2sensors_deactivated &= 2+1; | |
344 tMenuEdit_set_on_off(editId, 1); | |
345 } | |
346 else | |
347 { | |
348 settingsGetPointer()->ppo2sensors_deactivated |= 4; | |
349 tMenuEdit_set_on_off(editId, 0); | |
350 } | |
351 | |
352 return UPDATE_DIVESETTINGS; | |
353 } | |
354 | |
355 | |
356 uint8_t OnAction_O2_Fallback (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
357 { | |
358 uint8_t fallback = settingsGetPointer()->fallbackToFixedSetpoint; | |
359 | |
360 if(fallback) | |
361 fallback = 0; | |
362 else | |
363 fallback = 1; | |
364 | |
365 settingsGetPointer()->fallbackToFixedSetpoint = fallback; | |
366 tMenuEdit_set_on_off(editId, fallback); | |
367 return UPDATE_DIVESETTINGS; | |
368 } | |
369 | |
370 | |
371 void openEdit_Brightness(void) | |
372 { | |
373 uint8_t actualBrightness; | |
374 SSettings *pSettings = settingsGetPointer(); | |
375 | |
376 actualBrightness = pSettings->brightness; | |
377 actualBrightness++; | |
378 if(actualBrightness > 4) | |
379 actualBrightness = 0; | |
380 pSettings->brightness = actualBrightness; | |
381 exitEditWithUpdate(); | |
382 } | |
383 | |
384 | |
385 void buttonBalanceText_helper(uint8_t idOfButton, char *textOutput) | |
386 { | |
387 uint8_t txtcount = 0; | |
388 | |
389 if(idOfButton < 3) | |
390 { | |
391 textOutput[txtcount++] = '@' + settingsGetPointer()->buttonBalance[idOfButton]; | |
392 textOutput[txtcount++] = ' '; | |
393 textOutput[txtcount++] = ' '; | |
394 textOutput[txtcount++] = '('; | |
395 | |
396 switch(settingsGetPointer()->buttonBalance[idOfButton]) | |
397 { | |
398 case 1: | |
399 textOutput[txtcount++] = '-'; | |
400 textOutput[txtcount++] = '2'; | |
401 textOutput[txtcount++] = '0'; | |
402 break; | |
403 case 2: | |
404 textOutput[txtcount++] = '-'; | |
405 textOutput[txtcount++] = '1'; | |
406 textOutput[txtcount++] = '0'; | |
407 break; | |
408 case 3: | |
409 default: | |
410 textOutput[txtcount++] = '0'; | |
411 break; | |
412 case 4: | |
413 textOutput[txtcount++] = '+'; | |
414 textOutput[txtcount++] = '1'; | |
415 textOutput[txtcount++] = '0'; | |
416 break; | |
417 case 5: | |
418 textOutput[txtcount++] = '+'; | |
419 textOutput[txtcount++] = '2'; | |
420 textOutput[txtcount++] = '0'; | |
421 break; | |
422 } | |
423 textOutput[txtcount++] = ')'; | |
424 } | |
425 textOutput[txtcount++] = 0; | |
426 } | |
427 | |
428 /**# | |
429 ****************************************************************************** | |
430 * @brief BUTTONS | |
431 * @author heinrichs weikamp gmbh | |
432 * @version V 01 | |
433 * @date 15-Sept-2016 | |
434 ****************************************************************************** | |
435 * Button 0 is right, Button 1 is middle, Button 2 is left !!!! | |
436 * 2 1 0 (base value 3) | |
437 * Button 3 is used to store the base value, all others are balanced around this one! | |
438 * | |
439 */ | |
440 | |
441 void openEdit_ButtonSens(void) | |
442 { | |
443 char text[32]; | |
444 uint8_t sens; | |
445 const uint32_t eventListButtonBalance[3] = {StMHARD5_ButtonBalance1,StMHARD5_ButtonBalance2,StMHARD5_ButtonBalance3}; | |
446 | |
447 sens = (uint8_t)settingsGetPointer()->ButtonResponsiveness[3]; | |
448 write_field_3digit(StMHARD5_Button1, 360, 780, ME_Y_LINE1, &FontT48, "###", sens, 0, 0, 0); | |
449 | |
450 for(int i=2;i>=0;i--) | |
451 { | |
452 buttonBalanceText_helper(i,text); | |
453 write_field_button(eventListButtonBalance[i],360,500,ME_Y_LINE4-(i*ME_Y_LINE_STEP),&FontT48,text); | |
454 } | |
455 | |
456 | |
457 setEvent(StMHARD5_Button1, (uint32_t)OnAction_Button); | |
458 | |
459 for(int i=2;i>=0;i--) | |
460 { | |
461 setEvent(eventListButtonBalance[i], (uint32_t)OnAction_ButtonBalance); | |
462 } | |
463 | |
464 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
465 } | |
466 | |
467 | |
468 void refresh_ButtonValuesFromPIC(void) | |
469 { | |
470 uint8_t sens[3]; | |
471 char text[64]; | |
472 | |
473 text[0] = '\001'; | |
474 text[1] = TXT_2BYTE; | |
475 text[2] = TXT2BYTE_ButtonSensitivity; | |
476 text[3] = 0; | |
477 write_topline(text); | |
478 | |
479 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
480 | |
481 text[0] = '\020'; // '\021'; | |
482 text[1] = TXT_2BYTE; | |
483 text[2] = TXT2BYTE_LowerIsLess; | |
484 text[3] = 0; | |
485 write_label_var( 20, 780, ME_Y_LINE5, &FontT42, text); | |
486 | |
487 for(int i=0;i<3;i++) | |
488 { | |
489 text[0] = TXT_2BYTE; | |
490 text[1] = TXT2BYTE_ButtonLeft+i; | |
491 text[2] = 0; | |
492 write_label_var( 20, 300, ME_Y_LINE2+(i*ME_Y_LINE_STEP), &FontT48, text); | |
493 } | |
494 | |
495 for(int i=0;i<3;i++) | |
496 { | |
497 sens[i] = settingsHelperButtonSens_translate_hwOS_values_to_percentage(stateRealGetPointer()->lifeData.buttonPICdata[i]); | |
498 } | |
499 snprintf(text,64,"(%03u %03u %03u)",sens[2],sens[1],sens[0]); | |
500 write_label_var( 20, 340, ME_Y_LINE6, &FontT42, text); | |
501 | |
502 tMenuEdit_refresh_field(StMHARD5_Button1); | |
503 tMenuEdit_refresh_field(StMHARD5_ButtonBalance1); | |
504 tMenuEdit_refresh_field(StMHARD5_ButtonBalance2); | |
505 tMenuEdit_refresh_field(StMHARD5_ButtonBalance3); | |
506 } | |
507 | |
508 | |
509 uint8_t OnAction_Button(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
510 { | |
511 uint8_t digitContentNew, remainder; | |
512 uint32_t newSensitivityGlobal; | |
513 | |
514 if(action == ACTION_BUTTON_NEXT) | |
515 { | |
516 digitContentNew = digitContent - '0'; | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
517 if(digitContentNew >= MAX_BUTTONRESPONSIVENESS_GUI) |
38 | 518 { |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
519 digitContentNew = MIN_BUTTONRESPONSIVENESS_GUI; |
38 | 520 } |
521 else | |
522 { | |
523 remainder = digitContentNew%5; | |
524 digitContentNew += 5 - remainder; | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
525 if(digitContentNew >= MAX_BUTTONRESPONSIVENESS_GUI) |
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
526 digitContentNew = MAX_BUTTONRESPONSIVENESS_GUI; |
38 | 527 } |
528 return '0' + digitContentNew; | |
529 } | |
530 | |
531 if(action == ACTION_BUTTON_BACK) | |
532 { | |
533 digitContentNew = digitContent - '0'; | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
534 if(digitContentNew <= MIN_BUTTONRESPONSIVENESS_GUI) |
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
535 digitContentNew = MAX_BUTTONRESPONSIVENESS_GUI; |
38 | 536 else |
537 { | |
538 remainder = digitContentNew%5; | |
539 if(remainder) | |
540 digitContentNew -= remainder; | |
541 else | |
542 digitContentNew -= 5; | |
543 } | |
544 return '0' + digitContentNew; | |
545 } | |
546 | |
547 if(action == ACTION_BUTTON_ENTER_FINAL) | |
548 { | |
549 evaluateNewString(editId, &newSensitivityGlobal, 0, 0, 0); | |
550 settingsHelperButtonSens_keepPercentageValues(newSensitivityGlobal, settingsGetPointer()->ButtonResponsiveness); | |
551 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); | |
552 return UNSPECIFIC_RETURN; | |
553 } | |
554 return digitContent; | |
555 } | |
556 | |
557 | |
558 uint8_t OnAction_ButtonBalance(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
559 { | |
560 int8_t idBalance = -1; | |
561 uint8_t *ptrSetting; | |
562 char text[32]; | |
563 | |
564 const uint32_t eventListButtonBalance[3] = {StMHARD5_ButtonBalance1,StMHARD5_ButtonBalance2,StMHARD5_ButtonBalance3}; | |
565 | |
566 idBalance = -1; | |
567 for(int i=0;i<3;i++) | |
568 { | |
569 if(editId == eventListButtonBalance[i]) | |
570 { | |
571 idBalance = i; | |
572 break; | |
573 } | |
574 } | |
575 | |
576 if((idBalance >= 0) && (idBalance < 3)) | |
577 { | |
578 ptrSetting = &settingsGetPointer()->buttonBalance[idBalance]; | |
579 | |
580 *ptrSetting += 1; | |
581 | |
582 if(*ptrSetting > 5) | |
583 *ptrSetting = 2; | |
584 | |
585 buttonBalanceText_helper(idBalance,text); | |
586 tMenuEdit_newButtonText(eventListButtonBalance[idBalance],text); | |
587 } | |
588 | |
589 return UNSPECIFIC_RETURN; | |
590 } |