Mercurial > public > ostc4
annotate Discovery/Src/tMenuEdit.c @ 186:f11f0bf6ef2d cleanup-2
cleanup: remove obsolete code, make static, etc.
Some rather trivial cleanup things like putting demo code into
ifdefs, making functions static where possible, and against my
normal policy of hard removing unused code, commenting it out
at this point in time. Somehow, I think that this commented code
might be useful in the near future as a new pressure sensor is coming.
And finally, fixed some typo's in comment.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Fri, 15 Mar 2019 12:39:28 +0100 |
parents | 255eedad4155 |
children | f9b17e898a7a |
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 default: | |
1074 break; | |
1075 case ACTION_IDLE_TICK: | |
1076 case ACTION_IDLE_SECOND: | |
1077 break; | |
1078 } | |
1079 } | |
1080 else | |
1081 if(get_globalState() == event[evid].callerID) | |
1082 { | |
1083 switch(sendAction) | |
1084 { | |
1085 case ACTION_BUTTON_ENTER: | |
1086 nextMenuEditFieldDigit(); | |
1087 break; | |
1088 case ACTION_BUTTON_NEXT: | |
1089 upMenuEditFieldDigit(); | |
1090 break; | |
1091 case ACTION_BUTTON_BACK: | |
1092 downMenuEditFieldDigit(); | |
1093 break; | |
1094 case ACTION_TIMEOUT: | |
1095 case ACTION_MODE_CHANGE: | |
1096 exitMenuEditField(); | |
1097 default: | |
1098 break; | |
1099 case ACTION_IDLE_TICK: | |
1100 case ACTION_IDLE_SECOND: | |
1101 break; | |
1102 } | |
1103 } | |
1104 else | |
1105 { | |
1106 switch(sendAction) | |
1107 { | |
1108 case ACTION_BUTTON_ENTER: | |
1109 break; | |
1110 case ACTION_BUTTON_NEXT: | |
1111 break; | |
1112 case ACTION_BUTTON_BACK: | |
1113 break; | |
1114 case ACTION_TIMEOUT: | |
1115 case ACTION_MODE_CHANGE: | |
1116 exitMenuEdit(1); | |
1117 default: | |
1118 break; | |
1119 case ACTION_IDLE_TICK: | |
1120 case ACTION_IDLE_SECOND: | |
1121 break; | |
1122 } | |
1123 } | |
1124 } | |
1125 | |
1126 | |
1127 void create_newText_for_actual_Id_and_field_select(void) | |
1128 { | |
1129 uint8_t i; | |
1130 | |
1131 i = 0; | |
1132 while( ident[id].size[i] && (i < 4)) | |
1133 { | |
1134 if(ident[id].input[i]) | |
1135 ident[id].newText[ident[id].begin[i]] = '\005'; | |
1136 else | |
1137 ident[id].newText[ident[id].begin[i]] = '\006'; | |
1138 i++; | |
1139 } | |
1140 } | |
1141 | |
1142 | |
1143 void create_newText_for_actual_Id(void) | |
1144 { | |
1145 if( ident[id].maintype == FIELD_SELECT) | |
1146 { | |
1147 create_newText_for_actual_Id_and_field_select(); | |
1148 return; | |
1149 } | |
1150 | |
1151 uint8_t i, digitCount; | |
1152 uint32_t remainder, digit, divider; | |
1153 | |
1154 i = 0; | |
1155 while( ident[id].size[i] && (i < 4)) | |
1156 { | |
1157 remainder = ident[id].input[i]; | |
1158 divider = 1; | |
1159 | |
1160 for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++) | |
1161 divider *= 10; | |
1162 | |
1163 for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++) | |
1164 { | |
1165 digit = remainder / divider; | |
1166 remainder -= digit * divider; | |
1167 divider /= 10; | |
1168 if(digit < 10) | |
1169 ident[id].newText[ident[id].begin[i] + digitCount] = digit + '0'; | |
1170 else | |
1171 ident[id].newText[ident[id].begin[i] + digitCount] = 'x'; | |
1172 } | |
1173 i++; | |
1174 } | |
1175 } | |
1176 | |
1177 | |
1178 void write_content_without_Id(void) | |
1179 { | |
1180 write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, CLUT_MenuEditFieldRegular); | |
1181 } | |
1182 | |
1183 | |
1184 void write_content_of_actual_Id(void) | |
1185 { | |
1186 write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, (CLUT_MenuEditField0 + id)); | |
1187 } | |
1188 | |
1189 | |
1190 void clean_content_of_actual_Id(void) | |
1191 { | |
1192 clean_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed); | |
1193 } | |
1194 | |
1195 | |
1196 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) | |
1197 { | |
1198 if(id >= 9) | |
1199 return; | |
1200 | |
1201 ident[id].maintype = FIELD_NUMBERS; | |
1202 ident[id].subtype = subtype; | |
1203 | |
1204 ident[id].coord[0] = XleftGimpStyle; | |
1205 ident[id].coord[1] = XrightGimpStyle; | |
1206 ident[id].coord[2] = YtopGimpStyle; | |
1207 ident[id].fontUsed = (tFont *)Font; | |
1208 ident[id].callerID = editID; | |
1209 | |
1210 strncpy(ident[id].orgText, text, 32); | |
1211 strncpy(ident[id].newText, text, 32); | |
1212 ident[id].orgText[31] = 0; | |
1213 ident[id].newText[31] = 0; | |
1214 | |
1215 /* uint32_t has max 10 digits */ | |
1216 | |
1217 int8_t beginTmp, sizeTmp; | |
1218 uint8_t i; | |
1219 | |
1220 ident[id].input[0] = int1; | |
1221 ident[id].input[1] = int2; | |
1222 ident[id].input[2] = int3; | |
1223 ident[id].input[3] = int4; | |
1224 | |
1225 for(i=0;i<4;i++) | |
1226 ident[id].size[i] = 0; | |
1227 | |
1228 beginTmp = 0; | |
1229 for(i=0;i<4;i++) | |
1230 { | |
1231 while((ident[id].orgText[beginTmp] != '#')&& ident[id].orgText[beginTmp]) | |
1232 beginTmp++; | |
1233 | |
1234 if(ident[id].orgText[beginTmp] == '#') | |
1235 { | |
1236 sizeTmp = 1; | |
1237 while(ident[id].orgText[beginTmp + sizeTmp] == '#') | |
1238 sizeTmp++; | |
1239 | |
1240 ident[id].begin[i] = beginTmp; | |
1241 ident[id].size[i] = sizeTmp; | |
1242 beginTmp = ident[id].begin[i] + ident[id].size[i]; | |
1243 } | |
1244 else | |
1245 break; | |
1246 } | |
1247 | |
1248 if(!tME_stop) | |
1249 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1250 else | |
1251 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditInfo); | |
1252 | |
1253 create_newText_for_actual_Id(); | |
1254 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
1255 if(editID == 0) |
38 | 1256 write_content_without_Id(); |
1257 else | |
1258 { | |
1259 write_content_of_actual_Id(); | |
1260 if(!tME_stop) | |
1261 idLast = id; | |
1262 id++; | |
1263 } | |
1264 } | |
1265 | |
1266 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) | |
1267 { | |
1268 write_field_udigit_and_2digit(FIELD_UDIGIT, editID,XleftGimpStyle,XrightGimpStyle,YtopGimpStyle,Font,text,int1,int2,int3,int4); | |
1269 } | |
1270 | |
1271 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) | |
1272 { | |
1273 write_field_udigit_and_2digit(FIELD_2DIGIT, editID,XleftGimpStyle,XrightGimpStyle,YtopGimpStyle,Font,text,int1,int2,int3,int4); | |
1274 } | |
1275 | |
1276 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) | |
1277 { | |
1278 write_field_udigit_and_2digit(FIELD_3DIGIT, editID,XleftGimpStyle,XrightGimpStyle,YtopGimpStyle,Font,text,int1,int2,int3,int4); | |
1279 } | |
1280 | |
1281 /* | |
1282 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) | |
1283 { | |
1284 } | |
1285 */ | |
1286 | |
1287 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) | |
1288 { | |
1289 if(id >= 9) | |
1290 return; | |
1291 | |
1292 int8_t beginTmp; | |
1293 | |
1294 ident[id].maintype = FIELD_SELECT; | |
1295 ident[id].subtype = FIELD_SELECT; | |
1296 | |
1297 ident[id].coord[0] = XleftGimpStyle; | |
1298 ident[id].coord[1] = XrightGimpStyle; | |
1299 ident[id].coord[2] = YtopGimpStyle; | |
1300 ident[id].fontUsed = (tFont *)Font; | |
1301 ident[id].callerID = editID; | |
1302 | |
1303 strncpy(ident[id].orgText, text, 32); | |
1304 strncpy(ident[id].newText, text, 32); | |
1305 ident[id].orgText[31] = 0; | |
1306 ident[id].newText[31] = 0; | |
1307 | |
1308 ident[id].input[0] = int1; | |
1309 ident[id].input[1] = int2; | |
1310 ident[id].input[2] = int3; | |
1311 ident[id].input[3] = int4; | |
1312 | |
1313 for(int i=0;i<4;i++) | |
1314 ident[id].size[i] = 0; | |
1315 | |
1316 beginTmp = 0; | |
1317 for(int i=0;i<4;i++) | |
1318 { | |
1319 while((ident[id].orgText[beginTmp] != '#')&& ident[id].orgText[beginTmp]) | |
1320 beginTmp++; | |
1321 | |
1322 if(ident[id].orgText[beginTmp] == '#') | |
1323 { | |
1324 | |
1325 ident[id].begin[i] = beginTmp; | |
1326 ident[id].size[i] = 1; | |
1327 beginTmp = ident[id].begin[i] + ident[id].size[i]; | |
1328 } | |
1329 else | |
1330 break; | |
1331 } | |
1332 | |
1333 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1334 | |
1335 create_newText_for_actual_Id(); | |
1336 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
1337 if(editID == 0) |
38 | 1338 write_content_without_Id(); |
1339 else | |
1340 { | |
1341 write_content_of_actual_Id(); | |
1342 if(!tME_stop) | |
1343 idLast = id; | |
1344 id++; | |
1345 } | |
1346 } | |
1347 | |
1348 void write_field_button(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
1349 { | |
1350 if(id >= 9) | |
1351 return; | |
1352 | |
1353 ident[id].maintype = FIELD_BUTTON; | |
1354 ident[id].subtype = FIELD_BUTTON; | |
1355 | |
1356 ident[id].coord[0] = XleftGimpStyle; | |
1357 ident[id].coord[1] = XrightGimpStyle; | |
1358 ident[id].coord[2] = YtopGimpStyle; | |
1359 ident[id].fontUsed = (tFont *)Font; | |
1360 ident[id].callerID = editID; | |
1361 | |
1362 strncpy(ident[id].orgText, text, 32); | |
1363 strncpy(ident[id].newText, text, 32); | |
1364 ident[id].orgText[31] = 0; | |
1365 ident[id].newText[31] = 0; | |
1366 | |
1367 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditButtonColor1); | |
1368 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
1369 if(editID == 0) |
38 | 1370 write_content_without_Id(); |
1371 else | |
1372 { | |
1373 write_content_of_actual_Id(); | |
1374 if(!tME_stop) | |
1375 idLast = id; | |
1376 id++; | |
1377 } | |
1378 } | |
1379 | |
1380 | |
1381 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) | |
1382 { | |
1383 if(id >= 9) | |
1384 return; | |
1385 | |
1386 ident[id].maintype = FIELD_SYMBOL; | |
1387 ident[id].subtype = FIELD_SYMBOL; | |
1388 | |
1389 ident[id].coord[0] = XleftGimpStyle; | |
1390 ident[id].coord[1] = XrightGimpStyle; | |
1391 ident[id].coord[2] = YtopGimpStyle; | |
1392 ident[id].fontUsed = (tFont *)Font; | |
1393 ident[id].callerID = editID; | |
1394 | |
1395 strncpy(ident[id].orgText, text, 32); | |
1396 strncpy(ident[id].newText, text, 32); | |
1397 ident[id].orgText[31] = 0; | |
1398 | |
1399 ident[id].newText[0] = text[0]; | |
1400 ident[id].newText[1] = 0; | |
1401 | |
1402 ident[id].input[0] = int1; | |
1403 ident[id].input[1] = strlen(ident[id].orgText); | |
1404 | |
1405 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditButtonColor1); | |
1406 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
1407 if(editID == 0) |
38 | 1408 write_content_without_Id(); |
1409 else | |
1410 { | |
1411 write_content_of_actual_Id(); | |
1412 if(!tME_stop) | |
1413 idLast = id; | |
1414 id++; | |
1415 } | |
1416 } | |
1417 | |
1418 | |
1419 /* was build for field_on_off | |
1420 * to be tested for other purposes first | |
1421 */ | |
1422 void tMenuEdit_refresh_field(uint32_t editID) | |
1423 { | |
1424 uint8_t temp_id; | |
1425 | |
1426 temp_id = get_id_of(editID); | |
1427 if(temp_id == 255) | |
1428 return; | |
1429 | |
1430 clean_content( ident[temp_id].coord[0], ident[temp_id].coord[1], ident[temp_id].coord[2], ident[temp_id].fontUsed); | |
1431 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)); | |
1432 } | |
1433 | |
1434 | |
1435 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) | |
1436 { | |
1437 if(id >= 9) | |
1438 return; | |
1439 | |
1440 ident[id].maintype = FIELD_ON_OFF; | |
1441 ident[id].subtype = FIELD_ON_OFF; | |
1442 | |
1443 ident[id].coord[0] = XleftGimpStyle; | |
1444 ident[id].coord[1] = XrightGimpStyle; | |
1445 ident[id].coord[2] = YtopGimpStyle; | |
1446 ident[id].fontUsed = (tFont *)Font; | |
1447 ident[id].callerID = editID; | |
1448 | |
1449 if(int1) | |
1450 ident[id].orgText[0] = '\005'; | |
1451 else | |
1452 ident[id].orgText[0] = '\006'; | |
1453 | |
1454 ident[id].orgText[1] = ' '; | |
1455 | |
1456 strncpy(&ident[id].orgText[2], text, 30); | |
1457 strncpy(ident[id].newText, ident[id].orgText, 32); | |
1458 ident[id].orgText[31] = 0; | |
1459 ident[id].newText[31] = 0; | |
1460 | |
1461 if(!tME_stop) | |
1462 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1463 else | |
1464 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditInfo); | |
1465 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
1466 if(editID == 0) |
38 | 1467 write_content_without_Id(); |
1468 else | |
1469 { | |
1470 write_content_of_actual_Id(); | |
1471 if(!tME_stop) | |
1472 idLast = id; | |
1473 id++; | |
1474 } | |
1475 } | |
1476 | |
1477 | |
1478 void write_field_fpoint(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, float input) | |
1479 { | |
1480 if(id >= 9) | |
1481 return; | |
1482 | |
1483 ident[id].maintype = FIELD_NUMBERS; | |
1484 ident[id].subtype = FIELD_FLOAT; | |
1485 | |
1486 ident[id].coord[0] = XleftGimpStyle; | |
1487 ident[id].coord[1] = XrightGimpStyle; | |
1488 ident[id].coord[2] = YtopGimpStyle; | |
1489 ident[id].fontUsed = (tFont *)Font; | |
1490 ident[id].callerID = editID; | |
1491 | |
1492 strncpy(ident[id].orgText, text, 32); | |
1493 strncpy(ident[id].newText, text, 32); | |
1494 ident[id].orgText[31] = 0; | |
1495 ident[id].newText[31] = 0; | |
1496 | |
1497 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1498 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
1499 if(editID == 0) |
38 | 1500 write_content_without_Id(); |
1501 else | |
1502 { | |
1503 write_content_of_actual_Id(); | |
1504 if(!tME_stop) | |
1505 idLast = id; | |
1506 id++; | |
1507 } | |
1508 } | |
1509 | |
1510 | |
1511 void setBackMenu(uint32_t inputFunctionCall, uint8_t functionCallParameter, uint8_t gotoMenuEditField) | |
1512 { | |
1513 backmenu.pEventFunction = inputFunctionCall; | |
1514 backmenu.functionParameter = functionCallParameter; | |
1515 backmenu.line = gotoMenuEditField; | |
1516 } | |
1517 | |
1518 | |
1519 void setEvent(uint32_t inputEventID, uint32_t inputFunctionCall) | |
1520 { | |
1521 if(evidLast >= 9) | |
1522 return; | |
1523 | |
1524 /* set cursor to first field */ | |
1525 if(evidLast < 0) | |
1526 { | |
1527 startMenuEditFieldSelect(); | |
1528 } | |
1529 | |
1530 event[evid].callerID = inputEventID; | |
1531 event[evid].pEventFunction = inputFunctionCall; | |
1532 | |
1533 evidLast = evid; | |
1534 evid++; | |
1535 } | |
1536 | |
1537 void startEdit(void) | |
1538 { | |
1539 EnterPressed = 1; | |
1540 helperGotoMenuEditField(0); | |
1541 enterMenuEditField(); | |
1542 } | |
1543 | |
1544 void exitEditWithUpdate(void) | |
1545 { | |
1546 createDiveSettings(); | |
1547 EnterPressed = 1; | |
1548 exitMenuEdit(1); | |
1549 } | |
1550 | |
1551 /* | |
1552 void set_cursor(uint8_t forThisIdentID) | |
1553 { | |
1554 int16_t x0, x1, y0, y1; | |
1555 | |
1556 uint32_t xtra_left_right = 10; | |
1557 uint32_t xtra_top_bottom = 10; | |
1558 | |
1559 // y geht von 0 bis 799 | |
1560 // x geht von 0 bis 479 | |
1561 | |
1562 x0 = (int16_t)ident[forThisIdentID].coord[0]; | |
1563 x1 = (int16_t)ident[forThisIdentID].coord[1]; | |
1564 y0 = (int16_t)ident[forThisIdentID].coord[2]; | |
1565 y1 = y0 + (int16_t)ident[forThisIdentID].fontUsed->height; | |
1566 | |
1567 if(((int16_t)ident[forThisIdentID].fontUsed->height) > 70) | |
1568 { | |
1569 xtra_left_right = 10; | |
1570 xtra_top_bottom = 10; | |
1571 } | |
1572 else | |
1573 { | |
1574 xtra_left_right = 10; | |
1575 xtra_top_bottom = 0; | |
1576 } | |
1577 | |
1578 x0 -= xtra_left_right; | |
1579 x1 += xtra_left_right; | |
1580 y0 -= xtra_top_bottom; | |
1581 y1 += xtra_top_bottom; | |
1582 | |
1583 GFX_SetWindowLayer0(tMEcursor.FBStartAdress, x0, x1, y0, y1); | |
1584 } | |
1585 */ | |
1586 | |
1587 void set_cursorNew(uint8_t forThisIdentID) | |
1588 { | |
1589 int16_t y0; | |
1590 uint8_t lineMinusOne; | |
1591 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1592 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1593 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1594 y0 = (int16_t)ident[forThisIdentID].coord[2]; |
117 | 1595 y0 -= ME_Y_LINE1; |
110
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 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1598 { |
117 | 1599 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
|
1600 } |
117 | 1601 |
38 | 1602 y0 /= ME_Y_LINE_STEP; |
117 | 1603 if((y0 >= 0) && (y0 <=6)) |
38 | 1604 lineMinusOne = y0; |
1605 else | |
1606 lineMinusOne = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1607 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1608 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1609 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1610 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
|
1611 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1612 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1613 { |
117 | 1614 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
|
1615 } |
38 | 1616 } |
1617 | |
1618 | |
1619 void write_topline( char *text) | |
1620 { | |
1621 GFX_DrawCfgWindow hgfx; | |
1622 const tFont *Font = &FontT48; | |
1623 | |
1624 hgfx.Image = &tMEscreen; | |
1625 hgfx.WindowNumberOfTextLines = 1; | |
1626 hgfx.WindowLineSpacing = 0; | |
1627 hgfx.WindowTab = 0; | |
1628 hgfx.WindowX0 = 20; | |
1629 hgfx.WindowX1 = 779; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1630 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1631 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1632 hgfx.WindowY1 = 479; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1633 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
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 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1636 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1637 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1638 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1639 } |
38 | 1640 GFX_write_label(Font, &hgfx, text, menuColor); |
1641 } | |
1642 | |
1643 | |
1644 void write_buttonTextline( uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) | |
1645 { | |
110
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 SSettings* pSettings; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1648 pSettings = settingsGetPointer(); |
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 if(!pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1651 { |
117 | 1652 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
|
1653 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1654 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1655 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1656 GFX_clean_area(&tMEscreen, 0, 800, 0, 24); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1657 } |
38 | 1658 |
1659 char localtext[32]; | |
1660 | |
1661 if(left2ByteCode) | |
1662 { | |
1663 localtext[0] = TXT_2BYTE; | |
1664 localtext[1] = left2ByteCode; | |
1665 localtext[2] = 0; | |
117 | 1666 |
1667 write_content_simple(&tMEscreen, 0, 800, 479-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
38 | 1668 } |
1669 | |
1670 if(middle2ByteCode) | |
1671 { | |
1672 localtext[0] = '\001'; | |
1673 localtext[1] = TXT_2BYTE; | |
1674 localtext[2] = middle2ByteCode; | |
1675 localtext[3] = 0; | |
117 | 1676 |
1677 write_content_simple(&tMEscreen, 0, 800, 479-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
38 | 1678 } |
1679 | |
1680 if(right2ByteCode) | |
1681 { | |
1682 localtext[0] = '\002'; | |
1683 localtext[1] = TXT_2BYTE; | |
1684 localtext[2] = right2ByteCode; | |
1685 localtext[3] = 0; | |
117 | 1686 |
1687 write_content_simple(&tMEscreen, 0, 800, 479-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
38 | 1688 } |
1689 } | |
1690 | |
1691 | |
1692 | |
1693 void write_label_var(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
1694 { | |
1695 GFX_DrawCfgWindow hgfx; | |
1696 | |
1697 if(XrightGimpStyle > 799) | |
1698 XrightGimpStyle = 799; | |
1699 if(XleftGimpStyle >= XrightGimpStyle) | |
1700 XleftGimpStyle = 0; | |
1701 if(YtopGimpStyle > 479) | |
1702 YtopGimpStyle = 479; | |
1703 hgfx.Image = &tMEscreen; | |
1704 hgfx.WindowNumberOfTextLines = 1; | |
1705 hgfx.WindowLineSpacing = 0; | |
1706 hgfx.WindowTab = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1707 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1708 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1709 hgfx.WindowX0 = XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1710 hgfx.WindowX1 = XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1711 hgfx.WindowY1 = 479 - YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1712 if(hgfx.WindowY1 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1713 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1714 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1715 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1716 } |
38 | 1717 else |
110
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 = 800 - XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1720 hgfx.WindowX1 = 800 - XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1721 hgfx.WindowY0 = YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1722 if(hgfx.WindowY0 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1723 hgfx.WindowY1 = 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.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1726 } |
38 | 1727 GFX_write_label(Font, &hgfx, text, 0);/*menuColor);*/ |
1728 } | |
1729 | |
1730 | |
1731 void write_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) | |
1732 { | |
1733 GFX_DrawCfgWindow hgfx; | |
1734 | |
1735 if(XrightGimpStyle > 799) | |
1736 XrightGimpStyle = 799; | |
1737 if(XleftGimpStyle >= XrightGimpStyle) | |
1738 XleftGimpStyle = 0; | |
1739 if(YtopGimpStyle > 479) | |
1740 YtopGimpStyle = 479; | |
1741 hgfx.Image = &tMEscreen; | |
1742 hgfx.WindowNumberOfTextLines = 1; | |
1743 hgfx.WindowLineSpacing = 0; | |
1744 hgfx.WindowTab = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1745 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1746 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1747 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1748 hgfx.WindowX0 = XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1749 hgfx.WindowX1 = XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1750 hgfx.WindowY1 = 479 - YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1751 if(hgfx.WindowY1 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1752 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1753 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1754 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1755 } |
38 | 1756 else |
110
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 = 800 - XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1759 hgfx.WindowX1 = 800 - XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1760 hgfx.WindowY0 = YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1761 if(hgfx.WindowY0 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1762 hgfx.WindowY1 = 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.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1765 } |
38 | 1766 GFX_write_label(Font, &hgfx, text, color); |
1767 } | |
1768 | |
1769 | |
1770 void write_label_fix(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char textId) | |
1771 { | |
1772 char text[2]; | |
1773 | |
1774 text[0] = textId; | |
1775 text[1] = 0; | |
1776 | |
1777 write_label_var(XleftGimpStyle, XrightGimpStyle, YtopGimpStyle, Font, text); | |
1778 } | |
1779 | |
1780 | |
1781 void clean_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font) | |
1782 { | |
1783 GFX_DrawCfgWindow hgfx; | |
1784 | |
1785 if(XrightGimpStyle > 799) | |
1786 XrightGimpStyle = 799; | |
1787 if(XleftGimpStyle >= XrightGimpStyle) | |
1788 XleftGimpStyle = 0; | |
1789 if(YtopGimpStyle > 479) | |
1790 YtopGimpStyle = 479; | |
1791 hgfx.Image = &tMEscreen; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1792 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1793 { |
38 | 1794 hgfx.WindowX0 = XleftGimpStyle; |
1795 hgfx.WindowX1 = XrightGimpStyle; | |
1796 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
1797 if(hgfx.WindowY1 < Font->height) | |
1798 hgfx.WindowY0 = 0; | |
1799 else | |
1800 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1801 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1802 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1803 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1804 hgfx.WindowX0 = 800 - XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1805 hgfx.WindowX1 = 800 - XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1806 hgfx.WindowY0 = YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1807 if(hgfx.WindowY0 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1808 hgfx.WindowY1 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1809 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1810 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1811 } |
38 | 1812 GFX_clear_window_immediately(&hgfx); |
1813 } | |
1814 | |
1815 | |
1816 /* Private functions ---------------------------------------------------------*/ | |
1817 | |
1818 void draw_tMEdesign(void) | |
1819 { | |
1820 GFX_draw_header(&tMEscreen,menuColor); | |
1821 } | |
1822 | |
1823 void draw_tMEdesignSubUnselected(uint32_t *ppDestination) | |
1824 { | |
1825 union al88_u | |
1826 { | |
1827 uint8_t al8[2]; | |
1828 uint16_t al88; | |
1829 }; | |
1830 | |
1831 union al88_u color_seperator; | |
1832 union al88_u color_unselected; | |
1833 int i; | |
1834 | |
1835 color_seperator.al8[0] = CLUT_MenuLineUnselectedSeperator; | |
1836 color_unselected.al8[0] = CLUT_MenuLineUnselected; | |
1837 | |
1838 color_seperator.al8[1] = 0xFF; | |
1839 color_unselected.al8[1] = 0xFF; | |
1840 | |
1841 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1842 *ppDestination += 2; | |
1843 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1844 *ppDestination += 2; | |
1845 | |
1846 for(i = 61; i > 0; i--) | |
1847 { | |
1848 *(__IO uint16_t*)*ppDestination = color_unselected.al88; | |
1849 *ppDestination += 2; | |
1850 } | |
1851 | |
1852 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1853 *ppDestination += 2; | |
1854 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1855 *ppDestination += 2; | |
1856 } | |
1857 | |
1858 | |
1859 void draw_tMEdesignSubSelected(uint32_t *ppDestination) | |
1860 { | |
1861 union al88_u | |
1862 { | |
1863 uint8_t al8[2]; | |
1864 uint16_t al88; | |
1865 }; | |
1866 | |
1867 union al88_u color_selected; | |
1868 union al88_u color_seperator; | |
1869 int i; | |
1870 | |
1871 color_selected.al8[0] = CLUT_MenuEditLineSelected; | |
1872 color_selected.al8[1] = 0xFF; | |
1873 | |
1874 color_seperator.al8[0] = CLUT_MenuLineSelectedSeperator; | |
1875 color_seperator.al8[1] = 0xFF; | |
1876 | |
1877 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1878 *ppDestination += 2; | |
1879 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1880 *ppDestination += 2; | |
1881 | |
1882 for(i = 61; i > 0; i--) | |
1883 { | |
1884 *(__IO uint16_t*)*ppDestination = color_selected.al88; | |
1885 *ppDestination += 2; | |
1886 } | |
1887 | |
1888 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1889 *ppDestination += 2; | |
1890 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1891 *ppDestination += 2; | |
1892 } | |
1893 | |
1894 | |
1895 void draw_tMEdesignSubSelectedBorder(uint32_t *ppDestination) | |
1896 { | |
1897 union al88_u | |
1898 { | |
1899 uint8_t al8[2]; | |
1900 uint16_t al88; | |
1901 }; | |
1902 | |
1903 union al88_u color_selected_sides; | |
1904 | |
1905 int i; | |
1906 | |
1907 color_selected_sides.al8[0] = CLUT_MenuLineSelectedSides; | |
1908 color_selected_sides.al8[1] = 0xFF; | |
1909 | |
1910 for(i = 65; i > 0; i--) | |
1911 { | |
1912 *(__IO uint16_t*)*ppDestination = color_selected_sides.al88; | |
1913 *ppDestination += 2; | |
1914 } | |
1915 } | |
1916 | |
1917 | |
1918 void draw_tMEcursorNewDesign(void) | |
1919 { | |
1920 int i,j; | |
1921 uint32_t pDestination; | |
1922 | |
1923 pDestination = tMEcursorNew.FBStartAdress; | |
1924 | |
1925 for(j = 801; j > 0; j--) | |
1926 { | |
1927 for(i = 5; i > 0; i--) | |
1928 { | |
1929 draw_tMEdesignSubUnselected(&pDestination); | |
1930 } | |
1931 if((j > 787) || (j < 17)) | |
1932 draw_tMEdesignSubSelectedBorder(&pDestination); | |
1933 else | |
1934 draw_tMEdesignSubSelected(&pDestination); | |
1935 } | |
1936 } |