Mercurial > public > ostc4
annotate Discovery/Src/tMenuEdit.c @ 129:239aa58b533d FlipDisplay
Added function to initialise structures with the actual ambient pressure
author | Ideenmodellierer |
---|---|
date | Sun, 17 Feb 2019 21:14:09 +0100 |
parents | e6b190f5fbc7 |
children | cc9c18075e00 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuEdit.c | |
5 /// \brief Main Template file for Menu Setting Modifications | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 04-July-2014 | |
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 "tMenuEdit.h" | |
31 | |
32 #include "externLogbookFlash.h" | |
33 #include "gfx_fonts.h" | |
34 #include "tHome.h" | |
35 #include "tInfoCompass.h" | |
36 #include "tMenuEditHardware.h" | |
37 #include "tMenuEditPlanner.h" | |
38 #include "tMenuEditSystem.h" | |
39 #include "tMenuEditXtra.h" | |
40 | |
41 /* Private types -------------------------------------------------------------*/ | |
42 #define TEXTSIZE 16 | |
43 | |
44 typedef struct | |
45 { | |
46 uint32_t pEventFunction; | |
47 uint32_t callerID; | |
48 } SEventHandler; | |
49 | |
50 typedef struct | |
51 { | |
52 uint32_t pEventFunction; | |
53 uint8_t functionParameter; | |
54 uint8_t line; | |
55 } SBackMenuHandler; | |
56 | |
57 typedef struct | |
58 { | |
59 char orgText[32]; | |
60 char newText[32]; | |
61 uint16_t input[4]; | |
62 uint16_t coord[3]; | |
63 int8_t begin[4], size[4]; | |
64 tFont *fontUsed; | |
65 uint32_t callerID; | |
66 uint8_t maintype; | |
67 uint8_t subtype; | |
68 } SEditIdent; | |
69 | |
70 typedef enum | |
71 { | |
72 FIELD_NUMBERS = 0, | |
73 FIELD_BUTTON, | |
74 FIELD_SELECT, | |
75 FIELD_SYMBOL, | |
76 FIELD_TOGGLE, | |
77 FIELD_ON_OFF, | |
78 FIELD_UDIGIT, | |
79 FIELD_2DIGIT, | |
80 FIELD_3DIGIT, | |
81 FIELD_FLOAT, | |
82 FIELD_END | |
83 } SField; | |
84 | |
85 /* Private variables ---------------------------------------------------------*/ | |
86 GFX_DrawCfgScreen tMEscreen; | |
87 GFX_DrawCfgScreen tMEcursor; | |
88 GFX_DrawCfgScreen tMEcursorNew; | |
89 | |
90 uint32_t menuID; | |
91 uint8_t menuColor; | |
92 | |
93 int8_t id = 0; | |
94 int8_t idLast = -1; | |
95 SEditIdent ident[10]; | |
96 int8_t tME_stop = 0; | |
97 | |
98 int8_t evid = 0; | |
99 int8_t evidLast = -1; | |
100 SEventHandler event[10]; | |
101 | |
102 SBackMenuHandler backmenu; | |
103 | |
104 int8_t block = 0; | |
105 int8_t subBlockPosition = 0; | |
106 | |
107 _Bool EnterPressedBeforeButtonAction = 0; | |
108 _Bool EnterPressed = 0; | |
109 | |
110 _Bool WriteSettings = 0; | |
111 | |
112 /* Private function prototypes -----------------------------------------------*/ | |
113 void draw_tMEdesign(void); | |
114 void set_cursor(uint8_t forThisIdentID); | |
115 void set_cursorNew(uint8_t forThisIdentID); | |
116 void startMenuEditFieldSelect(void); | |
117 void create_newText_for_actual_Id(void); | |
118 void write_content_of_actual_Id(void); | |
119 void clean_content_of_actual_Id(void); | |
120 void write_content_without_Id(void); | |
121 | |
122 void nextMenuEditFieldDigit(void); | |
123 void upMenuEditFieldDigit(void); | |
124 void downMenuEditFieldDigit(void); | |
125 | |
126 void draw_tMEcursorNewDesign(void); | |
127 | |
128 void exitMenuEdit(uint8_t writeSettingsIfEnterPressed); | |
129 uint8_t split_Content_to_Digit_helper(uint8_t inContentAscii, uint8_t *outDigit100, uint8_t *outDigit10, uint8_t *outDigit1); | |
130 | |
131 /* Exported functions --------------------------------------------------------*/ | |
132 | |
133 void tMenuEdit_init(void) | |
134 { | |
135 tMEcursor.FBStartAdress = getFrame(7); | |
136 tMEcursor.ImageHeight = 480; | |
137 tMEcursor.ImageWidth = 800; | |
138 tMEcursor.LayerIndex = 0; | |
139 | |
140 GFX_fill_buffer(tMEcursor.FBStartAdress, 0xFF, CLUT_MenuEditCursor); | |
141 | |
142 tMEcursorNew.FBStartAdress = getFrame(8); | |
143 tMEcursorNew.ImageHeight = 390; | |
144 tMEcursorNew.ImageWidth = 800; | |
145 tMEcursorNew.LayerIndex = 0; | |
146 | |
147 draw_tMEcursorNewDesign(); | |
148 } | |
149 | |
150 void stop_cursor_fields(void) | |
151 { | |
152 tME_stop = 1; | |
153 } | |
154 | |
155 void resetMenuEdit(uint8_t color) | |
156 { | |
157 id = 0; | |
158 idLast = -1; | |
159 evid = 0; | |
160 evidLast = -1; | |
161 tME_stop = 0; | |
162 EnterPressed = 0; | |
163 EnterPressedBeforeButtonAction = 0; | |
164 | |
165 setBackMenu(0,0,0); | |
166 | |
167 releaseFrame(9,tMEscreen.FBStartAdress); | |
168 | |
169 tMEscreen.FBStartAdress = getFrame(9); | |
170 tMEscreen.ImageHeight = 480; | |
171 tMEscreen.ImageWidth = 800; | |
172 tMEscreen.LayerIndex = 1; | |
173 | |
174 /* | |
175 write_content_simple(&tMEscreen, 0, 38, 0, &Awe48,"x",CLUT_ButtonSymbols); | |
176 write_content_simple(&tMEscreen, 800-46, 800, 0, &Awe48,"u",CLUT_ButtonSymbols); | |
177 write_content_simple(&tMEscreen, 0, 45, 480-45, &Awe48,"d",CLUT_ButtonSymbols); | |
178 write_content_simple(&tMEscreen, 800-48, 800, 480-45, &Awe48,"e",CLUT_ButtonSymbols); | |
179 */ | |
180 menuID = get_globalState(); | |
181 | |
182 menuColor = color; | |
183 | |
184 // draw_tMEdesign(); | |
185 // GFX_SetFramesTopBottom(tMEscreen.FBStartAdress, tMEcursor.FBStartAdress,480); | |
186 uint8_t line = 1; | |
187 // GFX_SetFramesTopBottom(tMEscreen.FBStartAdress, (tMEcursorNew.FBStartAdress) + 65*2*(line - 1),390); | |
188 GFX_SetFrameTop(tMEscreen.FBStartAdress); | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
189 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
190 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
191 GFX_SetFrameBottom((tMEcursorNew.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
192 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
193 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
194 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
195 GFX_SetFrameBottom((tMEcursorNew.FBStartAdress)+ (390 - 65 *(line)) *2, 0, 480-390-25, 800, 390); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
196 } |
38 | 197 } |
198 | |
199 | |
200 void tMenuEdit_refresh_live_content(void) | |
201 { | |
202 | |
203 if(get_globalState() == (StMHARD3_O2_Sensor1 & MaskFieldDigit)) | |
204 { | |
205 uint32_t rememberPage = tMEscreen.FBStartAdress; | |
206 tMEscreen.FBStartAdress = getFrame(9); | |
207 // draw_tMEdesign(); | |
208 refresh_O2Sensors(); | |
209 GFX_SetFrameTop(tMEscreen.FBStartAdress); | |
210 releaseFrame(9,rememberPage); | |
211 } | |
212 else if(get_globalState() == (StMHARD2_Compass_SetCourse & MaskFieldDigit)) | |
213 { | |
214 uint32_t rememberPage = tMEscreen.FBStartAdress; | |
215 tMEscreen.FBStartAdress = getFrame(9); | |
216 refresh_CompassEdit(); | |
217 GFX_SetFrameTop(tMEscreen.FBStartAdress); | |
218 releaseFrame(9,rememberPage); | |
219 } | |
220 else if(get_globalState() == (StMXTRA_CompassHeading & MaskFieldDigit)) | |
221 { | |
222 uint32_t rememberPage = tMEscreen.FBStartAdress; | |
223 tMEscreen.FBStartAdress = getFrame(9); | |
224 // draw_tMEdesign(); | |
225 refresh_CompassHeading(); | |
226 GFX_SetFrameTop(tMEscreen.FBStartAdress); | |
227 releaseFrame(9,rememberPage); | |
228 } | |
229 else if(get_globalState() == (StMSYS5_Info & MaskFieldDigit)) | |
230 { | |
231 uint32_t rememberPage = tMEscreen.FBStartAdress; | |
232 tMEscreen.FBStartAdress = getFrame(9); | |
233 refresh_InformationPage(); | |
234 GFX_SetFrameTop(tMEscreen.FBStartAdress); | |
235 releaseFrame(9,rememberPage); | |
236 } | |
237 else if(get_globalState() == (StMPLAN5_ExitResult & MaskFieldDigit)) | |
238 { | |
239 uint32_t rememberPage = tMEscreen.FBStartAdress; | |
240 tMEscreen.FBStartAdress = getFrame(9); | |
241 refresh_PlanResult(); | |
242 GFX_SetFrameTop(tMEscreen.FBStartAdress); | |
243 releaseFrame(9,rememberPage); | |
244 } | |
245 else if(get_globalState() == (StMHARD5_Button1 & MaskFieldDigit)) // will not be executed in EditFieldMode as global state is different | |
246 { | |
247 uint32_t rememberPage = tMEscreen.FBStartAdress; | |
248 tMEscreen.FBStartAdress = getFrame(9); | |
249 refresh_ButtonValuesFromPIC(); | |
250 GFX_SetFrameTop(tMEscreen.FBStartAdress); | |
251 releaseFrame(9,rememberPage); | |
252 } | |
253 /* | |
254 else if(get_globalState() == (StMHARD6_ScooterDrag & MaskFieldDigit)) | |
255 { | |
256 uint32_t rememberPage = tMEscreen.FBStartAdress; | |
257 tMEscreen.FBStartAdress = getFrame(9); | |
258 refresh_ScooterControl(); | |
259 GFX_SetFrameTop(tMEscreen.FBStartAdress); | |
260 releaseFrame(9,rememberPage); | |
261 } | |
262 */ | |
263 else if(get_globalState() == (StMSYS3_Units & MaskFieldDigit)) | |
264 { | |
265 uint32_t rememberPage = tMEscreen.FBStartAdress; | |
266 tMEscreen.FBStartAdress = getFrame(9); | |
267 refresh_Design(); | |
268 GFX_SetFrameTop(tMEscreen.FBStartAdress); | |
269 releaseFrame(9,rememberPage); | |
270 } | |
271 else if(get_globalState() == (StMSYS4_CViewTimeout & MaskFieldDigit)) | |
272 { | |
273 uint32_t rememberPage = tMEscreen.FBStartAdress; | |
274 tMEscreen.FBStartAdress = getFrame(9); | |
275 refresh_Customviews(); | |
276 GFX_SetFrameTop(tMEscreen.FBStartAdress); | |
277 releaseFrame(9,rememberPage); | |
278 } | |
279 } | |
280 | |
281 void tMenuEdit_writeSettingsToFlash(void) | |
282 { | |
283 if(WriteSettings) | |
284 { | |
285 GFX_logoAutoOff(); | |
286 ext_flash_write_settings(); | |
287 WriteSettings = 0; | |
288 } | |
289 } | |
290 | |
291 void helperLeaveMenuEditField(uint8_t idID) | |
292 { | |
293 if(ident[idID].maintype == FIELD_NUMBERS) | |
294 { | |
295 change_CLUT_entry((CLUT_MenuEditField0 + idID), CLUT_MenuEditFieldRegular); | |
296 } | |
297 } | |
298 | |
299 | |
300 void helperGotoMenuEditField(uint8_t idID) | |
301 { | |
302 /* | |
303 if(ident[idID].maintype == FIELD_NUMBERS) | |
304 { | |
305 change_CLUT_entry((CLUT_MenuEditField0 + idID), CLUT_MenuEditFieldSelected); | |
306 } | |
307 */ | |
308 set_cursorNew(idID); | |
309 // set_cursor(idID); | |
310 } | |
311 | |
312 | |
313 void exitMenuEdit_to_BackMenu(void) | |
314 { | |
315 _Bool EnterPressedBackup = EnterPressed; | |
316 | |
317 if(backmenu.pEventFunction) | |
318 { | |
319 ((void (*)(uint8_t))(backmenu.pEventFunction))(backmenu.functionParameter); | |
320 | |
321 EnterPressed = EnterPressedBackup; | |
322 // if(backmenu.line > 1) | |
323 // helperGotoMenuEditField(backmenu.line); | |
324 } | |
325 } | |
326 | |
327 | |
328 void exitMenuEdit_to_Menu_with_Menu_Update(void) | |
329 { | |
330 EnterPressed = 1; | |
331 exitMenuEdit(1); | |
332 } | |
333 | |
334 | |
335 void exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only(void) | |
336 { | |
337 EnterPressed = 1; | |
338 exitMenuEdit(0); | |
339 } | |
340 | |
341 | |
342 void exitMenuEdit_to_Home_with_Menu_Update(void) | |
343 { | |
344 EnterPressed = 1; | |
345 exitMenuEdit(1); | |
346 set_globalState_tHome(); | |
347 } | |
348 | |
349 | |
350 void exitMenuEdit_to_InfoCompassCalibration(void) | |
351 { | |
352 exitMenuEdit(1); | |
353 openInfo_Compass(); | |
354 } | |
355 | |
356 | |
357 void exitMenuEdit_to_Home(void) | |
358 { | |
359 exitMenuEdit(1); | |
360 set_globalState_tHome(); | |
361 } | |
362 | |
363 | |
364 void exitMenuEdit(uint8_t writeSettingsIfEnterPressed) | |
365 { | |
366 openMenu(0); | |
367 if(EnterPressed) | |
368 { | |
369 updateMenu(); | |
370 if((stateUsed->mode == MODE_SURFACE) && writeSettingsIfEnterPressed) | |
371 WriteSettings = 1; | |
372 } | |
373 releaseFrame(9,tMEscreen.FBStartAdress); | |
374 } | |
375 | |
376 | |
377 void exitMenuEditBackMenuOption(void) | |
378 { | |
379 if(backmenu.pEventFunction == 0) | |
380 exitMenuEdit(1); | |
381 else | |
382 exitMenuEdit_to_BackMenu(); | |
383 } | |
384 | |
385 | |
386 void startMenuEditFieldSelect(void) | |
387 { | |
388 id = 0; | |
389 helperGotoMenuEditField(id); | |
390 } | |
391 | |
392 | |
393 void nextMenuEditField(void) | |
394 { | |
395 helperLeaveMenuEditField(id); | |
396 | |
397 if(id < idLast) | |
398 id++; | |
399 else | |
400 id = 0; | |
401 helperGotoMenuEditField(id); | |
402 } | |
403 | |
404 /* | |
405 void previousMenuEditField(void) | |
406 { | |
407 helperLeaveMenuEditField(id); | |
408 if(id > 0) | |
409 id--; | |
410 else | |
411 id = idLast; | |
412 helperGotoMenuEditField(id); | |
413 } | |
414 */ | |
415 | |
416 _Bool inc_subBlock_or_block_of_actual_id(void) | |
417 { | |
418 if(event[evid].callerID != ident[id].callerID) | |
419 return 0; | |
420 | |
421 if((ident[id].subtype != FIELD_3DIGIT) && (ident[id].subtype != FIELD_2DIGIT) && ((subBlockPosition + 1) < ident[id].size[block])) | |
422 { | |
423 subBlockPosition++; | |
424 return 1; | |
425 } | |
426 | |
427 if(((block + 1) < 4) && (ident[id].size[block+1] > 0)) | |
428 { | |
429 block++; | |
430 subBlockPosition = 0; | |
431 return 1; | |
432 } | |
433 | |
434 return 0; | |
435 } | |
436 | |
437 | |
438 uint8_t get_newContent_of_actual_id_block_and_subBlock(uint8_t action) | |
439 { | |
440 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); | |
441 uint8_t content; | |
442 | |
443 if(event[evid].callerID != ident[id].callerID) | |
444 return 0; | |
445 | |
446 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(event[evid].pEventFunction); | |
447 | |
448 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT)) | |
449 { | |
450 content = 100 * ( ident[id].newText[ident[id].begin[block] + 0] - '0'); | |
451 content += 10 * ( ident[id].newText[ident[id].begin[block] + 1] - '0'); | |
452 content += ident[id].newText[ident[id].begin[block] + 2]; | |
453 } | |
454 else | |
455 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT)) | |
456 { | |
457 content = 10 * (ident[id].newText[ident[id].begin[block] + 0] - '0'); | |
458 content += ident[id].newText[ident[id].begin[block] + 1]; | |
459 } | |
460 else | |
461 if(ident[id].maintype == FIELD_NUMBERS) | |
462 content = ident[id].newText[ident[id].begin[block] + subBlockPosition]; | |
463 else | |
464 if(ident[id].maintype == FIELD_ON_OFF) | |
465 content = ident[id].input[block]; | |
466 else | |
467 content = 0; /* just a default for protection */ | |
468 | |
469 return onActionFunc(ident[id].callerID, block, subBlockPosition, content, action); | |
470 } | |
471 | |
472 void mark_digit_of_actual_id_with_this_block_and_subBlock(int8_t oldblock, int8_t oldsubblockpos) | |
473 { | |
474 char oneCharText[2]; | |
475 uint16_t positionOffset; | |
476 | |
477 if(event[evid].callerID != ident[id].callerID) | |
478 return; | |
479 | |
480 if(ident[id].maintype == FIELD_NUMBERS) | |
481 { | |
482 oneCharText[0] = ident[id].newText[ident[id].begin[oldblock] + oldsubblockpos]; | |
483 oneCharText[1] = 0; | |
484 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[oldblock] + oldsubblockpos); | |
485 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditFieldSelected); | |
486 } | |
487 } | |
488 | |
489 | |
490 void mark_new_2digit_of_actual_id_block(void) | |
491 { | |
492 char oneCharText[3]; | |
493 uint16_t positionOffset; | |
494 | |
495 if(event[evid].callerID != ident[id].callerID) | |
496 return; | |
497 | |
498 if(ident[id].maintype == FIELD_NUMBERS) | |
499 { | |
500 oneCharText[0] = ident[id].newText[ident[id].begin[block] + 0]; | |
501 oneCharText[1] = ident[id].newText[ident[id].begin[block] + 1]; | |
502 oneCharText[2] = 0; | |
503 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + 0); | |
504 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); | |
505 } | |
506 } | |
507 | |
508 | |
509 void mark_new_3digit_of_actual_id_block(void) | |
510 { | |
511 char oneCharText[4]; | |
512 uint16_t positionOffset; | |
513 | |
514 if(event[evid].callerID != ident[id].callerID) | |
515 return; | |
516 | |
517 if(ident[id].maintype == FIELD_NUMBERS) | |
518 { | |
519 oneCharText[0] = ident[id].newText[ident[id].begin[block] + 0]; | |
520 oneCharText[1] = ident[id].newText[ident[id].begin[block] + 1]; | |
521 oneCharText[2] = ident[id].newText[ident[id].begin[block] + 2]; | |
522 oneCharText[3] = 0; | |
523 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + 0); | |
524 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); | |
525 } | |
526 } | |
527 | |
528 | |
529 void mark_new_digit_of_actual_id_block_and_subBlock(void) | |
530 { | |
531 char oneCharText[2]; | |
532 uint16_t positionOffset; | |
533 | |
534 if(event[evid].callerID != ident[id].callerID) | |
535 return; | |
536 | |
537 if(ident[id].maintype == FIELD_NUMBERS) | |
538 { | |
539 oneCharText[0] = ident[id].newText[ident[id].begin[block] + subBlockPosition]; | |
540 oneCharText[1] = 0; | |
541 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + subBlockPosition); | |
542 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); | |
543 } | |
544 } | |
545 | |
546 | |
547 void enterMenuEditField(void) | |
548 { | |
549 uint8_t newContent; | |
550 uint8_t digit100; | |
551 uint8_t digit10; | |
552 uint8_t digit1; | |
553 | |
554 evid = 0; | |
555 while((evid < evidLast) && (event[evid].callerID != ident[id].callerID)) | |
556 { | |
557 evid++; | |
558 } | |
559 | |
560 if(event[evid].callerID != ident[id].callerID) | |
561 return; | |
562 | |
563 set_globalState(event[evid].callerID); | |
564 block = 0; | |
565 subBlockPosition = 0; | |
566 | |
567 | |
568 if(ident[id].maintype == FIELD_NUMBERS) | |
569 { | |
570 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); | |
571 // old stuff? hw 150916, reactivated 150923, this shows which digit will be changed now as it marks the other grey/black | |
572 // now fixed for button settings with newContent <= '0'+99 condition | |
573 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldSelected); | |
574 } | |
575 | |
576 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_ENTER); | |
577 | |
578 if (((newContent == UPDATE_DIVESETTINGS) || (newContent == UPDATE_AND_EXIT_TO_HOME) || (newContent == UPDATE_AND_EXIT_TO_MENU)) && (actual_menu_content == MENU_SURFACE)) | |
579 createDiveSettings(); | |
580 | |
581 if(newContent == EXIT_TO_MENU_WITH_LOGO) | |
582 { | |
583 GFX_logoAutoOff(); | |
584 } | |
585 | |
586 if((newContent == EXIT_TO_MENU) || (newContent == UPDATE_AND_EXIT_TO_MENU) || (newContent == EXIT_TO_MENU_WITH_LOGO)) | |
587 { | |
588 if(backmenu.pEventFunction == 0) | |
589 exitMenuEdit(1); | |
590 else | |
591 exitMenuEdit_to_BackMenu(); | |
592 return; | |
593 } | |
594 | |
595 if((newContent == EXIT_TO_HOME) || (newContent == UPDATE_AND_EXIT_TO_HOME)) | |
596 { | |
597 exitMenuEdit_to_Home(); | |
598 return; | |
599 } | |
600 | |
601 if(newContent == EXIT_TO_INFO_COMPASS) | |
602 { | |
603 exitMenuEdit_to_InfoCompassCalibration(); | |
604 return; | |
605 } | |
606 | |
607 | |
608 switch(ident[id].maintype) | |
609 { | |
610 case FIELD_NUMBERS: | |
611 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); | |
612 | |
613 if(ident[id].subtype == FIELD_UDIGIT) | |
614 { | |
615 if((newContent >= '0') && (newContent <= '9')) | |
616 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | |
617 | |
618 mark_new_digit_of_actual_id_block_and_subBlock(); | |
619 } | |
620 else if(ident[id].subtype == FIELD_3DIGIT) | |
621 { | |
622 if((newContent >= '0') && (newContent <= '0'+200)) | |
623 { | |
624 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); | |
625 ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; | |
626 ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; | |
627 ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; | |
628 mark_new_3digit_of_actual_id_block(); | |
629 } | |
630 } | |
631 else // FIELD_2DIGIT | |
632 { | |
633 if((newContent >= '0') && (newContent <= '0'+99)) | |
634 { | |
635 ident[id].newText[ident[id].begin[block]] = '0' + (newContent - '0')/10; | |
636 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | |
637 mark_new_2digit_of_actual_id_block(); | |
638 } | |
639 } | |
640 break; | |
641 case FIELD_BUTTON: | |
642 set_globalState(menuID); | |
643 break; | |
644 case FIELD_ON_OFF: | |
645 set_globalState(menuID); | |
646 break; | |
647 case FIELD_SYMBOL: | |
648 ident[id].input[0] += 1; | |
649 if(ident[id].input[0] >= ident[id].input[1]) | |
650 ident[id].input[0] = 0; | |
651 ident[id].newText[0] = ident[id].orgText[ident[id].input[0]]; | |
652 write_content_of_actual_Id(); | |
653 set_globalState(menuID); | |
654 break; | |
655 } | |
656 } | |
657 | |
658 | |
659 void exitMenuEditField(void) | |
660 { | |
661 uint8_t newContent; | |
662 | |
663 set_globalState(menuID); | |
664 | |
665 if(event[evid].callerID != ident[id].callerID) | |
666 return; | |
667 | |
668 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_TIMEOUT); | |
669 | |
670 /* | |
671 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); | |
672 uint8_t newContent; | |
673 | |
674 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(event[evid].pEventFunction); | |
675 | |
676 newContent = onActionFunc(ident[id].callerID, 0, 0, 255, ACTION_BUTTON_BACK); | |
677 */ | |
678 | |
679 /* destroy changes of editing in newText */ | |
680 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuLineSelected); | |
681 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
682 | |
683 create_newText_for_actual_Id(); | |
684 write_content_of_actual_Id(); | |
685 | |
686 if((newContent == EXIT_TO_MENU) || (newContent == UPDATE_AND_EXIT_TO_MENU)) | |
687 { | |
688 exitMenuEdit(1); | |
689 return; | |
690 } | |
691 | |
692 if((newContent == EXIT_TO_HOME) || (newContent == UPDATE_AND_EXIT_TO_HOME)) | |
693 { | |
694 exitMenuEdit_to_Home(); | |
695 return; | |
696 } | |
697 | |
698 } | |
699 | |
700 void nextMenuEditFieldDigit(void) | |
701 { | |
702 uint8_t action; | |
703 uint8_t newContent; | |
704 int8_t blockOld = 0; | |
705 int8_t subBlockPositionOld = 0; | |
706 | |
707 if(event[evid].callerID != ident[id].callerID) | |
708 return; | |
709 | |
710 blockOld = block; | |
711 subBlockPositionOld = subBlockPosition; | |
712 | |
713 if(inc_subBlock_or_block_of_actual_id()) | |
714 action = ACTION_BUTTON_ENTER; | |
715 else | |
716 action = ACTION_BUTTON_ENTER_FINAL; | |
717 | |
718 newContent = get_newContent_of_actual_id_block_and_subBlock(action); | |
719 | |
720 if(action == ACTION_BUTTON_ENTER_FINAL) | |
721 { | |
722 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
723 | |
724 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuLineSelected); | |
725 for(int i = 0;i<=9;i++) | |
726 change_CLUT_entry((CLUT_MenuEditField0 + i), CLUT_MenuEditFieldRegular); | |
727 | |
728 if(((newContent == UPDATE_DIVESETTINGS) || (newContent == UPDATE_AND_EXIT_TO_HOME) || (newContent == UPDATE_AND_EXIT_TO_MENU)) && (actual_menu_content == MENU_SURFACE)) | |
729 createDiveSettings(); | |
730 | |
731 if((newContent == EXIT_TO_MENU) || (newContent == UPDATE_AND_EXIT_TO_MENU)) | |
732 { | |
733 exitMenuEdit(1); | |
734 return; | |
735 } | |
736 | |
737 if((newContent == EXIT_TO_HOME) || (newContent == UPDATE_AND_EXIT_TO_HOME)) | |
738 { | |
739 exitMenuEdit_to_Home(); | |
740 return; | |
741 } | |
742 } | |
743 | |
744 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) | |
745 { | |
746 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/100; | |
747 ident[id].newText[ident[id].begin[block] + 1] = '0' + (newContent - '0')/10; | |
748 ident[id].newText[ident[id].begin[block] + 2] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | |
749 } | |
750 else | |
751 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) | |
752 { | |
753 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; | |
754 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | |
755 } | |
756 else | |
757 if((ident[id].maintype == FIELD_NUMBERS) && (action == ACTION_BUTTON_ENTER) && (newContent >= '0') && (newContent <= '9')) | |
758 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | |
759 | |
760 if(action == ACTION_BUTTON_ENTER) | |
761 { | |
762 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT)) | |
763 { | |
764 mark_new_3digit_of_actual_id_block(); | |
765 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0); | |
766 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,1); | |
767 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,2); | |
768 } | |
769 else | |
770 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT)) | |
771 { | |
772 mark_new_2digit_of_actual_id_block(); | |
773 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0); | |
774 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,1); | |
775 } | |
776 else | |
777 { | |
778 mark_new_digit_of_actual_id_block_and_subBlock(); | |
779 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,subBlockPositionOld); | |
780 } | |
781 } | |
782 else /* action == ACTION_BUTTON_ENTER_FINAL */ | |
783 set_globalState(menuID); | |
784 } | |
785 | |
786 uint8_t split_Content_to_Digit_helper(uint8_t inContentAscii, uint8_t *outDigit100, uint8_t *outDigit10, uint8_t *outDigit1) | |
787 { | |
788 uint8_t newContent, tempDigit, CopyContent; | |
789 | |
790 newContent = inContentAscii - '0'; | |
791 CopyContent = newContent; | |
792 | |
793 tempDigit = newContent / 100; | |
794 newContent -= tempDigit * 100; | |
795 if(outDigit100) | |
796 *outDigit100 = tempDigit; | |
797 | |
798 tempDigit = newContent / 10; | |
799 newContent -= tempDigit * 10; | |
800 if(outDigit10) | |
801 *outDigit10 = tempDigit; | |
802 | |
803 tempDigit = newContent; | |
804 if(outDigit1) | |
805 *outDigit1 = tempDigit; | |
806 | |
807 return CopyContent; | |
808 } | |
809 | |
810 void upMenuEditFieldDigit(void) | |
811 { | |
812 uint8_t newContent; | |
813 uint8_t digit100; | |
814 uint8_t digit10; | |
815 uint8_t digit1; | |
816 | |
817 if(event[evid].callerID != ident[id].callerID) | |
818 return; | |
819 | |
820 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_NEXT); | |
821 | |
822 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) | |
823 { | |
824 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); | |
825 ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; | |
826 ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; | |
827 ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; | |
828 mark_new_3digit_of_actual_id_block(); | |
829 return; | |
830 } | |
831 | |
832 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) | |
833 { | |
834 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; | |
835 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | |
836 mark_new_2digit_of_actual_id_block(); | |
837 return; | |
838 } | |
839 | |
840 if((ident[id].maintype == FIELD_NUMBERS) && (newContent >= '0') && (newContent <= '9')) | |
841 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | |
842 | |
843 mark_new_digit_of_actual_id_block_and_subBlock(); | |
844 } | |
845 | |
846 | |
847 void downMenuEditFieldDigit(void) | |
848 { | |
849 uint8_t newContent; | |
850 uint8_t digit100; | |
851 uint8_t digit10; | |
852 uint8_t digit1; | |
853 | |
854 if(event[evid].callerID != ident[id].callerID) | |
855 return; | |
856 | |
857 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_BACK); | |
858 | |
859 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) | |
860 { | |
861 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); | |
862 ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; | |
863 ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; | |
864 ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; | |
865 mark_new_3digit_of_actual_id_block(); | |
866 return; | |
867 } | |
868 | |
869 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) | |
870 { | |
871 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; | |
872 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | |
873 mark_new_2digit_of_actual_id_block(); | |
874 return; | |
875 } | |
876 | |
877 if((ident[id].maintype == FIELD_NUMBERS) && (newContent >= '0') && (newContent <= '9')) | |
878 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | |
879 | |
880 mark_new_digit_of_actual_id_block_and_subBlock(); | |
881 } | |
882 | |
883 | |
884 void evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4) | |
885 { | |
886 if(editID != ident[id].callerID) | |
887 return; | |
888 | |
889 uint8_t i, digitCount, digit; | |
890 uint32_t sum[4], multiplier; | |
891 | |
892 for(i=0;i<4;i++) | |
893 sum[i] = 0; | |
894 | |
895 i = 0; | |
896 while( ident[id].size[i] && (i < 4)) | |
897 { | |
898 multiplier = 1; | |
899 for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++) | |
900 multiplier *= 10; | |
901 | |
902 for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++) | |
903 { | |
904 digit = ident[id].newText[ident[id].begin[i] + digitCount]; | |
905 | |
906 if(digit > '0') | |
907 digit -= '0'; | |
908 else | |
909 digit = 0; | |
910 | |
911 if(digit > 9) | |
912 digit = 9; | |
913 | |
914 sum[i] += digit * multiplier; | |
915 | |
916 if(multiplier >= 10) | |
917 multiplier /= 10; | |
918 else | |
919 multiplier = 0; | |
920 } | |
921 i++; | |
922 } | |
923 | |
924 *pNewValue1 = sum[0]; | |
925 *pNewValue2 = sum[1]; | |
926 *pNewValue3 = sum[2]; | |
927 *pNewValue4 = sum[3]; | |
928 } | |
929 | |
930 | |
931 uint8_t get_id_of(uint32_t editID) | |
932 { | |
933 uint8_t temp_id; | |
934 | |
935 if(editID == ident[id].callerID) | |
936 return id; | |
937 else | |
938 { | |
939 temp_id = 0; | |
940 while((temp_id < 9) && (editID != ident[temp_id].callerID)) | |
941 temp_id++; | |
942 if(editID != ident[temp_id].callerID) | |
943 temp_id = 255; | |
944 return temp_id; | |
945 } | |
946 } | |
947 | |
948 | |
949 void tMenuEdit_newButtonText(uint32_t editID, char *text) | |
950 { | |
951 uint8_t backup_id, temp_id; | |
952 | |
953 temp_id = get_id_of(editID); | |
954 if(temp_id == 255) | |
955 return; | |
956 | |
957 backup_id = id; | |
958 id = temp_id; | |
959 | |
960 strncpy(ident[id].newText, text, 32); | |
961 ident[id].newText[31] = 0; | |
962 | |
963 clean_content_of_actual_Id(); | |
964 write_content_of_actual_Id(); | |
965 | |
966 id = backup_id; | |
967 } | |
968 | |
969 | |
970 void tMenuEdit_set_on_off(uint32_t editID, uint32_t int1) | |
971 { | |
972 uint8_t backup_id, temp_id; | |
973 | |
974 temp_id = get_id_of(editID); | |
975 if(temp_id == 255) | |
976 return; | |
977 | |
978 backup_id = id; | |
979 id = temp_id; | |
980 | |
981 ident[id].input[0] = int1; | |
982 | |
983 if(int1) | |
984 ident[id].newText[0] = '\005'; | |
985 else | |
986 ident[id].newText[0] = '\006'; | |
987 | |
988 clean_content_of_actual_Id(); | |
989 write_content_of_actual_Id(); | |
990 | |
991 id = backup_id; | |
992 } | |
993 | |
994 | |
995 void tMenuEdit_select(uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) | |
996 { | |
997 if(int1 > 4) | |
998 return; | |
999 | |
1000 uint8_t backup_id, temp_id; | |
1001 | |
1002 temp_id = get_id_of(editID); | |
1003 if(temp_id == 255) | |
1004 return; | |
1005 | |
1006 backup_id = id; | |
1007 id = temp_id; | |
1008 | |
1009 ident[id].input[0] = int1; | |
1010 ident[id].input[1] = int1; | |
1011 ident[id].input[2] = int1; | |
1012 ident[id].input[3] = int1; | |
1013 | |
1014 create_newText_for_actual_Id(); | |
1015 clean_content_of_actual_Id(); | |
1016 write_content_of_actual_Id(); | |
1017 | |
1018 id = backup_id; | |
1019 } | |
1020 | |
1021 | |
1022 void tMenuEdit_newInput(uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) | |
1023 { | |
1024 uint8_t backup_id, temp_id; | |
1025 | |
1026 temp_id = get_id_of(editID); | |
1027 if(temp_id == 255) | |
1028 return; | |
1029 | |
1030 backup_id = id; | |
1031 id = temp_id; | |
1032 | |
1033 if(editID != ident[id].callerID) | |
1034 { | |
1035 temp_id = 0; | |
1036 while((temp_id < 9) && (editID != ident[temp_id].callerID)) | |
1037 temp_id++; | |
1038 if(editID != ident[temp_id].callerID) | |
1039 return; | |
1040 id = temp_id; | |
1041 } | |
1042 ident[id].input[0] = int1; | |
1043 ident[id].input[1] = int2; | |
1044 ident[id].input[2] = int3; | |
1045 ident[id].input[3] = int4; | |
1046 | |
1047 create_newText_for_actual_Id(); | |
1048 if(id <= idLast) | |
1049 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1050 write_content_of_actual_Id(); | |
1051 | |
1052 id = backup_id; | |
1053 } | |
1054 | |
1055 | |
1056 void resetEnterPressedToStateBeforeButtonAction(void) | |
1057 { | |
1058 EnterPressed = EnterPressedBeforeButtonAction; | |
1059 } | |
1060 | |
1061 | |
1062 void sendActionToMenuEdit(uint8_t sendAction) | |
1063 { | |
1064 if(get_globalState() == menuID) | |
1065 { | |
1066 switch(sendAction) | |
1067 { | |
1068 case ACTION_BUTTON_ENTER: | |
1069 EnterPressedBeforeButtonAction = EnterPressed; | |
1070 EnterPressed = 1; | |
1071 enterMenuEditField(); | |
1072 break; | |
1073 case ACTION_BUTTON_NEXT: | |
1074 nextMenuEditField(); | |
1075 // previousMenuEditField(); | |
1076 break; | |
1077 case ACTION_BUTTON_BACK: | |
1078 exitMenuEditBackMenuOption(); | |
1079 break; | |
1080 case ACTION_TIMEOUT: | |
1081 case ACTION_MODE_CHANGE: | |
1082 exitMenuEdit(1); | |
1083 default: | |
1084 break; | |
1085 case ACTION_IDLE_TICK: | |
1086 case ACTION_IDLE_SECOND: | |
1087 break; | |
1088 } | |
1089 } | |
1090 else | |
1091 if(get_globalState() == event[evid].callerID) | |
1092 { | |
1093 switch(sendAction) | |
1094 { | |
1095 case ACTION_BUTTON_ENTER: | |
1096 nextMenuEditFieldDigit(); | |
1097 break; | |
1098 case ACTION_BUTTON_NEXT: | |
1099 upMenuEditFieldDigit(); | |
1100 break; | |
1101 case ACTION_BUTTON_BACK: | |
1102 downMenuEditFieldDigit(); | |
1103 break; | |
1104 case ACTION_TIMEOUT: | |
1105 case ACTION_MODE_CHANGE: | |
1106 exitMenuEditField(); | |
1107 default: | |
1108 break; | |
1109 case ACTION_IDLE_TICK: | |
1110 case ACTION_IDLE_SECOND: | |
1111 break; | |
1112 } | |
1113 } | |
1114 else | |
1115 { | |
1116 switch(sendAction) | |
1117 { | |
1118 case ACTION_BUTTON_ENTER: | |
1119 break; | |
1120 case ACTION_BUTTON_NEXT: | |
1121 break; | |
1122 case ACTION_BUTTON_BACK: | |
1123 break; | |
1124 case ACTION_TIMEOUT: | |
1125 case ACTION_MODE_CHANGE: | |
1126 exitMenuEdit(1); | |
1127 default: | |
1128 break; | |
1129 case ACTION_IDLE_TICK: | |
1130 case ACTION_IDLE_SECOND: | |
1131 break; | |
1132 } | |
1133 } | |
1134 } | |
1135 | |
1136 | |
1137 void create_newText_for_actual_Id_and_field_select(void) | |
1138 { | |
1139 uint8_t i; | |
1140 | |
1141 i = 0; | |
1142 while( ident[id].size[i] && (i < 4)) | |
1143 { | |
1144 if(ident[id].input[i]) | |
1145 ident[id].newText[ident[id].begin[i]] = '\005'; | |
1146 else | |
1147 ident[id].newText[ident[id].begin[i]] = '\006'; | |
1148 i++; | |
1149 } | |
1150 } | |
1151 | |
1152 | |
1153 void create_newText_for_actual_Id(void) | |
1154 { | |
1155 if( ident[id].maintype == FIELD_SELECT) | |
1156 { | |
1157 create_newText_for_actual_Id_and_field_select(); | |
1158 return; | |
1159 } | |
1160 | |
1161 uint8_t i, digitCount; | |
1162 uint32_t remainder, digit, divider; | |
1163 | |
1164 i = 0; | |
1165 while( ident[id].size[i] && (i < 4)) | |
1166 { | |
1167 remainder = ident[id].input[i]; | |
1168 divider = 1; | |
1169 | |
1170 for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++) | |
1171 divider *= 10; | |
1172 | |
1173 for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++) | |
1174 { | |
1175 digit = remainder / divider; | |
1176 remainder -= digit * divider; | |
1177 divider /= 10; | |
1178 if(digit < 10) | |
1179 ident[id].newText[ident[id].begin[i] + digitCount] = digit + '0'; | |
1180 else | |
1181 ident[id].newText[ident[id].begin[i] + digitCount] = 'x'; | |
1182 } | |
1183 i++; | |
1184 } | |
1185 } | |
1186 | |
1187 | |
1188 void write_content_without_Id(void) | |
1189 { | |
1190 write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, CLUT_MenuEditFieldRegular); | |
1191 } | |
1192 | |
1193 | |
1194 void write_content_of_actual_Id(void) | |
1195 { | |
1196 write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, (CLUT_MenuEditField0 + id)); | |
1197 } | |
1198 | |
1199 | |
1200 void clean_content_of_actual_Id(void) | |
1201 { | |
1202 clean_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed); | |
1203 } | |
1204 | |
1205 | |
1206 void write_field_udigit_and_2digit(uint8_t subtype, uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) | |
1207 { | |
1208 if(id >= 9) | |
1209 return; | |
1210 | |
1211 ident[id].maintype = FIELD_NUMBERS; | |
1212 ident[id].subtype = subtype; | |
1213 | |
1214 ident[id].coord[0] = XleftGimpStyle; | |
1215 ident[id].coord[1] = XrightGimpStyle; | |
1216 ident[id].coord[2] = YtopGimpStyle; | |
1217 ident[id].fontUsed = (tFont *)Font; | |
1218 ident[id].callerID = editID; | |
1219 | |
1220 strncpy(ident[id].orgText, text, 32); | |
1221 strncpy(ident[id].newText, text, 32); | |
1222 ident[id].orgText[31] = 0; | |
1223 ident[id].newText[31] = 0; | |
1224 | |
1225 /* uint32_t has max 10 digits */ | |
1226 | |
1227 int8_t beginTmp, sizeTmp; | |
1228 uint8_t i; | |
1229 | |
1230 ident[id].input[0] = int1; | |
1231 ident[id].input[1] = int2; | |
1232 ident[id].input[2] = int3; | |
1233 ident[id].input[3] = int4; | |
1234 | |
1235 for(i=0;i<4;i++) | |
1236 ident[id].size[i] = 0; | |
1237 | |
1238 beginTmp = 0; | |
1239 for(i=0;i<4;i++) | |
1240 { | |
1241 while((ident[id].orgText[beginTmp] != '#')&& ident[id].orgText[beginTmp]) | |
1242 beginTmp++; | |
1243 | |
1244 if(ident[id].orgText[beginTmp] == '#') | |
1245 { | |
1246 sizeTmp = 1; | |
1247 while(ident[id].orgText[beginTmp + sizeTmp] == '#') | |
1248 sizeTmp++; | |
1249 | |
1250 ident[id].begin[i] = beginTmp; | |
1251 ident[id].size[i] = sizeTmp; | |
1252 beginTmp = ident[id].begin[i] + ident[id].size[i]; | |
1253 } | |
1254 else | |
1255 break; | |
1256 } | |
1257 | |
1258 if(!tME_stop) | |
1259 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1260 else | |
1261 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditInfo); | |
1262 | |
1263 create_newText_for_actual_Id(); | |
1264 | |
1265 if(editID == NULL) | |
1266 write_content_without_Id(); | |
1267 else | |
1268 { | |
1269 write_content_of_actual_Id(); | |
1270 if(!tME_stop) | |
1271 idLast = id; | |
1272 id++; | |
1273 } | |
1274 } | |
1275 | |
1276 void write_field_udigit(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) | |
1277 { | |
1278 write_field_udigit_and_2digit(FIELD_UDIGIT, editID,XleftGimpStyle,XrightGimpStyle,YtopGimpStyle,Font,text,int1,int2,int3,int4); | |
1279 } | |
1280 | |
1281 void write_field_2digit(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) | |
1282 { | |
1283 write_field_udigit_and_2digit(FIELD_2DIGIT, editID,XleftGimpStyle,XrightGimpStyle,YtopGimpStyle,Font,text,int1,int2,int3,int4); | |
1284 } | |
1285 | |
1286 void write_field_3digit(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) | |
1287 { | |
1288 write_field_udigit_and_2digit(FIELD_3DIGIT, editID,XleftGimpStyle,XrightGimpStyle,YtopGimpStyle,Font,text,int1,int2,int3,int4); | |
1289 } | |
1290 | |
1291 /* | |
1292 void write_field_sdigit(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, int32_t int1, int32_t int2, int32_t int3, int32_t int4) | |
1293 { | |
1294 } | |
1295 */ | |
1296 | |
1297 void write_field_select(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1, uint8_t int2, uint8_t int3, uint8_t int4) | |
1298 { | |
1299 if(id >= 9) | |
1300 return; | |
1301 | |
1302 int8_t beginTmp; | |
1303 | |
1304 ident[id].maintype = FIELD_SELECT; | |
1305 ident[id].subtype = FIELD_SELECT; | |
1306 | |
1307 ident[id].coord[0] = XleftGimpStyle; | |
1308 ident[id].coord[1] = XrightGimpStyle; | |
1309 ident[id].coord[2] = YtopGimpStyle; | |
1310 ident[id].fontUsed = (tFont *)Font; | |
1311 ident[id].callerID = editID; | |
1312 | |
1313 strncpy(ident[id].orgText, text, 32); | |
1314 strncpy(ident[id].newText, text, 32); | |
1315 ident[id].orgText[31] = 0; | |
1316 ident[id].newText[31] = 0; | |
1317 | |
1318 ident[id].input[0] = int1; | |
1319 ident[id].input[1] = int2; | |
1320 ident[id].input[2] = int3; | |
1321 ident[id].input[3] = int4; | |
1322 | |
1323 for(int i=0;i<4;i++) | |
1324 ident[id].size[i] = 0; | |
1325 | |
1326 beginTmp = 0; | |
1327 for(int i=0;i<4;i++) | |
1328 { | |
1329 while((ident[id].orgText[beginTmp] != '#')&& ident[id].orgText[beginTmp]) | |
1330 beginTmp++; | |
1331 | |
1332 if(ident[id].orgText[beginTmp] == '#') | |
1333 { | |
1334 | |
1335 ident[id].begin[i] = beginTmp; | |
1336 ident[id].size[i] = 1; | |
1337 beginTmp = ident[id].begin[i] + ident[id].size[i]; | |
1338 } | |
1339 else | |
1340 break; | |
1341 } | |
1342 | |
1343 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1344 | |
1345 create_newText_for_actual_Id(); | |
1346 | |
1347 if(editID == NULL) | |
1348 write_content_without_Id(); | |
1349 else | |
1350 { | |
1351 write_content_of_actual_Id(); | |
1352 if(!tME_stop) | |
1353 idLast = id; | |
1354 id++; | |
1355 } | |
1356 } | |
1357 | |
1358 void write_field_button(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
1359 { | |
1360 if(id >= 9) | |
1361 return; | |
1362 | |
1363 ident[id].maintype = FIELD_BUTTON; | |
1364 ident[id].subtype = FIELD_BUTTON; | |
1365 | |
1366 ident[id].coord[0] = XleftGimpStyle; | |
1367 ident[id].coord[1] = XrightGimpStyle; | |
1368 ident[id].coord[2] = YtopGimpStyle; | |
1369 ident[id].fontUsed = (tFont *)Font; | |
1370 ident[id].callerID = editID; | |
1371 | |
1372 strncpy(ident[id].orgText, text, 32); | |
1373 strncpy(ident[id].newText, text, 32); | |
1374 ident[id].orgText[31] = 0; | |
1375 ident[id].newText[31] = 0; | |
1376 | |
1377 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditButtonColor1); | |
1378 | |
1379 if(editID == NULL) | |
1380 write_content_without_Id(); | |
1381 else | |
1382 { | |
1383 write_content_of_actual_Id(); | |
1384 if(!tME_stop) | |
1385 idLast = id; | |
1386 id++; | |
1387 } | |
1388 } | |
1389 | |
1390 | |
1391 void write_field_symbol(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1) | |
1392 { | |
1393 if(id >= 9) | |
1394 return; | |
1395 | |
1396 ident[id].maintype = FIELD_SYMBOL; | |
1397 ident[id].subtype = FIELD_SYMBOL; | |
1398 | |
1399 ident[id].coord[0] = XleftGimpStyle; | |
1400 ident[id].coord[1] = XrightGimpStyle; | |
1401 ident[id].coord[2] = YtopGimpStyle; | |
1402 ident[id].fontUsed = (tFont *)Font; | |
1403 ident[id].callerID = editID; | |
1404 | |
1405 strncpy(ident[id].orgText, text, 32); | |
1406 strncpy(ident[id].newText, text, 32); | |
1407 ident[id].orgText[31] = 0; | |
1408 | |
1409 ident[id].newText[0] = text[0]; | |
1410 ident[id].newText[1] = 0; | |
1411 | |
1412 ident[id].input[0] = int1; | |
1413 ident[id].input[1] = strlen(ident[id].orgText); | |
1414 | |
1415 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditButtonColor1); | |
1416 | |
1417 if(editID == NULL) | |
1418 write_content_without_Id(); | |
1419 else | |
1420 { | |
1421 write_content_of_actual_Id(); | |
1422 if(!tME_stop) | |
1423 idLast = id; | |
1424 id++; | |
1425 } | |
1426 } | |
1427 | |
1428 | |
1429 /* was build for field_on_off | |
1430 * to be tested for other purposes first | |
1431 */ | |
1432 void tMenuEdit_refresh_field(uint32_t editID) | |
1433 { | |
1434 uint8_t temp_id; | |
1435 | |
1436 temp_id = get_id_of(editID); | |
1437 if(temp_id == 255) | |
1438 return; | |
1439 | |
1440 clean_content( ident[temp_id].coord[0], ident[temp_id].coord[1], ident[temp_id].coord[2], ident[temp_id].fontUsed); | |
1441 write_content( ident[temp_id].coord[0], ident[temp_id].coord[1], ident[temp_id].coord[2], ident[temp_id].fontUsed, ident[temp_id].newText, (CLUT_MenuEditField0 + temp_id)); | |
1442 } | |
1443 | |
1444 | |
1445 void write_field_on_off(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1) | |
1446 { | |
1447 if(id >= 9) | |
1448 return; | |
1449 | |
1450 ident[id].maintype = FIELD_ON_OFF; | |
1451 ident[id].subtype = FIELD_ON_OFF; | |
1452 | |
1453 ident[id].coord[0] = XleftGimpStyle; | |
1454 ident[id].coord[1] = XrightGimpStyle; | |
1455 ident[id].coord[2] = YtopGimpStyle; | |
1456 ident[id].fontUsed = (tFont *)Font; | |
1457 ident[id].callerID = editID; | |
1458 | |
1459 if(int1) | |
1460 ident[id].orgText[0] = '\005'; | |
1461 else | |
1462 ident[id].orgText[0] = '\006'; | |
1463 | |
1464 ident[id].orgText[1] = ' '; | |
1465 | |
1466 strncpy(&ident[id].orgText[2], text, 30); | |
1467 strncpy(ident[id].newText, ident[id].orgText, 32); | |
1468 ident[id].orgText[31] = 0; | |
1469 ident[id].newText[31] = 0; | |
1470 | |
1471 if(!tME_stop) | |
1472 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1473 else | |
1474 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditInfo); | |
1475 | |
1476 if(editID == NULL) | |
1477 write_content_without_Id(); | |
1478 else | |
1479 { | |
1480 write_content_of_actual_Id(); | |
1481 if(!tME_stop) | |
1482 idLast = id; | |
1483 id++; | |
1484 } | |
1485 } | |
1486 | |
1487 | |
1488 void write_field_fpoint(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, float input) | |
1489 { | |
1490 if(id >= 9) | |
1491 return; | |
1492 | |
1493 ident[id].maintype = FIELD_NUMBERS; | |
1494 ident[id].subtype = FIELD_FLOAT; | |
1495 | |
1496 ident[id].coord[0] = XleftGimpStyle; | |
1497 ident[id].coord[1] = XrightGimpStyle; | |
1498 ident[id].coord[2] = YtopGimpStyle; | |
1499 ident[id].fontUsed = (tFont *)Font; | |
1500 ident[id].callerID = editID; | |
1501 | |
1502 strncpy(ident[id].orgText, text, 32); | |
1503 strncpy(ident[id].newText, text, 32); | |
1504 ident[id].orgText[31] = 0; | |
1505 ident[id].newText[31] = 0; | |
1506 | |
1507 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1508 | |
1509 if(editID == NULL) | |
1510 write_content_without_Id(); | |
1511 else | |
1512 { | |
1513 write_content_of_actual_Id(); | |
1514 if(!tME_stop) | |
1515 idLast = id; | |
1516 id++; | |
1517 } | |
1518 } | |
1519 | |
1520 | |
1521 void setBackMenu(uint32_t inputFunctionCall, uint8_t functionCallParameter, uint8_t gotoMenuEditField) | |
1522 { | |
1523 backmenu.pEventFunction = inputFunctionCall; | |
1524 backmenu.functionParameter = functionCallParameter; | |
1525 backmenu.line = gotoMenuEditField; | |
1526 } | |
1527 | |
1528 | |
1529 void setEvent(uint32_t inputEventID, uint32_t inputFunctionCall) | |
1530 { | |
1531 if(evidLast >= 9) | |
1532 return; | |
1533 | |
1534 /* set cursor to first field */ | |
1535 if(evidLast < 0) | |
1536 { | |
1537 startMenuEditFieldSelect(); | |
1538 } | |
1539 | |
1540 event[evid].callerID = inputEventID; | |
1541 event[evid].pEventFunction = inputFunctionCall; | |
1542 | |
1543 evidLast = evid; | |
1544 evid++; | |
1545 } | |
1546 | |
1547 void startEdit(void) | |
1548 { | |
1549 EnterPressed = 1; | |
1550 helperGotoMenuEditField(0); | |
1551 enterMenuEditField(); | |
1552 } | |
1553 | |
1554 void exitEditWithUpdate(void) | |
1555 { | |
1556 createDiveSettings(); | |
1557 EnterPressed = 1; | |
1558 exitMenuEdit(1); | |
1559 } | |
1560 | |
1561 /* | |
1562 void set_cursor(uint8_t forThisIdentID) | |
1563 { | |
1564 int16_t x0, x1, y0, y1; | |
1565 | |
1566 uint32_t xtra_left_right = 10; | |
1567 uint32_t xtra_top_bottom = 10; | |
1568 | |
1569 // y geht von 0 bis 799 | |
1570 // x geht von 0 bis 479 | |
1571 | |
1572 x0 = (int16_t)ident[forThisIdentID].coord[0]; | |
1573 x1 = (int16_t)ident[forThisIdentID].coord[1]; | |
1574 y0 = (int16_t)ident[forThisIdentID].coord[2]; | |
1575 y1 = y0 + (int16_t)ident[forThisIdentID].fontUsed->height; | |
1576 | |
1577 if(((int16_t)ident[forThisIdentID].fontUsed->height) > 70) | |
1578 { | |
1579 xtra_left_right = 10; | |
1580 xtra_top_bottom = 10; | |
1581 } | |
1582 else | |
1583 { | |
1584 xtra_left_right = 10; | |
1585 xtra_top_bottom = 0; | |
1586 } | |
1587 | |
1588 x0 -= xtra_left_right; | |
1589 x1 += xtra_left_right; | |
1590 y0 -= xtra_top_bottom; | |
1591 y1 += xtra_top_bottom; | |
1592 | |
1593 GFX_SetWindowLayer0(tMEcursor.FBStartAdress, x0, x1, y0, y1); | |
1594 } | |
1595 */ | |
1596 | |
1597 void set_cursorNew(uint8_t forThisIdentID) | |
1598 { | |
1599 int16_t y0; | |
1600 uint8_t lineMinusOne; | |
1601 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1602 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1603 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1604 y0 = (int16_t)ident[forThisIdentID].coord[2]; |
117 | 1605 y0 -= ME_Y_LINE1; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1606 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1607 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1608 { |
117 | 1609 y0 = 390 + 25 - (int16_t)ident[forThisIdentID].coord[2]; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1610 } |
117 | 1611 |
38 | 1612 y0 /= ME_Y_LINE_STEP; |
117 | 1613 if((y0 >= 0) && (y0 <=6)) |
38 | 1614 lineMinusOne = y0; |
1615 else | |
1616 lineMinusOne = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1617 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1618 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1619 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1620 GFX_SetFrameBottom((tMEcursorNew.FBStartAdress) + 65*2*(lineMinusOne), 0, 25, 800, 390); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1621 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1622 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1623 { |
117 | 1624 GFX_SetFrameBottom((tMEcursorNew.FBStartAdress)+ (390 - 65 *(6-lineMinusOne)) *2, 0, 480-390-25, 800, 390); |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1625 } |
38 | 1626 } |
1627 | |
1628 | |
1629 void write_topline( char *text) | |
1630 { | |
1631 GFX_DrawCfgWindow hgfx; | |
1632 const tFont *Font = &FontT48; | |
1633 | |
1634 hgfx.Image = &tMEscreen; | |
1635 hgfx.WindowNumberOfTextLines = 1; | |
1636 hgfx.WindowLineSpacing = 0; | |
1637 hgfx.WindowTab = 0; | |
1638 hgfx.WindowX0 = 20; | |
1639 hgfx.WindowX1 = 779; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1640 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1641 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1642 hgfx.WindowY1 = 479; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1643 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1644 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1645 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1646 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1647 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1648 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1649 } |
38 | 1650 GFX_write_label(Font, &hgfx, text, menuColor); |
1651 } | |
1652 | |
1653 | |
1654 void write_buttonTextline( uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) | |
1655 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1656 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1657 SSettings* pSettings; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1658 pSettings = settingsGetPointer(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1659 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1660 if(!pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1661 { |
117 | 1662 GFX_clean_area(&tMEscreen, 0, 800, 479-24,480); |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1663 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1664 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1665 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1666 GFX_clean_area(&tMEscreen, 0, 800, 0, 24); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1667 } |
38 | 1668 |
1669 char localtext[32]; | |
1670 | |
1671 if(left2ByteCode) | |
1672 { | |
1673 localtext[0] = TXT_2BYTE; | |
1674 localtext[1] = left2ByteCode; | |
1675 localtext[2] = 0; | |
117 | 1676 |
1677 write_content_simple(&tMEscreen, 0, 800, 479-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
38 | 1678 } |
1679 | |
1680 if(middle2ByteCode) | |
1681 { | |
1682 localtext[0] = '\001'; | |
1683 localtext[1] = TXT_2BYTE; | |
1684 localtext[2] = middle2ByteCode; | |
1685 localtext[3] = 0; | |
117 | 1686 |
1687 write_content_simple(&tMEscreen, 0, 800, 479-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
38 | 1688 } |
1689 | |
1690 if(right2ByteCode) | |
1691 { | |
1692 localtext[0] = '\002'; | |
1693 localtext[1] = TXT_2BYTE; | |
1694 localtext[2] = right2ByteCode; | |
1695 localtext[3] = 0; | |
117 | 1696 |
1697 write_content_simple(&tMEscreen, 0, 800, 479-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
38 | 1698 } |
1699 } | |
1700 | |
1701 | |
1702 | |
1703 void write_label_var(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
1704 { | |
1705 GFX_DrawCfgWindow hgfx; | |
1706 | |
1707 if(XrightGimpStyle > 799) | |
1708 XrightGimpStyle = 799; | |
1709 if(XleftGimpStyle >= XrightGimpStyle) | |
1710 XleftGimpStyle = 0; | |
1711 if(YtopGimpStyle > 479) | |
1712 YtopGimpStyle = 479; | |
1713 hgfx.Image = &tMEscreen; | |
1714 hgfx.WindowNumberOfTextLines = 1; | |
1715 hgfx.WindowLineSpacing = 0; | |
1716 hgfx.WindowTab = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1717 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1718 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1719 hgfx.WindowX0 = XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1720 hgfx.WindowX1 = XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1721 hgfx.WindowY1 = 479 - YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1722 if(hgfx.WindowY1 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1723 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1724 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1725 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1726 } |
38 | 1727 else |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1728 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1729 hgfx.WindowX0 = 800 - XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1730 hgfx.WindowX1 = 800 - XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1731 hgfx.WindowY0 = YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1732 if(hgfx.WindowY0 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1733 hgfx.WindowY1 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1734 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1735 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1736 } |
38 | 1737 GFX_write_label(Font, &hgfx, text, 0);/*menuColor);*/ |
1738 } | |
1739 | |
1740 | |
1741 void write_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) | |
1742 { | |
1743 GFX_DrawCfgWindow hgfx; | |
1744 | |
1745 if(XrightGimpStyle > 799) | |
1746 XrightGimpStyle = 799; | |
1747 if(XleftGimpStyle >= XrightGimpStyle) | |
1748 XleftGimpStyle = 0; | |
1749 if(YtopGimpStyle > 479) | |
1750 YtopGimpStyle = 479; | |
1751 hgfx.Image = &tMEscreen; | |
1752 hgfx.WindowNumberOfTextLines = 1; | |
1753 hgfx.WindowLineSpacing = 0; | |
1754 hgfx.WindowTab = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1755 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1756 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1757 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1758 hgfx.WindowX0 = XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1759 hgfx.WindowX1 = XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1760 hgfx.WindowY1 = 479 - YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1761 if(hgfx.WindowY1 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1762 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1763 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1764 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1765 } |
38 | 1766 else |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1767 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1768 hgfx.WindowX0 = 800 - XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1769 hgfx.WindowX1 = 800 - XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1770 hgfx.WindowY0 = YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1771 if(hgfx.WindowY0 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1772 hgfx.WindowY1 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1773 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1774 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1775 } |
38 | 1776 GFX_write_label(Font, &hgfx, text, color); |
1777 } | |
1778 | |
1779 | |
1780 void write_label_fix(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char textId) | |
1781 { | |
1782 char text[2]; | |
1783 | |
1784 text[0] = textId; | |
1785 text[1] = 0; | |
1786 | |
1787 write_label_var(XleftGimpStyle, XrightGimpStyle, YtopGimpStyle, Font, text); | |
1788 } | |
1789 | |
1790 | |
1791 void clean_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font) | |
1792 { | |
1793 GFX_DrawCfgWindow hgfx; | |
1794 | |
1795 if(XrightGimpStyle > 799) | |
1796 XrightGimpStyle = 799; | |
1797 if(XleftGimpStyle >= XrightGimpStyle) | |
1798 XleftGimpStyle = 0; | |
1799 if(YtopGimpStyle > 479) | |
1800 YtopGimpStyle = 479; | |
1801 hgfx.Image = &tMEscreen; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1802 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1803 { |
38 | 1804 hgfx.WindowX0 = XleftGimpStyle; |
1805 hgfx.WindowX1 = XrightGimpStyle; | |
1806 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
1807 if(hgfx.WindowY1 < Font->height) | |
1808 hgfx.WindowY0 = 0; | |
1809 else | |
1810 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1811 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1812 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1813 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1814 hgfx.WindowX0 = 800 - XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1815 hgfx.WindowX1 = 800 - XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1816 hgfx.WindowY0 = YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1817 if(hgfx.WindowY0 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1818 hgfx.WindowY1 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1819 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1820 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1821 } |
38 | 1822 GFX_clear_window_immediately(&hgfx); |
1823 } | |
1824 | |
1825 | |
1826 /* Private functions ---------------------------------------------------------*/ | |
1827 | |
1828 void draw_tMEdesign(void) | |
1829 { | |
1830 GFX_draw_header(&tMEscreen,menuColor); | |
1831 } | |
1832 | |
1833 void draw_tMEdesignSubUnselected(uint32_t *ppDestination) | |
1834 { | |
1835 union al88_u | |
1836 { | |
1837 uint8_t al8[2]; | |
1838 uint16_t al88; | |
1839 }; | |
1840 | |
1841 union al88_u color_seperator; | |
1842 union al88_u color_unselected; | |
1843 int i; | |
1844 | |
1845 color_seperator.al8[0] = CLUT_MenuLineUnselectedSeperator; | |
1846 color_unselected.al8[0] = CLUT_MenuLineUnselected; | |
1847 | |
1848 color_seperator.al8[1] = 0xFF; | |
1849 color_unselected.al8[1] = 0xFF; | |
1850 | |
1851 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1852 *ppDestination += 2; | |
1853 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1854 *ppDestination += 2; | |
1855 | |
1856 for(i = 61; i > 0; i--) | |
1857 { | |
1858 *(__IO uint16_t*)*ppDestination = color_unselected.al88; | |
1859 *ppDestination += 2; | |
1860 } | |
1861 | |
1862 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1863 *ppDestination += 2; | |
1864 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1865 *ppDestination += 2; | |
1866 } | |
1867 | |
1868 | |
1869 void draw_tMEdesignSubSelected(uint32_t *ppDestination) | |
1870 { | |
1871 union al88_u | |
1872 { | |
1873 uint8_t al8[2]; | |
1874 uint16_t al88; | |
1875 }; | |
1876 | |
1877 union al88_u color_selected; | |
1878 union al88_u color_seperator; | |
1879 int i; | |
1880 | |
1881 color_selected.al8[0] = CLUT_MenuEditLineSelected; | |
1882 color_selected.al8[1] = 0xFF; | |
1883 | |
1884 color_seperator.al8[0] = CLUT_MenuLineSelectedSeperator; | |
1885 color_seperator.al8[1] = 0xFF; | |
1886 | |
1887 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1888 *ppDestination += 2; | |
1889 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1890 *ppDestination += 2; | |
1891 | |
1892 for(i = 61; i > 0; i--) | |
1893 { | |
1894 *(__IO uint16_t*)*ppDestination = color_selected.al88; | |
1895 *ppDestination += 2; | |
1896 } | |
1897 | |
1898 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1899 *ppDestination += 2; | |
1900 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1901 *ppDestination += 2; | |
1902 } | |
1903 | |
1904 | |
1905 void draw_tMEdesignSubSelectedBorder(uint32_t *ppDestination) | |
1906 { | |
1907 union al88_u | |
1908 { | |
1909 uint8_t al8[2]; | |
1910 uint16_t al88; | |
1911 }; | |
1912 | |
1913 union al88_u color_selected_sides; | |
1914 | |
1915 int i; | |
1916 | |
1917 color_selected_sides.al8[0] = CLUT_MenuLineSelectedSides; | |
1918 color_selected_sides.al8[1] = 0xFF; | |
1919 | |
1920 for(i = 65; i > 0; i--) | |
1921 { | |
1922 *(__IO uint16_t*)*ppDestination = color_selected_sides.al88; | |
1923 *ppDestination += 2; | |
1924 } | |
1925 } | |
1926 | |
1927 | |
1928 void draw_tMEcursorNewDesign(void) | |
1929 { | |
1930 int i,j; | |
1931 uint32_t pDestination; | |
1932 | |
1933 pDestination = tMEcursorNew.FBStartAdress; | |
1934 | |
1935 for(j = 801; j > 0; j--) | |
1936 { | |
1937 for(i = 5; i > 0; i--) | |
1938 { | |
1939 draw_tMEdesignSubUnselected(&pDestination); | |
1940 } | |
1941 if((j > 787) || (j < 17)) | |
1942 draw_tMEdesignSubSelectedBorder(&pDestination); | |
1943 else | |
1944 draw_tMEdesignSubSelected(&pDestination); | |
1945 } | |
1946 } |