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