comparison Discovery/Src/tMenuEdit.c @ 981:c6c781a2e85b default

Merge into default
author heinrichsweikamp
date Tue, 11 Feb 2025 18:12:00 +0100
parents e9c37071933b
children ac25c35a3c97
comparison
equal deleted inserted replaced
871:f7318457df4d 981:c6c781a2e85b
34 #include "externLogbookFlash.h" 34 #include "externLogbookFlash.h"
35 #include "gfx_fonts.h" 35 #include "gfx_fonts.h"
36 #include "tHome.h" 36 #include "tHome.h"
37 #include "tInfoCompass.h" 37 #include "tInfoCompass.h"
38 #include "tInfoSensor.h" 38 #include "tInfoSensor.h"
39 #include "tInfoPreDive.h"
39 #include "tMenuEditHardware.h" 40 #include "tMenuEditHardware.h"
40 #include "tMenuEditPlanner.h" 41 #include "tMenuEditPlanner.h"
41 #include "tMenuEditSystem.h" 42 #include "tMenuEditSystem.h"
42 #include "tMenuEditXtra.h" 43 #include "tMenuEditXtra.h"
43 #include "tMenuEditCustom.h" 44 #include "tMenuEditCustom.h"
94 95
95 static uint32_t menuID; 96 static uint32_t menuID;
96 static uint8_t menuColor; 97 static uint8_t menuColor;
97 98
98 static int8_t id = 0; 99 static int8_t id = 0;
100 static int8_t actualId = 0;
99 static int8_t idLast = -1; 101 static int8_t idLast = -1;
100 static SEditIdent ident[10]; 102 static SEditIdent ident[10];
101 static int8_t tME_stop = 0; 103 static int8_t tME_stop = 0;
102 104
103 static int8_t evid = 0; 105 static int8_t evid = 0;
106 static int8_t actualevid = 0;
104 static int8_t evidLast = -1; 107 static int8_t evidLast = -1;
105 static SEventHandler event[10]; 108 static SEventHandler event[10];
106 109
107 static SBackMenuHandler backmenu; 110 static SBackMenuHandler backmenu;
108 111
113 static _Bool EnterPressed = 0; 116 static _Bool EnterPressed = 0;
114 117
115 static _Bool WriteSettings = 0; 118 static _Bool WriteSettings = 0;
116 119
117 /* Private function prototypes -----------------------------------------------*/ 120 /* Private function prototypes -----------------------------------------------*/
121 static void create_newText_for_Id(int8_t localId);
122 void clean_content_of_Id(int8_t localId);
123 static void write_content_of_Id(int8_t localId);
124
118 void draw_tMEdesign(void); 125 void draw_tMEdesign(void);
119 void set_cursorNew(uint8_t forThisIdentID); 126 void set_cursorNew(uint8_t forThisIdentID);
120 void startMenuEditFieldSelect(void); 127 void startMenuEditFieldSelect(void);
121 void create_newText_for_actual_Id(void); 128 void create_newText_for_actual_Id(void);
122 void write_content_of_actual_Id(void); 129 void write_content_of_actual_Id(void);
153 void stop_cursor_fields(void) 160 void stop_cursor_fields(void)
154 { 161 {
155 tME_stop = 1; 162 tME_stop = 1;
156 } 163 }
157 164
158 void resetMenuEdit(uint8_t color) 165 void resetMenuContentStructure()
159 { 166 {
160 id = 0; 167 id = 0;
161 idLast = -1; 168 idLast = -1;
162 evid = 0; 169 evid = 0;
170 evidLast = -1;
171 }
172
173 void resetMenuEdit(uint8_t color)
174 {
175 id = 0;
176 actualId = 0;
177 idLast = -1;
178 evid = 0;
179 actualevid = 0;
163 evidLast = -1; 180 evidLast = -1;
164 tME_stop = 0; 181 tME_stop = 0;
165 EnterPressed = 0; 182 EnterPressed = 0;
166 EnterPressedBeforeButtonAction = 0; 183 EnterPressedBeforeButtonAction = 0;
167 184
182 */ 199 */
183 menuID = get_globalState(); 200 menuID = get_globalState();
184 201
185 menuColor = color; 202 menuColor = color;
186 203
187 // draw_tMEdesign(); 204 /* set cursor to first line */
188 // GFX_SetFramesTopBottom(tMEscreen.FBStartAdress, tMEcursor.FBStartAdress,480);
189 uint8_t line = 1; 205 uint8_t line = 1;
190 // GFX_SetFramesTopBottom(tMEscreen.FBStartAdress, (tMEcursorNew.FBStartAdress) + 65*2*(line - 1),390);
191 GFX_SetFrameTop(tMEscreen.FBStartAdress); 206 GFX_SetFrameTop(tMEscreen.FBStartAdress);
192 if(!settingsGetPointer()->FlipDisplay) 207 if(!settingsGetPointer()->FlipDisplay)
193 { 208 {
194 GFX_SetFrameBottom((tMEcursorNew.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390); 209 GFX_SetFrameBottom((tMEcursorNew.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390);
195 } 210 }
212 case (StMHARD3_O2_Sensor1 & MaskFieldDigit): 227 case (StMHARD3_O2_Sensor1 & MaskFieldDigit):
213 case (StMHARD3_O2_Calibrate): 228 case (StMHARD3_O2_Calibrate):
214 case (StMHARD3_Sensor_Detect): 229 case (StMHARD3_Sensor_Detect):
215 case (StMHARD3_Sensor_Info): refreshFct = refresh_O2Sensors; 230 case (StMHARD3_Sensor_Info): refreshFct = refresh_O2Sensors;
216 break; 231 break;
217 case (StMHARD2_Compass_SetCourse & MaskFieldDigit): 232 case (StMHARD2_Compass & MaskFieldDigit):
218 refreshFct = refresh_CompassEdit; 233 refreshFct = refresh_CompassEdit;
219
220 break; 234 break;
221 case (StMXTRA_CompassHeading & MaskFieldDigit): 235 case (StMXTRA_CompassHeading & MaskFieldDigit):
222 refreshFct = refresh_CompassHeading; 236 refreshFct = refresh_CompassHeading;
223
224 break; 237 break;
225 case (StMXTRA_PSCR_O2_Drop & MaskFieldDigit):
226 if (settingsGetPointer()->dive_mode != DIVEMODE_PSCR) { /* workaround because PSCR mode is set dynamic */
227 refreshFct = refresh_CO2Data;
228 }
229
230 break;
231 case (StMXTRA_CO2_Sensor & MaskFieldDigit): refreshFct = refresh_CO2Data;
232 break;
233 case (StMSYS4_Info & MaskFieldDigit): refreshFct = &refresh_InformationPage; 238 case (StMSYS4_Info & MaskFieldDigit): refreshFct = &refresh_InformationPage;
234 break; 239 break;
235 case (StMPLAN5_ExitResult & MaskFieldDigit): refreshFct = refresh_PlanResult; 240 case (StMPLAN5_ExitResult & MaskFieldDigit): refreshFct = refresh_PlanResult;
236 break; 241 break;
237 case (StMHARD5_Button1 & MaskFieldDigit): // will not be executed in EditFieldMode as global state is different 242 case (StMHARD5_Button1 & MaskFieldDigit): // will not be executed in EditFieldMode as global state is different
238 refreshFct = refresh_ButtonValuesFromPIC; 243 refreshFct = refresh_ButtonValuesFromPIC;
239 break; 244 break;
245 case StMSYS1_DateTime: refreshFct = refresh_DateTime;
246 break;
240 case (StMSYS3_Units & MaskFieldDigit): refreshFct = refresh_Design; 247 case (StMSYS3_Units & MaskFieldDigit): refreshFct = refresh_Design;
241 break; 248 break;
242 case (StMCustom1_CViewTimeout & MaskFieldDigit):refreshFct = refresh_Customviews; 249 case (StMCustom1_CViewTimeout & MaskFieldDigit):refreshFct = refresh_Customviews;
243 break; 250 break;
244 case (StMCustom4_CViewSelection1 & MaskFieldDigit): 251 case (StMCustom4_CViewSelection1 & MaskFieldDigit):
247 case StMCustom3_CViewSelection3: 254 case StMCustom3_CViewSelection3:
248 case StMCustom3_CViewSelection4: 255 case StMCustom3_CViewSelection4:
249 case StMCustom3_CViewSelection5: 256 case StMCustom3_CViewSelection5:
250 case StMCustom3_CViewSelection6: refreshFct = CustomviewDivemode_refresh; 257 case StMCustom3_CViewSelection6: refreshFct = CustomviewDivemode_refresh;
251 break; 258 break;
259 #ifdef ENABLE_MOTION_CONTROL
252 case (StMCustom5_CViewPortCalib & MaskFieldDigit): 260 case (StMCustom5_CViewPortCalib & MaskFieldDigit):
253 case StMCustom5_CViewPortLayout: 261 case StMCustom5_CViewPortLayout:
254 case StMCustom5_CViewPortAmbient: refreshFct = refresh_ViewPort; 262 case StMCustom5_CViewPortAmbient: refreshFct = refresh_ViewPort;
255 break; 263 break;
264 #endif
256 default: /* no menu has been updated */ 265 default: /* no menu has been updated */
257 break; 266 break;
258 } 267 }
259 268
260 if(refreshFct != NULL) 269 if(refreshFct != NULL)
392 } 401 }
393 402
394 403
395 void startMenuEditFieldSelect(void) 404 void startMenuEditFieldSelect(void)
396 { 405 {
397 id = 0; 406 actualId = 0;
398 helperGotoMenuEditField(id); 407 helperGotoMenuEditField(actualId);
399 } 408 }
400 409
401 410
402 void nextMenuEditField(void) 411 void nextMenuEditField(void)
403 { 412 {
404 helperLeaveMenuEditField(id); 413 helperLeaveMenuEditField(actualId);
405 414
406 if(id < idLast) 415 if(actualId < idLast)
407 id++; 416 actualId++;
408 else 417 else
409 id = 0; 418 actualId = 0;
410 helperGotoMenuEditField(id); 419 helperGotoMenuEditField(actualId);
411 } 420 }
412 421
413 /* 422 /*
414 void previousMenuEditField(void) 423 void previousMenuEditField(void)
415 { 424 {
422 } 431 }
423 */ 432 */
424 433
425 _Bool inc_subBlock_or_block_of_actual_id(void) 434 _Bool inc_subBlock_or_block_of_actual_id(void)
426 { 435 {
427 if(event[evid].callerID != ident[id].callerID) 436 if(event[actualevid].callerID != ident[actualId].callerID)
428 return 0; 437 return 0;
429 438
430 if((ident[id].subtype != FIELD_3DIGIT) && (ident[id].subtype != FIELD_2DIGIT) && ((subBlockPosition + 1) < ident[id].size[block])) 439 if((ident[actualId].subtype != FIELD_3DIGIT) && (ident[actualId].subtype != FIELD_2DIGIT) && ((subBlockPosition + 1) < ident[actualId].size[block]))
431 { 440 {
432 subBlockPosition++; 441 subBlockPosition++;
433 return 1; 442 return 1;
434 } 443 }
435 444
436 if(((block + 1) < 4) && (ident[id].size[block+1] > 0)) 445 if(((block + 1) < 4) && (ident[actualId].size[block+1] > 0))
437 { 446 {
438 block++; 447 block++;
439 subBlockPosition = 0; 448 subBlockPosition = 0;
440 return 1; 449 return 1;
441 } 450 }
447 uint8_t get_newContent_of_actual_id_block_and_subBlock(uint8_t action) 456 uint8_t get_newContent_of_actual_id_block_and_subBlock(uint8_t action)
448 { 457 {
449 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); 458 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t);
450 uint8_t content; 459 uint8_t content;
451 460
452 if(event[evid].callerID != ident[id].callerID) 461 if(event[actualevid].callerID != ident[actualId].callerID)
453 return 0; 462 return 0;
454 463
455 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(event[evid].pEventFunction); 464 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(event[actualevid].pEventFunction);
456 465
457 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT)) 466 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT))
458 { 467 {
459 content = 100 * ( ident[id].newText[ident[id].begin[block] + 0] - '0'); 468 content = 100 * ( ident[actualId].newText[ident[actualId].begin[block] + 0] - '0');
460 content += 10 * ( ident[id].newText[ident[id].begin[block] + 1] - '0'); 469 content += 10 * ( ident[actualId].newText[ident[actualId].begin[block] + 1] - '0');
461 content += ident[id].newText[ident[id].begin[block] + 2]; 470 content += ident[actualId].newText[ident[actualId].begin[block] + 2];
462 } 471 }
463 else 472 else
464 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT)) 473 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT))
465 { 474 {
466 content = 10 * (ident[id].newText[ident[id].begin[block] + 0] - '0'); 475 content = 10 * (ident[actualId].newText[ident[actualId].begin[block] + 0] - '0');
467 content += ident[id].newText[ident[id].begin[block] + 1]; 476 content += ident[actualId].newText[ident[actualId].begin[block] + 1];
468 } 477 }
469 else 478 else
470 if(ident[id].maintype == FIELD_NUMBERS) 479 if(ident[actualId].maintype == FIELD_NUMBERS)
471 content = ident[id].newText[ident[id].begin[block] + subBlockPosition]; 480 content = ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition];
472 else 481 else
473 if((ident[id].maintype == FIELD_ON_OFF) || (ident[id].maintype == FIELD_TOGGLE)) 482 if((ident[actualId].maintype == FIELD_ON_OFF) || (ident[actualId].maintype == FIELD_TOGGLE))
474 content = ident[id].input[block]; 483 content = ident[actualId].input[block];
475 else 484 else
476 content = 0; /* just a default for protection */ 485 content = 0; /* just a default for protection */
477 486
478 return onActionFunc(ident[id].callerID, block, subBlockPosition, content, action); 487 return onActionFunc(ident[actualId].callerID, block, subBlockPosition, content, action);
479 } 488 }
480 489
481 void mark_digit_of_actual_id_with_this_block_and_subBlock(int8_t oldblock, int8_t oldsubblockpos) 490 void mark_digit_of_actual_id_with_this_block_and_subBlock(int8_t oldblock, int8_t oldsubblockpos)
482 { 491 {
483 char oneCharText[2]; 492 char oneCharText[2];
484 uint16_t positionOffset; 493 uint16_t positionOffset;
485 494
486 if(event[evid].callerID != ident[id].callerID) 495 if(event[actualevid].callerID != ident[actualId].callerID)
487 return; 496 return;
488 497
489 if(ident[id].maintype == FIELD_NUMBERS) 498 if(ident[actualId].maintype == FIELD_NUMBERS)
490 { 499 {
491 oneCharText[0] = ident[id].newText[ident[id].begin[oldblock] + oldsubblockpos]; 500 oneCharText[0] = ident[actualId].newText[ident[actualId].begin[oldblock] + oldsubblockpos];
492 oneCharText[1] = 0; 501 oneCharText[1] = 0;
493 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[oldblock] + oldsubblockpos); 502 positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[oldblock] + oldsubblockpos);
494 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditFieldSelected); 503 write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditFieldSelected);
495 } 504 }
496 } 505 }
497 506
498 507
499 void mark_new_2digit_of_actual_id_block(void) 508 void mark_new_2digit_of_actual_id_block(void)
500 { 509 {
501 char oneCharText[3]; 510 char oneCharText[3];
502 uint16_t positionOffset; 511 uint16_t positionOffset;
503 512
504 if(event[evid].callerID != ident[id].callerID) 513 if(event[actualevid].callerID != ident[actualId].callerID)
505 return; 514 return;
506 515
507 if(ident[id].maintype == FIELD_NUMBERS) 516 if(ident[actualId].maintype == FIELD_NUMBERS)
508 { 517 {
509 oneCharText[0] = ident[id].newText[ident[id].begin[block] + 0]; 518 oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + 0];
510 oneCharText[1] = ident[id].newText[ident[id].begin[block] + 1]; 519 oneCharText[1] = ident[actualId].newText[ident[actualId].begin[block] + 1];
511 oneCharText[2] = 0; 520 oneCharText[2] = 0;
512 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + 0); 521 positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].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); 522 write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit);
514 } 523 }
515 } 524 }
516 525
517 526
518 void mark_new_3digit_of_actual_id_block(void) 527 void mark_new_3digit_of_actual_id_block(void)
519 { 528 {
520 char oneCharText[4]; 529 char oneCharText[4];
521 uint16_t positionOffset; 530 uint16_t positionOffset;
522 531
523 if(event[evid].callerID != ident[id].callerID) 532 if(event[actualevid].callerID != ident[actualId].callerID)
524 return; 533 return;
525 534
526 if(ident[id].maintype == FIELD_NUMBERS) 535 if(ident[actualId].maintype == FIELD_NUMBERS)
527 { 536 {
528 oneCharText[0] = ident[id].newText[ident[id].begin[block] + 0]; 537 oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + 0];
529 oneCharText[1] = ident[id].newText[ident[id].begin[block] + 1]; 538 oneCharText[1] = ident[actualId].newText[ident[actualId].begin[block] + 1];
530 oneCharText[2] = ident[id].newText[ident[id].begin[block] + 2]; 539 oneCharText[2] = ident[actualId].newText[ident[actualId].begin[block] + 2];
531 oneCharText[3] = 0; 540 oneCharText[3] = 0;
532 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + 0); 541 positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block] + 0);
533 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); 542 write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit);
534 } 543 }
535 } 544 }
536 545
537 546
538 void mark_new_digit_of_actual_id_block_and_subBlock(void) 547 void mark_new_digit_of_actual_id_block_and_subBlock(void)
539 { 548 {
540 char oneCharText[2]; 549 char oneCharText[2];
541 uint16_t positionOffset; 550 uint16_t positionOffset;
542 551
543 if(event[evid].callerID != ident[id].callerID) 552 if(event[actualevid].callerID != ident[actualId].callerID)
544 return; 553 return;
545 554
546 if(ident[id].maintype == FIELD_NUMBERS) 555 if(ident[actualId].maintype == FIELD_NUMBERS)
547 { 556 {
548 oneCharText[0] = ident[id].newText[ident[id].begin[block] + subBlockPosition]; 557 oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition];
549 oneCharText[1] = 0; 558 oneCharText[1] = 0;
550 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + subBlockPosition); 559 positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block] + subBlockPosition);
551 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); 560 write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit);
552 } 561 }
553 } 562 }
554 563
555 564
556 void enterMenuEditField(void) 565 void enterMenuEditField(void)
558 uint8_t newContent; 567 uint8_t newContent;
559 uint8_t digit100; 568 uint8_t digit100;
560 uint8_t digit10; 569 uint8_t digit10;
561 uint8_t digit1; 570 uint8_t digit1;
562 571
563 evid = 0; 572 actualevid = 0;
564 while((evid < evidLast) && (event[evid].callerID != ident[id].callerID)) 573 while((actualevid < evidLast) && (event[actualevid].callerID != ident[actualId].callerID))
565 { 574 {
566 evid++; 575 actualevid++;
567 } 576 }
568 577
569 if(event[evid].callerID != ident[id].callerID) 578 if(event[actualevid].callerID != ident[actualId].callerID)
570 return; 579 return;
571 580
572 set_globalState(event[evid].callerID); 581 set_globalState(event[actualevid].callerID);
573 block = 0; 582 block = 0;
574 subBlockPosition = 0; 583 subBlockPosition = 0;
575 584
576 if(ident[id].maintype == FIELD_NUMBERS) 585 if(ident[actualId].maintype == FIELD_NUMBERS)
577 { 586 {
578 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); 587 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor);
579 // old stuff? hw 150916, reactivated 150923, this shows which digit will be changed now as it marks the other grey/black 588 // old stuff? hw 150916, reactivated 150923, this shows which digit will be changed now as it marks the other grey/black
580 // now fixed for button settings with newContent <= '0'+99 condition 589 // now fixed for button settings with newContent <= '0'+99 condition
581 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldSelected); 590 change_CLUT_entry((CLUT_MenuEditField0 + actualId), CLUT_MenuEditFieldSelected);
582 } 591 }
583 if(ident[id].maintype == FIELD_TOGGLE) 592 if(ident[actualId].maintype == FIELD_TOGGLE)
584 { 593 {
585 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); 594 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor);
586 } 595 }
587 596
588 597
621 { 630 {
622 exitMenuEdit_to_InfoSensor(); 631 exitMenuEdit_to_InfoSensor();
623 return; 632 return;
624 } 633 }
625 634
626 switch(ident[id].maintype) 635 switch(ident[actualId].maintype)
627 { 636 {
628 case FIELD_NUMBERS: 637 case FIELD_NUMBERS:
629 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); 638 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus);
630 639
631 switch (ident[id].subtype) { 640 switch (ident[actualId].subtype) {
632 case FIELD_UDIGIT: 641 case FIELD_UDIGIT:
633 if((newContent >= '0') && (newContent <= '9')) 642 if((newContent >= '0') && (newContent <= '9'))
634 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; 643 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
635 644
636 mark_new_digit_of_actual_id_block_and_subBlock(); 645 mark_new_digit_of_actual_id_block_and_subBlock();
637 646
638 break; 647 break;
639 case FIELD_3DIGIT: 648 case FIELD_3DIGIT:
640 if((newContent >= '0') && (newContent <= '0'+200)) 649 if((newContent >= '0') && (newContent <= '0'+200))
641 { 650 {
642 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); 651 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1);
643 ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; 652 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + digit100;
644 ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; 653 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + digit10;
645 ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; 654 ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + digit1;
646 mark_new_3digit_of_actual_id_block(); 655 mark_new_3digit_of_actual_id_block();
647 } 656 }
648 657
649 break; 658 break;
650 case FIELD_2DIGIT: 659 case FIELD_2DIGIT:
651 if((newContent >= '0') && (newContent <= '0'+99)) 660 if((newContent >= '0') && (newContent <= '0'+99))
652 { 661 {
653 ident[id].newText[ident[id].begin[block]] = '0' + (newContent - '0')/10; 662 ident[actualId].newText[ident[actualId].begin[block]] = '0' + (newContent - '0')/10;
654 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); 663 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
655 mark_new_2digit_of_actual_id_block(); 664 mark_new_2digit_of_actual_id_block();
656 } 665 }
657 666
658 break; 667 break;
659 case FIELD_SDIGIT: 668 case FIELD_SDIGIT:
660 if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) { 669 if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) {
661 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; 670 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
662 } 671 }
663 672
664 mark_new_digit_of_actual_id_block_and_subBlock(); 673 mark_new_digit_of_actual_id_block_and_subBlock();
665 674
666 break; 675 break;
670 case FIELD_ON_OFF: 679 case FIELD_ON_OFF:
671 set_globalState(menuID); 680 set_globalState(menuID);
672 681
673 break; 682 break;
674 case FIELD_SYMBOL: 683 case FIELD_SYMBOL:
675 ident[id].input[0] += 1; 684 ident[actualId].input[0] += 1;
676 if(ident[id].input[0] >= ident[id].input[1]) 685 if(ident[actualId].input[0] >= ident[actualId].input[1])
677 ident[id].input[0] = 0; 686 ident[actualId].input[0] = 0;
678 ident[id].newText[0] = ident[id].orgText[ident[id].input[0]]; 687 ident[actualId].newText[0] = ident[actualId].orgText[ident[actualId].input[0]];
679 write_content_of_actual_Id(); 688 write_content_of_actual_Id();
680 set_globalState(menuID); 689 set_globalState(menuID);
681 break; 690 break;
682 case FIELD_SELECT: 691 case FIELD_SELECT:
683 write_buttonTextline(TXT2BYTE_ButtonMinus, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonPlus); 692 write_buttonTextline(TXT2BYTE_ButtonMinus, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonPlus);
691 { 700 {
692 uint8_t newContent; 701 uint8_t newContent;
693 702
694 set_globalState(menuID); 703 set_globalState(menuID);
695 704
696 if(event[evid].callerID != ident[id].callerID) 705 if(event[actualevid].callerID != ident[actualId].callerID)
697 return; 706 return;
698 707
699 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_TIMEOUT); 708 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_TIMEOUT);
700 709
701 /* 710 /*
742 uint8_t action; 751 uint8_t action;
743 uint8_t newContent; 752 uint8_t newContent;
744 int8_t blockOld = 0; 753 int8_t blockOld = 0;
745 int8_t subBlockPositionOld = 0; 754 int8_t subBlockPositionOld = 0;
746 755
747 if(event[evid].callerID != ident[id].callerID) 756 if(event[actualevid].callerID != ident[actualId].callerID)
748 return; 757 return;
749 758
750 blockOld = block; 759 blockOld = block;
751 subBlockPositionOld = subBlockPosition; 760 subBlockPositionOld = subBlockPosition;
752 761
785 794
786 return; 795 return;
787 } 796 }
788 } 797 }
789 798
790 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) 799 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99))
791 { 800 {
792 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/100; 801 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/100;
793 ident[id].newText[ident[id].begin[block] + 1] = '0' + (newContent - '0')/10; 802 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + (newContent - '0')/10;
794 ident[id].newText[ident[id].begin[block] + 2] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); 803 ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
795 } 804 }
796 else 805 else
797 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) 806 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99))
798 { 807 {
799 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; 808 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/10;
800 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); 809 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
801 } else if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT && action == ACTION_BUTTON_ENTER && subBlockPosition == 0) { 810 } else if (ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT && action == ACTION_BUTTON_ENTER && subBlockPosition == 0) {
802 if (newContent == '+' || newContent == '-') { 811 if (newContent == '+' || newContent == '-') {
803 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; 812 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
804 } 813 }
805 } 814 }
806 else 815 else
807 if((ident[id].maintype == FIELD_NUMBERS) && (action == ACTION_BUTTON_ENTER) && (newContent >= '0') && (newContent <= '9')) 816 if((ident[actualId].maintype == FIELD_NUMBERS) && (action == ACTION_BUTTON_ENTER) && (newContent >= '0') && (newContent <= '9'))
808 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; 817 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
809 818
810 if(action == ACTION_BUTTON_ENTER) 819 if(action == ACTION_BUTTON_ENTER)
811 { 820 {
812 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT)) 821 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT))
813 { 822 {
814 mark_new_3digit_of_actual_id_block(); 823 mark_new_3digit_of_actual_id_block();
815 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0); 824 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0);
816 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,1); 825 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,1);
817 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,2); 826 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,2);
818 } 827 }
819 else 828 else
820 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT)) 829 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT))
821 { 830 {
822 mark_new_2digit_of_actual_id_block(); 831 mark_new_2digit_of_actual_id_block();
823 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0); 832 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0);
824 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,1); 833 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,1);
825 } 834 }
859 868
860 869
861 static void checkUpdateSDigit(uint8_t newContent) 870 static void checkUpdateSDigit(uint8_t newContent)
862 { 871 {
863 if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) { 872 if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) {
864 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; 873 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
865 } 874 }
866 } 875 }
867 876
868 877
869 void upMenuEditFieldDigit(void) 878 void upMenuEditFieldDigit(void)
871 uint8_t newContent; 880 uint8_t newContent;
872 uint8_t digit100; 881 uint8_t digit100;
873 uint8_t digit10; 882 uint8_t digit10;
874 uint8_t digit1; 883 uint8_t digit1;
875 884
876 if(event[evid].callerID != ident[id].callerID) 885 if(event[actualevid].callerID != ident[actualId].callerID)
877 return; 886 return;
878 887
879 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_NEXT); 888 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_NEXT);
880 889
881 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) 890 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200))
882 { 891 {
883 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); 892 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1);
884 ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; 893 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + digit100;
885 ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; 894 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + digit10;
886 ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; 895 ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + digit1;
887 mark_new_3digit_of_actual_id_block(); 896 mark_new_3digit_of_actual_id_block();
888 return; 897 return;
889 } 898 }
890 899
891 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) 900 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99))
892 { 901 {
893 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; 902 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/10;
894 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); 903 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
895 mark_new_2digit_of_actual_id_block(); 904 mark_new_2digit_of_actual_id_block();
896 return; 905 return;
897 } 906 }
898 907
899 if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT) { 908 if (ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT) {
900 checkUpdateSDigit(newContent); 909 checkUpdateSDigit(newContent);
901 } else if (ident[id].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { 910 } else if (ident[actualId].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') {
902 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; 911 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
903 } 912 }
904 913
905 mark_new_digit_of_actual_id_block_and_subBlock(); 914 mark_new_digit_of_actual_id_block_and_subBlock();
906 } 915 }
907 916
911 uint8_t newContent; 920 uint8_t newContent;
912 uint8_t digit100; 921 uint8_t digit100;
913 uint8_t digit10; 922 uint8_t digit10;
914 uint8_t digit1; 923 uint8_t digit1;
915 924
916 if(event[evid].callerID != ident[id].callerID) 925 if(event[actualevid].callerID != ident[actualId].callerID)
917 return; 926 return;
918 927
919 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_BACK); 928 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_BACK);
920 929
921 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) 930 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200))
922 { 931 {
923 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); 932 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1);
924 ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; 933 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + digit100;
925 ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; 934 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + digit10;
926 ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; 935 ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + digit1;
927 mark_new_3digit_of_actual_id_block(); 936 mark_new_3digit_of_actual_id_block();
928 return; 937 return;
929 } 938 }
930 939
931 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) 940 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99))
932 { 941 {
933 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; 942 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/10;
934 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); 943 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
935 mark_new_2digit_of_actual_id_block(); 944 mark_new_2digit_of_actual_id_block();
936 return; 945 return;
937 } 946 }
938 947
939 if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT) { 948 if (ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT) {
940 checkUpdateSDigit(newContent); 949 checkUpdateSDigit(newContent);
941 } else if (ident[id].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { 950 } else if (ident[actualId].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') {
942 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; 951 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
943 } 952 }
944 953
945 mark_new_digit_of_actual_id_block_and_subBlock(); 954 mark_new_digit_of_actual_id_block_and_subBlock();
946 } 955 }
947 956
948 957
949 void evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4) 958 void evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4)
950 { 959 {
951 if(editID != ident[id].callerID) 960 if(editID != ident[actualId].callerID)
952 return; 961 return;
953 962
954 bool isSigned = ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT; 963 bool isSigned = ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT;
955 964
956 uint8_t i, digitCount, digit; 965 uint8_t i, digitCount, digit;
957 uint32_t sum[4], multiplier; 966 uint32_t sum[4], multiplier;
958 967
959 for(i=0;i<4;i++) 968 for(i=0;i<4;i++)
960 sum[i] = 0; 969 sum[i] = 0;
961 970
962 i = 0; 971 i = 0;
963 while( ident[id].size[i] && (i < 4)) 972 while( ident[actualId].size[i] && (i < 4))
964 { 973 {
965 multiplier = 1; 974 multiplier = 1;
966 for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++) 975 for(digitCount = 1; digitCount < ident[actualId].size[i]; digitCount++)
967 multiplier *= 10; 976 multiplier *= 10;
968 977
969 bool isNegative = false; 978 bool isNegative = false;
970 for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++) 979 for(digitCount = 0; digitCount < ident[actualId].size[i]; digitCount++)
971 { 980 {
972 digit = ident[id].newText[ident[id].begin[i] + digitCount]; 981 digit = ident[actualId].newText[ident[actualId].begin[i] + digitCount];
973 982
974 if (isSigned && digitCount == 0) { 983 if (isSigned && digitCount == 0) {
975 if (digit == '-') { 984 if (digit == '-') {
976 isNegative = true; 985 isNegative = true;
977 } 986 }
1013 1022
1014 uint8_t get_id_of(uint32_t editID) 1023 uint8_t get_id_of(uint32_t editID)
1015 { 1024 {
1016 uint8_t temp_id; 1025 uint8_t temp_id;
1017 1026
1018 if(editID == ident[id].callerID) 1027 if(editID == ident[actualId].callerID)
1019 return id; 1028 return actualId;
1020 else 1029 else
1021 { 1030 {
1022 temp_id = 0; 1031 temp_id = 0;
1023 while((temp_id < 9) && (editID != ident[temp_id].callerID)) 1032 while((temp_id < 9) && (editID != ident[temp_id].callerID))
1024 temp_id++; 1033 temp_id++;
1041 id = temp_id; 1050 id = temp_id;
1042 1051
1043 strncpy(ident[id].newText, text, 32); 1052 strncpy(ident[id].newText, text, 32);
1044 ident[id].newText[31] = 0; 1053 ident[id].newText[31] = 0;
1045 1054
1046 clean_content_of_actual_Id(); 1055 clean_content_of_Id(id);
1047 write_content_of_actual_Id(); 1056 write_content_of_Id(id);
1048 1057
1049 id = backup_id; 1058 id = backup_id;
1050 } 1059 }
1051 1060
1052 1061
1066 if(int1) 1075 if(int1)
1067 ident[id].newText[0] = '\005'; 1076 ident[id].newText[0] = '\005';
1068 else 1077 else
1069 ident[id].newText[0] = '\006'; 1078 ident[id].newText[0] = '\006';
1070 1079
1071 clean_content_of_actual_Id(); 1080 clean_content_of_Id(id);
1072 write_content_of_actual_Id(); 1081 write_content_of_Id(id);
1073 1082
1074 id = backup_id; 1083 id = backup_id;
1075 } 1084 }
1076 1085
1077 void tMenuEdit_select(uint32_t editID) 1086 void tMenuEdit_select(uint32_t editID)
1079 uint8_t id_local = 0; 1088 uint8_t id_local = 0;
1080 id_local = get_id_of(editID); 1089 id_local = get_id_of(editID);
1081 1090
1082 if(id_local <= idLast) 1091 if(id_local <= idLast)
1083 { 1092 {
1084 id = id_local; 1093 actualId = id_local;
1085 set_cursorNew(id); 1094 set_cursorNew(id_local);
1086 } 1095 }
1087 } 1096 }
1088 1097
1089 #if OLD_SELECTION 1098 #if OLD_SELECTION
1090 void tMenuEdit_select(uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) 1099 void tMenuEdit_select(uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4)
1138 ident[id].input[0] = int1; 1147 ident[id].input[0] = int1;
1139 ident[id].input[1] = int2; 1148 ident[id].input[1] = int2;
1140 ident[id].input[2] = int3; 1149 ident[id].input[2] = int3;
1141 ident[id].input[3] = int4; 1150 ident[id].input[3] = int4;
1142 1151
1143 create_newText_for_actual_Id(); 1152 create_newText_for_Id(id);
1144 if(id <= idLast) 1153 if(id <= idLast)
1145 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); 1154 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular);
1146 write_content_of_actual_Id(); 1155 write_content_of_Id(id);
1147 1156
1148 id = backup_id; 1157 id = backup_id;
1149 } 1158 }
1150 1159
1151 1160
1183 break; 1192 break;
1184 1193
1185 } 1194 }
1186 } 1195 }
1187 else 1196 else
1188 if(get_globalState() == event[evid].callerID) 1197 if(get_globalState() == event[actualevid].callerID)
1189 { 1198 {
1190 switch(sendAction) 1199 switch(sendAction)
1191 { 1200 {
1192 case ACTION_BUTTON_ENTER: 1201 case ACTION_BUTTON_ENTER:
1193 nextMenuEditFieldDigit(); 1202 nextMenuEditFieldDigit();
1231 } 1240 }
1232 } 1241 }
1233 } 1242 }
1234 1243
1235 1244
1245 void create_newText_for_Id_and_field_select(int8_t localId)
1246 {
1247 uint8_t i;
1248
1249 i = 0;
1250 while( ident[localId].size[i] && (i < 4))
1251 {
1252 if(ident[localId].input[i])
1253 ident[localId].newText[ident[localId].begin[i]] = '\005';
1254 else
1255 ident[localId].newText[ident[localId].begin[i]] = '\006';
1256 i++;
1257 }
1258 }
1259
1236 void create_newText_for_actual_Id_and_field_select(void) 1260 void create_newText_for_actual_Id_and_field_select(void)
1237 { 1261 {
1238 uint8_t i; 1262 create_newText_for_Id_and_field_select(actualId);
1239 1263 }
1240 i = 0; 1264
1241 while( ident[id].size[i] && (i < 4)) 1265 void create_newText_for_Id(int8_t localId)
1242 { 1266 {
1243 if(ident[id].input[i]) 1267 bool isSigned = ident[localId].maintype == FIELD_NUMBERS && ident[localId].subtype == FIELD_SDIGIT;
1244 ident[id].newText[ident[id].begin[i]] = '\005'; 1268
1245 else 1269 uint8_t i, digitCount;
1246 ident[id].newText[ident[id].begin[i]] = '\006'; 1270 uint32_t remainder, digit, divider;
1247 i++; 1271 i = 0;
1248 } 1272
1249 } 1273 if( ident[localId].maintype == FIELD_SELECT)
1250 1274 {
1275 create_newText_for_Id_and_field_select(localId);
1276 return;
1277 }
1278
1279 while( ident[localId].size[i] && (i < 4))
1280 {
1281 bool isNegative = false;
1282 if (isSigned) {
1283 int32_t value = ((input_u)ident[localId].input[i]).int32;
1284 if (value < 0) {
1285 isNegative = true;
1286 }
1287 remainder = abs(value);
1288 } else {
1289 remainder = ident[localId].input[i];
1290 }
1291 divider = 1;
1292
1293 for(digitCount = 1; digitCount < ident[localId].size[i]; digitCount++)
1294 divider *= 10;
1295
1296 for(digitCount = 0; digitCount < ident[localId].size[i]; digitCount++)
1297 {
1298 if (isSigned && digitCount == 0) {
1299 ident[localId].newText[ident[localId].begin[i] + digitCount] = isNegative ? '-' : '+';
1300 } else {
1301 digit = remainder / divider;
1302 remainder -= digit * divider;
1303 if(digit < 10)
1304 ident[localId].newText[ident[localId].begin[i] + digitCount] = digit + '0';
1305 else
1306 ident[localId].newText[ident[localId].begin[i] + digitCount] = 'x';
1307 }
1308
1309 divider /= 10;
1310 }
1311 i++;
1312 }
1313 }
1251 1314
1252 void create_newText_for_actual_Id(void) 1315 void create_newText_for_actual_Id(void)
1253 { 1316 {
1254 if( ident[id].maintype == FIELD_SELECT) 1317 create_newText_for_Id(actualId);
1255 {
1256 create_newText_for_actual_Id_and_field_select();
1257 return;
1258 }
1259
1260 bool isSigned = ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT;
1261
1262 uint8_t i, digitCount;
1263 uint32_t remainder, digit, divider;
1264
1265 i = 0;
1266 while( ident[id].size[i] && (i < 4))
1267 {
1268 bool isNegative = false;
1269 if (isSigned) {
1270 int32_t value = ((input_u)ident[id].input[i]).int32;
1271 if (value < 0) {
1272 isNegative = true;
1273 }
1274 remainder = abs(value);
1275 } else {
1276 remainder = ident[id].input[i];
1277 }
1278 divider = 1;
1279
1280 for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++)
1281 divider *= 10;
1282
1283 for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++)
1284 {
1285 if (isSigned && digitCount == 0) {
1286 ident[id].newText[ident[id].begin[i] + digitCount] = isNegative ? '-' : '+';
1287 } else {
1288 digit = remainder / divider;
1289 remainder -= digit * divider;
1290 if(digit < 10)
1291 ident[id].newText[ident[id].begin[i] + digitCount] = digit + '0';
1292 else
1293 ident[id].newText[ident[id].begin[i] + digitCount] = 'x';
1294 }
1295
1296 divider /= 10;
1297 }
1298 i++;
1299 }
1300 } 1318 }
1301 1319
1302 1320
1303 void write_content_without_Id(void) 1321 void write_content_without_Id(void)
1304 { 1322 {
1305 write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, CLUT_MenuEditFieldRegular); 1323 write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, CLUT_MenuEditFieldRegular);
1306 } 1324 }
1307 1325
1308 1326
1327 void write_content_of_Id(int8_t localId)
1328 {
1329 write_content( ident[localId].coord[0], ident[localId].coord[1], ident[localId].coord[2], ident[localId].fontUsed, ident[localId].newText, (CLUT_MenuEditField0 + localId));
1330 }
1309 void write_content_of_actual_Id(void) 1331 void write_content_of_actual_Id(void)
1310 { 1332 {
1311 write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, (CLUT_MenuEditField0 + id)); 1333 write_content_of_Id(actualId);
1312 } 1334 }
1313 1335
1336 void clean_content_of_Id(int8_t localId)
1337 {
1338 clean_content( ident[localId].coord[0], ident[localId].coord[1], ident[localId].coord[2], ident[localId].fontUsed);
1339 }
1314 1340
1315 void clean_content_of_actual_Id(void) 1341 void clean_content_of_actual_Id(void)
1316 { 1342 {
1317 clean_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed); 1343 clean_content_of_Id(actualId);
1318 } 1344 }
1319 1345
1346 uint8_t togglePlusMinus(uint8_t input)
1347 {
1348 if (input == '+') {
1349 return '-';
1350 } else {
1351 return '+';
1352 }
1353 }
1320 1354
1321 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) 1355 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)
1322 { 1356 {
1323 if(id >= 9) 1357 if(id >= 9)
1324 return; 1358 return;
1373 if(!tME_stop) 1407 if(!tME_stop)
1374 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); 1408 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular);
1375 else 1409 else
1376 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditInfo); 1410 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditInfo);
1377 1411
1378 create_newText_for_actual_Id(); 1412 create_newText_for_Id(id);
1379 1413
1380 if(editID == 0) 1414 if(editID == 0)
1381 write_content_without_Id(); 1415 write_content_without_Id();
1382 else 1416 else
1383 { 1417 {
1384 write_content_of_actual_Id(); 1418 write_content_of_Id(id);
1385 if(!tME_stop) 1419 if(!tME_stop)
1386 idLast = id; 1420 idLast = id;
1387 id++; 1421 id++;
1388 } 1422 }
1389 } 1423 }
1456 break; 1490 break;
1457 } 1491 }
1458 1492
1459 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); 1493 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular);
1460 1494
1461 create_newText_for_actual_Id(); 1495 create_newText_for_Id(id);
1462 1496
1463 if(editID == 0) 1497 if(editID == 0)
1464 write_content_without_Id(); 1498 write_content_without_Id();
1465 else 1499 else
1466 { 1500 {
1467 write_content_of_actual_Id(); 1501 write_content_of_Id(id);
1468 if(!tME_stop) 1502 if(!tME_stop)
1469 idLast = id; 1503 idLast = id;
1470 id++; 1504 id++;
1471 } 1505 }
1472 } 1506 }
1494 1528
1495 if(editID == 0) 1529 if(editID == 0)
1496 write_content_without_Id(); 1530 write_content_without_Id();
1497 else 1531 else
1498 { 1532 {
1499 write_content_of_actual_Id(); 1533 write_content_of_Id(id);
1500 if(!tME_stop) 1534 if(!tME_stop)
1501 idLast = id; 1535 idLast = id;
1502 id++; 1536 id++;
1503 } 1537 }
1504 } 1538 }
1532 1566
1533 if(editID == 0) 1567 if(editID == 0)
1534 write_content_without_Id(); 1568 write_content_without_Id();
1535 else 1569 else
1536 { 1570 {
1537 write_content_of_actual_Id(); 1571 write_content_of_Id(id);
1538 if(!tME_stop) 1572 if(!tME_stop)
1539 idLast = id; 1573 idLast = id;
1540 id++; 1574 id++;
1541 } 1575 }
1542 } 1576 }
1558 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditButtonColor1); 1592 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditButtonColor1);
1559 1593
1560 if(editID == 0) write_content_without_Id(); 1594 if(editID == 0) write_content_without_Id();
1561 else 1595 else
1562 { 1596 {
1563 write_content_of_actual_Id(); 1597 write_content_of_Id(id);
1564 if(!tME_stop) idLast = id; 1598 if(!tME_stop) idLast = id;
1565 id++; 1599 id++;
1566 } 1600 }
1567 } 1601 }
1568 1602
1617 1651
1618 if(editID == 0) 1652 if(editID == 0)
1619 write_content_without_Id(); 1653 write_content_without_Id();
1620 else 1654 else
1621 { 1655 {
1622 write_content_of_actual_Id(); 1656 write_content_of_Id(id);
1623 if(!tME_stop) 1657 if(!tME_stop)
1624 idLast = id; 1658 idLast = id;
1625 id++; 1659 id++;
1626 } 1660 }
1627 } 1661 }
1650 1684
1651 if(editID == 0) 1685 if(editID == 0)
1652 write_content_without_Id(); 1686 write_content_without_Id();
1653 else 1687 else
1654 { 1688 {
1655 write_content_of_actual_Id(); 1689 write_content_of_Id(id);
1656 if(!tME_stop) 1690 if(!tME_stop)
1657 idLast = id; 1691 idLast = id;
1658 id++; 1692 id++;
1659 } 1693 }
1660 } 1694 }
1671 void setEvent(uint32_t inputEventID, uint32_t inputFunctionCall) 1705 void setEvent(uint32_t inputEventID, uint32_t inputFunctionCall)
1672 { 1706 {
1673 if(evidLast >= 9) 1707 if(evidLast >= 9)
1674 return; 1708 return;
1675 1709
1710 #if 0
1676 /* set cursor to first field */ 1711 /* set cursor to first field */
1677 if(evidLast < 0) 1712 if(evidLast < 0)
1678 { 1713 {
1679 startMenuEditFieldSelect(); 1714 startMenuEditFieldSelect();
1680 } 1715 }
1681 1716 #endif
1682 event[evid].callerID = inputEventID; 1717 event[evid].callerID = inputEventID;
1683 event[evid].pEventFunction = inputFunctionCall; 1718 event[evid].pEventFunction = inputFunctionCall;
1684 1719
1685 evidLast = evid; 1720 evidLast = evid;
1686 evid++; 1721 evid++;