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