Mercurial > public > ostc4
annotate Discovery/Src/tMenuEditHardware.c @ 126:98fb81f293a1 kittz
build files
author | heinrichsweikamp |
---|---|
date | Sun, 03 Feb 2019 10:04:27 +0100 |
parents | be35821a4974 |
children | 3834b6272ee5 |
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 "bonex4.h" | |
33 #include "externCPU2bootloader.h" | |
34 #include "gfx_fonts.h" | |
35 #include "ostc.h" | |
36 #include "tCCR.h" | |
37 #include "tMenuEdit.h" | |
38 | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
39 |
38 | 40 /* Private function prototypes -----------------------------------------------*/ |
41 void openEdit_Bluetooth(void); | |
42 void openEdit_Compass(void); | |
43 void openEdit_O2Sensors(void); | |
44 void openEdit_Brightness(void); | |
45 //void openEdit_Luftintegration(void); | |
46 void openEdit_ButtonSens(void); | |
47 void openEdit_ScooterControl(void); | |
48 | |
49 /* Announced function prototypes -----------------------------------------------*/ | |
50 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
51 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
52 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
53 //uint8_t OnAction_ExitHardw (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
54 uint8_t OnAction_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
55 uint8_t OnAction_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
56 uint8_t OnAction_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
57 uint8_t OnAction_O2_Fallback (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
58 uint8_t OnAction_Button (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
59 uint8_t OnAction_ButtonBalance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
60 uint8_t OnAction_ScooterDrag (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
61 uint8_t OnAction_ScooterLoad (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
62 uint8_t OnAction_ScooterBatt (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 // nicht notwending uint8_t OnAction_ScooterControl (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: | |
92 openEdit_ScooterControl(); | |
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(); | |
108 } | |
109 else | |
110 { | |
111 pSettings->bluetoothActive = 0; | |
112 MX_Bluetooth_PowerOff(); | |
113 } | |
114 exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only(); | |
115 } | |
116 | |
117 /* | |
118 void refresh_ScooterControl(void) | |
119 { | |
120 char text[256]; | |
121 | |
122 text[0] = '\001'; | |
123 text[1] = TXT_2BYTE; | |
124 text[2] = TXT2BYTE_ScooterSetup; | |
125 text[3] = 0; | |
126 write_topline(text); | |
127 | |
128 // drag | |
129 text[0] = TXT_2BYTE; | |
130 text[1] = TXT2BYTE_ScooterDrag; | |
131 text[2] = 0; | |
132 write_label_var( 30, 180, ME_Y_LINE1, &FontT48, text); | |
133 // load | |
134 text[0] = TXT_2BYTE; | |
135 text[1] = TXT2BYTE_ScooterLoad; | |
136 text[2] = 0; | |
137 write_label_var( 30, 180, ME_Y_LINE2, &FontT48, text); | |
138 // batt type | |
139 text[0] = TXT_2BYTE; | |
140 text[1] = TXT2BYTE_ScooterBattTyp; | |
141 text[2] = 0; | |
142 write_label_var( 30, 180, ME_Y_LINE3, &FontT48, text); | |
143 | |
144 // drag | |
145 text[0] = TXT_2BYTE; | |
146 text[1] = 0; | |
147 text[2] = 0; | |
148 switch(settingsGetPointer()->scooterDrag) | |
149 { | |
150 case 0: | |
151 text[1] = TXT2BYTE_ScooterD0Apnoe; | |
152 break; | |
153 case 1: | |
154 text[1] = TXT2BYTE_ScooterD1Scuba; | |
155 break; | |
156 case 2: | |
157 text[1] = TXT2BYTE_ScooterD2Tech; | |
158 break; | |
159 case 3: | |
160 text[1] = TXT2BYTE_ScooterD3Heavy; | |
161 break; | |
162 default: | |
163 snprintf(&text[4],3,"%02u",settingsGetPointer()->scooterDrag); | |
164 break; | |
165 } | |
166 write_label_var( 200, 700, ME_Y_LINE1, &FontT48, text); | |
167 | |
168 // load | |
169 text[0] = TXT_2BYTE; | |
170 text[1] = 0; | |
171 text[2] = 0; | |
172 switch(settingsGetPointer()->scooterLoad) | |
173 { | |
174 case 0: | |
175 text[1] = TXT2BYTE_ScooterL0None; | |
176 break; | |
177 case 1: | |
178 text[1] = TXT2BYTE_ScooterL1Small; | |
179 break; | |
180 case 2: | |
181 text[1] = TXT2BYTE_ScooterL2Stages; | |
182 break; | |
183 case 3: | |
184 text[1] = TXT2BYTE_ScooterL3Full; | |
185 break; | |
186 case 4: | |
187 text[1] = TXT2BYTE_ScooterL4Towing; | |
188 break; | |
189 default: | |
190 snprintf(&text[4],3,"%02u",settingsGetPointer()->scooterLoad); | |
191 break; | |
192 } | |
193 write_label_var( 200, 700, ME_Y_LINE2, &FontT48, text); | |
194 | |
195 //batt type | |
196 | |
197 // txtptr = 0; | |
198 // txtptr += bo4GetBatteryName(text,settingsGetPointer()->scooterBattType); | |
199 // txtptr += snprintf(&text[txtptr],10," (%0.1f V)",bo4GetBatteryVoltage(settingsGetPointer()->scooterBattType)); | |
200 // write_label_var( 200, 700, ME_Y_LINE3, &FontT48, text); | |
201 } | |
202 */ | |
203 | |
204 void getButtonText_ScooterControl(char *text, uint8_t * pointer) | |
205 { | |
206 | |
207 if((pointer != &settingsGetPointer()->scooterLoad) && (pointer != &settingsGetPointer()->scooterDrag)) | |
208 return; | |
209 | |
210 text[0] = TXT_2BYTE; | |
211 text[1] = 0; | |
212 text[2] = 0; | |
213 | |
214 // drag | |
215 if(pointer == &settingsGetPointer()->scooterDrag) | |
216 { | |
217 switch(settingsGetPointer()->scooterDrag) | |
218 { | |
219 case 0: | |
220 text[1] = TXT2BYTE_ScooterD0Apnoe; | |
221 break; | |
222 case 1: | |
223 text[1] = TXT2BYTE_ScooterD1Scuba; | |
224 break; | |
225 case 2: | |
226 text[1] = TXT2BYTE_ScooterD2Tech; | |
227 break; | |
228 case 3: | |
229 text[1] = TXT2BYTE_ScooterD3Heavy; | |
230 break; | |
231 default: | |
232 snprintf(&text[4],3,"%02u",settingsGetPointer()->scooterDrag); | |
233 break; | |
234 } | |
235 } | |
236 else // load | |
237 if(pointer == &settingsGetPointer()->scooterLoad) | |
238 { | |
239 | |
240 switch(settingsGetPointer()->scooterLoad) | |
241 { | |
242 case 0: | |
243 text[1] = TXT2BYTE_ScooterL0None; | |
244 break; | |
245 case 1: | |
246 text[1] = TXT2BYTE_ScooterL1Small; | |
247 break; | |
248 case 2: | |
249 text[1] = TXT2BYTE_ScooterL2Stages; | |
250 break; | |
251 case 3: | |
252 text[1] = TXT2BYTE_ScooterL3Full; | |
253 break; | |
254 case 4: | |
255 text[1] = TXT2BYTE_ScooterL4Towing; | |
256 break; | |
257 default: | |
258 snprintf(&text[4],3,"%02u",settingsGetPointer()->scooterLoad); | |
259 break; | |
260 } | |
261 } | |
262 } | |
263 | |
264 | |
265 void openEdit_ScooterControl(void) | |
266 { | |
267 char text[256]; | |
268 uint16_t battWh; | |
269 | |
270 text[0] = '\001'; | |
271 text[1] = TXT_2BYTE; | |
272 text[2] = TXT2BYTE_ScooterSetup; | |
273 text[3] = 0; | |
274 write_topline(text); | |
275 | |
276 // drag | |
277 text[0] = TXT_2BYTE; | |
278 text[1] = TXT2BYTE_ScooterDrag; | |
279 text[2] = 0; | |
280 write_label_var( 30, 180, ME_Y_LINE1, &FontT48, text); | |
281 // load | |
282 text[0] = TXT_2BYTE; | |
283 text[1] = TXT2BYTE_ScooterLoad; | |
284 text[2] = 0; | |
285 write_label_var( 30, 180, ME_Y_LINE2, &FontT48, text); | |
286 // batt type | |
287 text[0] = TXT_2BYTE; | |
288 text[1] = TXT2BYTE_ScooterBattTyp; | |
289 text[2] = 0; | |
290 write_label_var( 30, 180, ME_Y_LINE3, &FontT48, text); | |
291 | |
292 getButtonText_ScooterControl(text,&settingsGetPointer()->scooterDrag); | |
293 write_field_button(StMHARD6_ScooterDrag, 200, 770, ME_Y_LINE1, &FontT48, text); | |
294 | |
295 getButtonText_ScooterControl(text,&settingsGetPointer()->scooterLoad); | |
296 write_field_button(StMHARD6_ScooterLoad, 200, 770, ME_Y_LINE2, &FontT48, text); | |
297 | |
298 battWh = settingsGetPointer()->scooterBattSize; | |
299 write_field_udigit(StMHARD6_ScooterBatt, 200, 770, ME_Y_LINE3, &FontT48, "####\016\016 Wh\017", battWh, 0, 0, 0); | |
300 | |
301 setEvent(StMHARD6_ScooterDrag, (uint32_t)OnAction_ScooterDrag); | |
302 setEvent(StMHARD6_ScooterLoad, (uint32_t)OnAction_ScooterLoad); | |
303 setEvent(StMHARD6_ScooterBatt, (uint32_t)OnAction_ScooterBatt); | |
304 | |
305 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
306 } | |
307 | |
308 | |
309 uint8_t OnAction_ScooterDrag(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
310 { | |
311 char text[256]; | |
312 | |
313 settingsGetPointer()->scooterDrag = settingsGetPointer()->scooterDrag + 1; | |
314 if(settingsGetPointer()->scooterDrag > 3) | |
315 settingsGetPointer()->scooterDrag = 0; | |
316 | |
317 getButtonText_ScooterControl(text,&settingsGetPointer()->scooterDrag); | |
318 tMenuEdit_newButtonText(editId, text); | |
319 | |
320 return UPDATE_DIVESETTINGS; | |
321 } | |
322 | |
323 | |
324 uint8_t OnAction_ScooterLoad(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
325 { | |
326 char text[256]; | |
327 | |
328 settingsGetPointer()->scooterLoad = settingsGetPointer()->scooterLoad + 1; | |
329 if(settingsGetPointer()->scooterLoad > 4) | |
330 settingsGetPointer()->scooterLoad = 0; | |
331 | |
332 getButtonText_ScooterControl(text,&settingsGetPointer()->scooterLoad); | |
333 tMenuEdit_newButtonText(editId, text); | |
334 | |
335 return UPDATE_DIVESETTINGS; | |
336 } | |
337 | |
338 | |
339 uint8_t OnAction_ScooterBatt(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
340 { | |
341 uint8_t digitContentNew; | |
342 uint32_t newWh; | |
343 | |
344 if(action == ACTION_BUTTON_ENTER) | |
345 { | |
346 return digitContent; | |
347 } | |
348 if(action == ACTION_BUTTON_ENTER_FINAL) | |
349 { | |
350 evaluateNewString(editId, &newWh, 0, 0, 0); | |
351 | |
352 if(newWh < 300) | |
353 newWh = 300; | |
354 if(newWh > 5000) | |
355 newWh = 5000; | |
356 | |
357 tMenuEdit_newInput(editId, newWh, 0, 0, 0); | |
358 settingsGetPointer()->scooterBattSize = newWh; | |
359 return UPDATE_DIVESETTINGS; | |
360 } | |
361 if(action == ACTION_BUTTON_NEXT) | |
362 { | |
363 digitContentNew = digitContent + 1; | |
364 if(digitNumber == 0) | |
365 { | |
366 if(digitContentNew > '5') | |
367 digitContentNew = '0'; | |
368 } | |
369 else if(digitContentNew > '9') | |
370 digitContentNew = '0'; | |
371 return digitContentNew; | |
372 } | |
373 if(action == ACTION_BUTTON_BACK) | |
374 { | |
375 digitContentNew = digitContent - 1; | |
376 if(digitNumber == 0) | |
377 { | |
378 if(digitContentNew < '0') | |
379 digitContentNew = '5'; | |
380 } | |
381 else if(digitContentNew < '0') | |
382 digitContentNew = '9'; | |
383 return digitContentNew; | |
384 } | |
385 return UNSPECIFIC_RETURN; | |
386 } | |
387 | |
388 | |
389 void refresh_CompassEdit(void) | |
390 { | |
391 uint16_t heading; | |
392 char text[32]; | |
393 | |
394 text[0] = '\001'; | |
395 text[1] = TXT_2BYTE; | |
396 text[2] = TXT2BYTE_Compass; | |
397 text[3] = 0; | |
398 write_topline(text); | |
399 | |
400 heading = (uint16_t)stateUsed->lifeData.compass_heading; | |
401 snprintf(text,32,"\001%03i`",heading); | |
402 write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text); | |
403 | |
404 tMenuEdit_refresh_field(StMHARD2_Compass_SetCourse); | |
405 tMenuEdit_refresh_field(StMHARD2_Compass_Calibrate); | |
406 tMenuEdit_refresh_field(StMHARD2_Compass_ResetCourse); | |
407 | |
408 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
409 } | |
410 | |
411 | |
412 void openEdit_Compass(void) | |
413 { | |
414 char text[4]; | |
415 | |
416 text[0] = '\001'; | |
417 text[1] = TXT_2BYTE; | |
418 text[2] = TXT2BYTE_Compass; | |
419 text[3] = 0; | |
420 write_topline(text); | |
421 | |
422 text[0] = TXT_2BYTE; | |
423 text[2] = 0; | |
424 | |
425 text[1] = TXT2BYTE_SetBearing; | |
426 write_field_button(StMHARD2_Compass_SetCourse, 30, 800, ME_Y_LINE2, &FontT48, text); | |
427 | |
428 text[1] = TXT2BYTE_CompassCalib; | |
429 write_field_button(StMHARD2_Compass_Calibrate, 30, 800, ME_Y_LINE3, &FontT48, text); | |
430 | |
431 text[1] = TXT2BYTE_ResetBearing; | |
432 write_field_button(StMHARD2_Compass_ResetCourse, 30, 800, ME_Y_LINE4, &FontT48, text); | |
433 | |
434 setEvent(StMHARD2_Compass_SetCourse, (uint32_t)OnAction_Bearing); | |
435 setEvent(StMHARD2_Compass_Calibrate, (uint32_t)OnAction_Compass); | |
436 setEvent(StMHARD2_Compass_ResetCourse, (uint32_t)OnAction_BearingClear); | |
437 | |
438 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
439 } | |
440 | |
441 | |
442 uint8_t OnAction_Compass (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
443 { | |
444 calibrateCompass(); | |
445 return EXIT_TO_INFO_COMPASS; | |
446 } | |
447 | |
448 | |
449 uint8_t OnAction_Bearing (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
450 { | |
451 settingsGetPointer()->compassBearing = (int16_t)stateUsed->lifeData.compass_heading; | |
452 if(settingsGetPointer()->compassBearing == 0) | |
453 settingsGetPointer()->compassBearing = 360; | |
454 return UPDATE_AND_EXIT_TO_MENU; | |
455 } | |
456 | |
457 | |
458 uint8_t OnAction_BearingClear (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
459 { | |
460 settingsGetPointer()->compassBearing = 0; | |
461 return UPDATE_AND_EXIT_TO_MENU; | |
462 } | |
463 | |
464 /* | |
465 uint8_t OnAction_ExitHardw (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
466 { | |
467 return EXIT_TO_MENU; | |
468 } | |
469 */ | |
470 | |
471 void refresh_O2Sensors(void) | |
472 { | |
473 char text[10]; | |
474 uint16_t y_line; | |
475 | |
476 text[0] = '\001'; | |
477 text[1] = TXT_o2Sensors; | |
478 text[2] = 0; | |
479 write_topline(text); | |
480 | |
481 | |
482 text[0] = TXT_2BYTE; | |
483 text[1] = TXT2BYTE_Sensor; | |
484 text[2] = ' '; | |
485 text[3] = '1'; | |
486 text[4] = 0; | |
487 write_label_var( 96, 340, ME_Y_LINE1, &FontT48, text); | |
488 text[3] = '2'; | |
489 write_label_var( 96, 340, ME_Y_LINE2, &FontT48, text); | |
490 text[3] = '3'; | |
491 write_label_var( 96, 340, ME_Y_LINE3, &FontT48, text); | |
492 | |
493 text[0] = TXT_2BYTE; | |
494 text[1] = TXT2BYTE_HUDbattery; | |
495 text[2] = 0; | |
496 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); | |
497 // write_label_var( 30, 340, ME_Y_LINE4, &FontT48, "HUD Battery"); | |
498 | |
499 for(int i=0;i<3;i++) | |
500 { | |
501 snprintf(text, 20,"%01.2f, %01.1fmV",get_ppO2Sensor_bar(i),get_sensorVoltage_mV(i)); | |
502 y_line = ME_Y_LINE1 + (i * ME_Y_LINE_STEP); | |
503 write_label_var( 400, 800, y_line, &FontT48, text); | |
504 } | |
505 | |
506 snprintf(text, 20,"%01.3fV", get_HUD_battery_voltage_V()); | |
507 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); | |
508 | |
509 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); | |
510 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); | |
511 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); | |
512 tMenuEdit_refresh_field(StMHARD3_O2_Fallback); | |
513 | |
514 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
515 } | |
516 | |
517 | |
518 void openEdit_O2Sensors(void) | |
519 { | |
520 char text[2]; | |
521 uint8_t sensorActive[3]; | |
522 | |
523 sensorActive[0] = 1; | |
524 sensorActive[1] = 1; | |
525 sensorActive[2] = 1; | |
526 if(settingsGetPointer()->ppo2sensors_deactivated & 1) | |
527 sensorActive[0] = 0; | |
528 if(settingsGetPointer()->ppo2sensors_deactivated & 2) | |
529 sensorActive[1] = 0; | |
530 if(settingsGetPointer()->ppo2sensors_deactivated & 4) | |
531 sensorActive[2] = 0; | |
532 | |
533 write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]); | |
534 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); | |
535 write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]); | |
536 | |
537 text[0] = TXT_Fallback; | |
538 text[1] = 1; | |
539 write_field_on_off(StMHARD3_O2_Fallback, 30, 500, ME_Y_LINE5, &FontT48, text, settingsGetPointer()->fallbackToFixedSetpoint); | |
540 | |
541 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); | |
542 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2); | |
543 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3); | |
544 setEvent(StMHARD3_O2_Fallback, (uint32_t)OnAction_O2_Fallback); | |
545 | |
546 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
547 } | |
548 | |
549 | |
550 uint8_t OnAction_Sensor1(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
551 { | |
552 if(settingsGetPointer()->ppo2sensors_deactivated & 1) | |
553 { | |
554 settingsGetPointer()->ppo2sensors_deactivated &= 4+2; | |
555 tMenuEdit_set_on_off(editId, 1); | |
556 } | |
557 else | |
558 { | |
559 settingsGetPointer()->ppo2sensors_deactivated |= 1; | |
560 tMenuEdit_set_on_off(editId, 0); | |
561 } | |
562 | |
563 return UPDATE_DIVESETTINGS; | |
564 } | |
565 | |
566 | |
567 uint8_t OnAction_Sensor2(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
568 { | |
569 if(settingsGetPointer()->ppo2sensors_deactivated & 2) | |
570 { | |
571 settingsGetPointer()->ppo2sensors_deactivated &= 4+1; | |
572 tMenuEdit_set_on_off(editId, 1); | |
573 } | |
574 else | |
575 { | |
576 settingsGetPointer()->ppo2sensors_deactivated |= 2; | |
577 tMenuEdit_set_on_off(editId, 0); | |
578 } | |
579 | |
580 return UPDATE_DIVESETTINGS; | |
581 } | |
582 | |
583 | |
584 uint8_t OnAction_Sensor3(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
585 { | |
586 if(settingsGetPointer()->ppo2sensors_deactivated & 4) | |
587 { | |
588 settingsGetPointer()->ppo2sensors_deactivated &= 2+1; | |
589 tMenuEdit_set_on_off(editId, 1); | |
590 } | |
591 else | |
592 { | |
593 settingsGetPointer()->ppo2sensors_deactivated |= 4; | |
594 tMenuEdit_set_on_off(editId, 0); | |
595 } | |
596 | |
597 return UPDATE_DIVESETTINGS; | |
598 } | |
599 | |
600 | |
601 uint8_t OnAction_O2_Fallback (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
602 { | |
603 uint8_t fallback = settingsGetPointer()->fallbackToFixedSetpoint; | |
604 | |
605 if(fallback) | |
606 fallback = 0; | |
607 else | |
608 fallback = 1; | |
609 | |
610 settingsGetPointer()->fallbackToFixedSetpoint = fallback; | |
611 tMenuEdit_set_on_off(editId, fallback); | |
612 return UPDATE_DIVESETTINGS; | |
613 } | |
614 | |
615 | |
616 void openEdit_Brightness(void) | |
617 { | |
618 uint8_t actualBrightness; | |
619 SSettings *pSettings = settingsGetPointer(); | |
620 | |
621 actualBrightness = pSettings->brightness; | |
622 actualBrightness++; | |
623 if(actualBrightness > 4) | |
624 actualBrightness = 0; | |
625 pSettings->brightness = actualBrightness; | |
626 exitEditWithUpdate(); | |
627 } | |
628 | |
629 | |
630 void buttonBalanceText_helper(uint8_t idOfButton, char *textOutput) | |
631 { | |
632 uint8_t txtcount = 0; | |
633 | |
634 if(idOfButton < 3) | |
635 { | |
636 textOutput[txtcount++] = '@' + settingsGetPointer()->buttonBalance[idOfButton]; | |
637 textOutput[txtcount++] = ' '; | |
638 textOutput[txtcount++] = ' '; | |
639 textOutput[txtcount++] = '('; | |
640 | |
641 switch(settingsGetPointer()->buttonBalance[idOfButton]) | |
642 { | |
643 case 1: | |
644 textOutput[txtcount++] = '-'; | |
645 textOutput[txtcount++] = '2'; | |
646 textOutput[txtcount++] = '0'; | |
647 break; | |
648 case 2: | |
649 textOutput[txtcount++] = '-'; | |
650 textOutput[txtcount++] = '1'; | |
651 textOutput[txtcount++] = '0'; | |
652 break; | |
653 case 3: | |
654 default: | |
655 textOutput[txtcount++] = '0'; | |
656 break; | |
657 case 4: | |
658 textOutput[txtcount++] = '+'; | |
659 textOutput[txtcount++] = '1'; | |
660 textOutput[txtcount++] = '0'; | |
661 break; | |
662 case 5: | |
663 textOutput[txtcount++] = '+'; | |
664 textOutput[txtcount++] = '2'; | |
665 textOutput[txtcount++] = '0'; | |
666 break; | |
667 } | |
668 textOutput[txtcount++] = ')'; | |
669 } | |
670 textOutput[txtcount++] = 0; | |
671 } | |
672 | |
673 /**# | |
674 ****************************************************************************** | |
675 * @brief BUTTONS | |
676 * @author heinrichs weikamp gmbh | |
677 * @version V 01 | |
678 * @date 15-Sept-2016 | |
679 ****************************************************************************** | |
680 * Button 0 is right, Button 1 is middle, Button 2 is left !!!! | |
681 * 2 1 0 (base value 3) | |
682 * Button 3 is used to store the base value, all others are balanced around this one! | |
683 * | |
684 */ | |
685 | |
686 void openEdit_ButtonSens(void) | |
687 { | |
688 char text[32]; | |
689 uint8_t sens; | |
690 const uint32_t eventListButtonBalance[3] = {StMHARD5_ButtonBalance1,StMHARD5_ButtonBalance2,StMHARD5_ButtonBalance3}; | |
691 | |
692 sens = (uint8_t)settingsGetPointer()->ButtonResponsiveness[3]; | |
693 write_field_3digit(StMHARD5_Button1, 360, 780, ME_Y_LINE1, &FontT48, "###", sens, 0, 0, 0); | |
694 | |
695 for(int i=2;i>=0;i--) | |
696 { | |
697 buttonBalanceText_helper(i,text); | |
698 write_field_button(eventListButtonBalance[i],360,500,ME_Y_LINE4-(i*ME_Y_LINE_STEP),&FontT48,text); | |
699 } | |
700 | |
701 | |
702 setEvent(StMHARD5_Button1, (uint32_t)OnAction_Button); | |
703 | |
704 for(int i=2;i>=0;i--) | |
705 { | |
706 setEvent(eventListButtonBalance[i], (uint32_t)OnAction_ButtonBalance); | |
707 } | |
708 | |
709 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
710 } | |
711 | |
712 | |
713 void refresh_ButtonValuesFromPIC(void) | |
714 { | |
715 uint8_t sens[3]; | |
716 char text[64]; | |
717 | |
718 text[0] = '\001'; | |
719 text[1] = TXT_2BYTE; | |
720 text[2] = TXT2BYTE_ButtonSensitivity; | |
721 text[3] = 0; | |
722 write_topline(text); | |
723 | |
724 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
725 | |
726 text[0] = '\020'; // '\021'; | |
727 text[1] = TXT_2BYTE; | |
728 text[2] = TXT2BYTE_LowerIsLess; | |
729 text[3] = 0; | |
730 write_label_var( 20, 780, ME_Y_LINE5, &FontT42, text); | |
731 | |
732 for(int i=0;i<3;i++) | |
733 { | |
734 text[0] = TXT_2BYTE; | |
735 text[1] = TXT2BYTE_ButtonLeft+i; | |
736 text[2] = 0; | |
737 write_label_var( 20, 300, ME_Y_LINE2+(i*ME_Y_LINE_STEP), &FontT48, text); | |
738 } | |
739 | |
740 for(int i=0;i<3;i++) | |
741 { | |
742 sens[i] = settingsHelperButtonSens_translate_hwOS_values_to_percentage(stateRealGetPointer()->lifeData.buttonPICdata[i]); | |
743 } | |
744 snprintf(text,64,"(%03u %03u %03u)",sens[2],sens[1],sens[0]); | |
745 write_label_var( 20, 340, ME_Y_LINE6, &FontT42, text); | |
746 | |
747 tMenuEdit_refresh_field(StMHARD5_Button1); | |
748 tMenuEdit_refresh_field(StMHARD5_ButtonBalance1); | |
749 tMenuEdit_refresh_field(StMHARD5_ButtonBalance2); | |
750 tMenuEdit_refresh_field(StMHARD5_ButtonBalance3); | |
751 } | |
752 | |
753 | |
754 uint8_t OnAction_Button(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
755 { | |
756 uint8_t digitContentNew, remainder; | |
757 uint32_t newSensitivityGlobal; | |
758 | |
759 if(action == ACTION_BUTTON_NEXT) | |
760 { | |
761 digitContentNew = digitContent - '0'; | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
762 if(digitContentNew >= MAX_BUTTONRESPONSIVENESS_GUI) |
38 | 763 { |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
764 digitContentNew = MIN_BUTTONRESPONSIVENESS_GUI; |
38 | 765 } |
766 else | |
767 { | |
768 remainder = digitContentNew%5; | |
769 digitContentNew += 5 - remainder; | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
770 if(digitContentNew >= MAX_BUTTONRESPONSIVENESS_GUI) |
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
771 digitContentNew = MAX_BUTTONRESPONSIVENESS_GUI; |
38 | 772 } |
773 return '0' + digitContentNew; | |
774 } | |
775 | |
776 if(action == ACTION_BUTTON_BACK) | |
777 { | |
778 digitContentNew = digitContent - '0'; | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
779 if(digitContentNew <= MIN_BUTTONRESPONSIVENESS_GUI) |
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
38
diff
changeset
|
780 digitContentNew = MAX_BUTTONRESPONSIVENESS_GUI; |
38 | 781 else |
782 { | |
783 remainder = digitContentNew%5; | |
784 if(remainder) | |
785 digitContentNew -= remainder; | |
786 else | |
787 digitContentNew -= 5; | |
788 } | |
789 return '0' + digitContentNew; | |
790 } | |
791 | |
792 if(action == ACTION_BUTTON_ENTER_FINAL) | |
793 { | |
794 evaluateNewString(editId, &newSensitivityGlobal, 0, 0, 0); | |
795 settingsHelperButtonSens_keepPercentageValues(newSensitivityGlobal, settingsGetPointer()->ButtonResponsiveness); | |
796 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); | |
797 return UNSPECIFIC_RETURN; | |
798 } | |
799 return digitContent; | |
800 } | |
801 | |
802 | |
803 uint8_t OnAction_ButtonBalance(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
804 { | |
805 int8_t idBalance = -1; | |
806 uint8_t *ptrSetting; | |
807 char text[32]; | |
808 | |
809 const uint32_t eventListButtonBalance[3] = {StMHARD5_ButtonBalance1,StMHARD5_ButtonBalance2,StMHARD5_ButtonBalance3}; | |
810 | |
811 idBalance = -1; | |
812 for(int i=0;i<3;i++) | |
813 { | |
814 if(editId == eventListButtonBalance[i]) | |
815 { | |
816 idBalance = i; | |
817 break; | |
818 } | |
819 } | |
820 | |
821 if((idBalance >= 0) && (idBalance < 3)) | |
822 { | |
823 ptrSetting = &settingsGetPointer()->buttonBalance[idBalance]; | |
824 | |
825 *ptrSetting += 1; | |
826 | |
827 if(*ptrSetting > 5) | |
828 *ptrSetting = 2; | |
829 | |
830 buttonBalanceText_helper(idBalance,text); | |
831 tMenuEdit_newButtonText(eventListButtonBalance[idBalance],text); | |
832 } | |
833 | |
834 return UNSPECIFIC_RETURN; | |
835 } |