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