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