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