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