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