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