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