Mercurial > public > ostc4
comparison Discovery/Src/tMenuEdit.c @ 853:de6023cc0580 Evo_2_23
Potential Bugfix Selection MenuEdit lifecycle:
The "id" as well as the "evid" were used in two workflows. The setup of the menu structure and later in the handling of e.g. actual cursor position. In case of sructure updates while the menu was opened this lead to misbehavior in the menu handling. To avoid this in future the two usecased of the variables have been separated. The creation of the menus is still handles by "id" and "evid". The handling of the actual menu behavior is controlled by "actualId" and"actualevid"
author | Ideenmodellierer |
---|---|
date | Thu, 07 Mar 2024 21:51:18 +0100 |
parents | 17d9d6eddd8d |
children | 48b6a3b1f3f8 |
comparison
equal
deleted
inserted
replaced
852:b2aad621aeb0 | 853:de6023cc0580 |
---|---|
95 | 95 |
96 static uint32_t menuID; | 96 static uint32_t menuID; |
97 static uint8_t menuColor; | 97 static uint8_t menuColor; |
98 | 98 |
99 static int8_t id = 0; | 99 static int8_t id = 0; |
100 static int8_t actualId = 0; | |
100 static int8_t idLast = -1; | 101 static int8_t idLast = -1; |
101 static SEditIdent ident[10]; | 102 static SEditIdent ident[10]; |
102 static int8_t tME_stop = 0; | 103 static int8_t tME_stop = 0; |
103 | 104 |
104 static int8_t evid = 0; | 105 static int8_t evid = 0; |
106 static int8_t actualevid = 0; | |
105 static int8_t evidLast = -1; | 107 static int8_t evidLast = -1; |
106 static SEventHandler event[10]; | 108 static SEventHandler event[10]; |
107 | 109 |
108 static SBackMenuHandler backmenu; | 110 static SBackMenuHandler backmenu; |
109 | 111 |
154 void stop_cursor_fields(void) | 156 void stop_cursor_fields(void) |
155 { | 157 { |
156 tME_stop = 1; | 158 tME_stop = 1; |
157 } | 159 } |
158 | 160 |
159 void resetMenuEdit(uint8_t color) | 161 void resetMenuContentStructure() |
160 { | 162 { |
161 id = 0; | 163 id = 0; |
162 idLast = -1; | 164 idLast = -1; |
163 evid = 0; | 165 evid = 0; |
166 evidLast = -1; | |
167 } | |
168 | |
169 void resetMenuEdit(uint8_t color) | |
170 { | |
171 id = 0; | |
172 actualId = 0; | |
173 idLast = -1; | |
174 evid = 0; | |
175 actualevid = 0; | |
164 evidLast = -1; | 176 evidLast = -1; |
165 tME_stop = 0; | 177 tME_stop = 0; |
166 EnterPressed = 0; | 178 EnterPressed = 0; |
167 EnterPressedBeforeButtonAction = 0; | 179 EnterPressedBeforeButtonAction = 0; |
168 | 180 |
183 */ | 195 */ |
184 menuID = get_globalState(); | 196 menuID = get_globalState(); |
185 | 197 |
186 menuColor = color; | 198 menuColor = color; |
187 | 199 |
188 // draw_tMEdesign(); | 200 /* set cursor to first line */ |
189 // GFX_SetFramesTopBottom(tMEscreen.FBStartAdress, tMEcursor.FBStartAdress,480); | |
190 uint8_t line = 1; | 201 uint8_t line = 1; |
191 // GFX_SetFramesTopBottom(tMEscreen.FBStartAdress, (tMEcursorNew.FBStartAdress) + 65*2*(line - 1),390); | |
192 GFX_SetFrameTop(tMEscreen.FBStartAdress); | 202 GFX_SetFrameTop(tMEscreen.FBStartAdress); |
193 if(!settingsGetPointer()->FlipDisplay) | 203 if(!settingsGetPointer()->FlipDisplay) |
194 { | 204 { |
195 GFX_SetFrameBottom((tMEcursorNew.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390); | 205 GFX_SetFrameBottom((tMEcursorNew.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390); |
196 } | 206 } |
383 } | 393 } |
384 | 394 |
385 | 395 |
386 void startMenuEditFieldSelect(void) | 396 void startMenuEditFieldSelect(void) |
387 { | 397 { |
388 id = 0; | 398 actualId = 0; |
389 helperGotoMenuEditField(id); | 399 helperGotoMenuEditField(actualId); |
390 } | 400 } |
391 | 401 |
392 | 402 |
393 void nextMenuEditField(void) | 403 void nextMenuEditField(void) |
394 { | 404 { |
395 helperLeaveMenuEditField(id); | 405 helperLeaveMenuEditField(actualId); |
396 | 406 |
397 if(id < idLast) | 407 if(actualId < idLast) |
398 id++; | 408 actualId++; |
399 else | 409 else |
400 id = 0; | 410 actualId = 0; |
401 helperGotoMenuEditField(id); | 411 helperGotoMenuEditField(actualId); |
402 } | 412 } |
403 | 413 |
404 /* | 414 /* |
405 void previousMenuEditField(void) | 415 void previousMenuEditField(void) |
406 { | 416 { |
413 } | 423 } |
414 */ | 424 */ |
415 | 425 |
416 _Bool inc_subBlock_or_block_of_actual_id(void) | 426 _Bool inc_subBlock_or_block_of_actual_id(void) |
417 { | 427 { |
418 if(event[evid].callerID != ident[id].callerID) | 428 if(event[actualevid].callerID != ident[actualId].callerID) |
419 return 0; | 429 return 0; |
420 | 430 |
421 if((ident[id].subtype != FIELD_3DIGIT) && (ident[id].subtype != FIELD_2DIGIT) && ((subBlockPosition + 1) < ident[id].size[block])) | 431 if((ident[actualId].subtype != FIELD_3DIGIT) && (ident[actualId].subtype != FIELD_2DIGIT) && ((subBlockPosition + 1) < ident[actualId].size[block])) |
422 { | 432 { |
423 subBlockPosition++; | 433 subBlockPosition++; |
424 return 1; | 434 return 1; |
425 } | 435 } |
426 | 436 |
427 if(((block + 1) < 4) && (ident[id].size[block+1] > 0)) | 437 if(((block + 1) < 4) && (ident[actualId].size[block+1] > 0)) |
428 { | 438 { |
429 block++; | 439 block++; |
430 subBlockPosition = 0; | 440 subBlockPosition = 0; |
431 return 1; | 441 return 1; |
432 } | 442 } |
438 uint8_t get_newContent_of_actual_id_block_and_subBlock(uint8_t action) | 448 uint8_t get_newContent_of_actual_id_block_and_subBlock(uint8_t action) |
439 { | 449 { |
440 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); | 450 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); |
441 uint8_t content; | 451 uint8_t content; |
442 | 452 |
443 if(event[evid].callerID != ident[id].callerID) | 453 if(event[actualevid].callerID != ident[actualId].callerID) |
444 return 0; | 454 return 0; |
445 | 455 |
446 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(event[evid].pEventFunction); | 456 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(event[actualevid].pEventFunction); |
447 | 457 |
448 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT)) | 458 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT)) |
449 { | 459 { |
450 content = 100 * ( ident[id].newText[ident[id].begin[block] + 0] - '0'); | 460 content = 100 * ( ident[id].newText[ident[actualId].begin[block] + 0] - '0'); |
451 content += 10 * ( ident[id].newText[ident[id].begin[block] + 1] - '0'); | 461 content += 10 * ( ident[id].newText[ident[actualId].begin[block] + 1] - '0'); |
452 content += ident[id].newText[ident[id].begin[block] + 2]; | 462 content += ident[id].newText[ident[actualId].begin[block] + 2]; |
453 } | 463 } |
454 else | 464 else |
455 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT)) | 465 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT)) |
456 { | 466 { |
457 content = 10 * (ident[id].newText[ident[id].begin[block] + 0] - '0'); | 467 content = 10 * (ident[actualId].newText[ident[actualId].begin[block] + 0] - '0'); |
458 content += ident[id].newText[ident[id].begin[block] + 1]; | 468 content += ident[actualId].newText[ident[actualId].begin[block] + 1]; |
459 } | 469 } |
460 else | 470 else |
461 if(ident[id].maintype == FIELD_NUMBERS) | 471 if(ident[actualId].maintype == FIELD_NUMBERS) |
462 content = ident[id].newText[ident[id].begin[block] + subBlockPosition]; | 472 content = ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition]; |
463 else | 473 else |
464 if((ident[id].maintype == FIELD_ON_OFF) || (ident[id].maintype == FIELD_TOGGLE)) | 474 if((ident[actualId].maintype == FIELD_ON_OFF) || (ident[actualId].maintype == FIELD_TOGGLE)) |
465 content = ident[id].input[block]; | 475 content = ident[actualId].input[block]; |
466 else | 476 else |
467 content = 0; /* just a default for protection */ | 477 content = 0; /* just a default for protection */ |
468 | 478 |
469 return onActionFunc(ident[id].callerID, block, subBlockPosition, content, action); | 479 return onActionFunc(ident[actualId].callerID, block, subBlockPosition, content, action); |
470 } | 480 } |
471 | 481 |
472 void mark_digit_of_actual_id_with_this_block_and_subBlock(int8_t oldblock, int8_t oldsubblockpos) | 482 void mark_digit_of_actual_id_with_this_block_and_subBlock(int8_t oldblock, int8_t oldsubblockpos) |
473 { | 483 { |
474 char oneCharText[2]; | 484 char oneCharText[2]; |
475 uint16_t positionOffset; | 485 uint16_t positionOffset; |
476 | 486 |
477 if(event[evid].callerID != ident[id].callerID) | 487 if(event[actualevid].callerID != ident[actualId].callerID) |
478 return; | 488 return; |
479 | 489 |
480 if(ident[id].maintype == FIELD_NUMBERS) | 490 if(ident[actualId].maintype == FIELD_NUMBERS) |
481 { | 491 { |
482 oneCharText[0] = ident[id].newText[ident[id].begin[oldblock] + oldsubblockpos]; | 492 oneCharText[0] = ident[actualId].newText[ident[actualId].begin[oldblock] + oldsubblockpos]; |
483 oneCharText[1] = 0; | 493 oneCharText[1] = 0; |
484 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[oldblock] + oldsubblockpos); | 494 positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[oldblock] + oldsubblockpos); |
485 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditFieldSelected); | 495 write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditFieldSelected); |
486 } | 496 } |
487 } | 497 } |
488 | 498 |
489 | 499 |
490 void mark_new_2digit_of_actual_id_block(void) | 500 void mark_new_2digit_of_actual_id_block(void) |
491 { | 501 { |
492 char oneCharText[3]; | 502 char oneCharText[3]; |
493 uint16_t positionOffset; | 503 uint16_t positionOffset; |
494 | 504 |
495 if(event[evid].callerID != ident[id].callerID) | 505 if(event[actualevid].callerID != ident[actualId].callerID) |
496 return; | 506 return; |
497 | 507 |
498 if(ident[id].maintype == FIELD_NUMBERS) | 508 if(ident[id].maintype == FIELD_NUMBERS) |
499 { | 509 { |
500 oneCharText[0] = ident[id].newText[ident[id].begin[block] + 0]; | 510 oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + 0]; |
501 oneCharText[1] = ident[id].newText[ident[id].begin[block] + 1]; | 511 oneCharText[1] = ident[actualId].newText[ident[actualId].begin[block] + 1]; |
502 oneCharText[2] = 0; | 512 oneCharText[2] = 0; |
503 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + 0); | 513 positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block] + 0); |
504 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); | 514 write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit); |
505 } | 515 } |
506 } | 516 } |
507 | 517 |
508 | 518 |
509 void mark_new_3digit_of_actual_id_block(void) | 519 void mark_new_3digit_of_actual_id_block(void) |
510 { | 520 { |
511 char oneCharText[4]; | 521 char oneCharText[4]; |
512 uint16_t positionOffset; | 522 uint16_t positionOffset; |
513 | 523 |
514 if(event[evid].callerID != ident[id].callerID) | 524 if(event[actualevid].callerID != ident[actualId].callerID) |
515 return; | 525 return; |
516 | 526 |
517 if(ident[id].maintype == FIELD_NUMBERS) | 527 if(ident[actualId].maintype == FIELD_NUMBERS) |
518 { | 528 { |
519 oneCharText[0] = ident[id].newText[ident[id].begin[block] + 0]; | 529 oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + 0]; |
520 oneCharText[1] = ident[id].newText[ident[id].begin[block] + 1]; | 530 oneCharText[1] = ident[actualId].newText[ident[actualId].begin[block] + 1]; |
521 oneCharText[2] = ident[id].newText[ident[id].begin[block] + 2]; | 531 oneCharText[2] = ident[actualId].newText[ident[actualId].begin[block] + 2]; |
522 oneCharText[3] = 0; | 532 oneCharText[3] = 0; |
523 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + 0); | 533 positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block] + 0); |
524 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); | 534 write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit); |
525 } | 535 } |
526 } | 536 } |
527 | 537 |
528 | 538 |
529 void mark_new_digit_of_actual_id_block_and_subBlock(void) | 539 void mark_new_digit_of_actual_id_block_and_subBlock(void) |
530 { | 540 { |
531 char oneCharText[2]; | 541 char oneCharText[2]; |
532 uint16_t positionOffset; | 542 uint16_t positionOffset; |
533 | 543 |
534 if(event[evid].callerID != ident[id].callerID) | 544 if(event[actualevid].callerID != ident[actualId].callerID) |
535 return; | 545 return; |
536 | 546 |
537 if(ident[id].maintype == FIELD_NUMBERS) | 547 if(ident[actualId].maintype == FIELD_NUMBERS) |
538 { | 548 { |
539 oneCharText[0] = ident[id].newText[ident[id].begin[block] + subBlockPosition]; | 549 oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition]; |
540 oneCharText[1] = 0; | 550 oneCharText[1] = 0; |
541 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + subBlockPosition); | 551 positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block] + subBlockPosition); |
542 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); | 552 write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[id].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit); |
543 } | 553 } |
544 } | 554 } |
545 | 555 |
546 | 556 |
547 void enterMenuEditField(void) | 557 void enterMenuEditField(void) |
549 uint8_t newContent; | 559 uint8_t newContent; |
550 uint8_t digit100; | 560 uint8_t digit100; |
551 uint8_t digit10; | 561 uint8_t digit10; |
552 uint8_t digit1; | 562 uint8_t digit1; |
553 | 563 |
554 evid = 0; | 564 actualevid = 0; |
555 while((evid < evidLast) && (event[evid].callerID != ident[id].callerID)) | 565 while((actualevid < evidLast) && (event[actualevid].callerID != ident[actualId].callerID)) |
556 { | 566 { |
557 evid++; | 567 actualevid++; |
558 } | 568 } |
559 | 569 |
560 if(event[evid].callerID != ident[id].callerID) | 570 if(event[actualevid].callerID != ident[actualId].callerID) |
561 return; | 571 return; |
562 | 572 |
563 set_globalState(event[evid].callerID); | 573 set_globalState(event[actualevid].callerID); |
564 block = 0; | 574 block = 0; |
565 subBlockPosition = 0; | 575 subBlockPosition = 0; |
566 | 576 |
567 if(ident[id].maintype == FIELD_NUMBERS) | 577 if(ident[actualId].maintype == FIELD_NUMBERS) |
568 { | 578 { |
569 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); | 579 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); |
570 // old stuff? hw 150916, reactivated 150923, this shows which digit will be changed now as it marks the other grey/black | 580 // old stuff? hw 150916, reactivated 150923, this shows which digit will be changed now as it marks the other grey/black |
571 // now fixed for button settings with newContent <= '0'+99 condition | 581 // now fixed for button settings with newContent <= '0'+99 condition |
572 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldSelected); | 582 change_CLUT_entry((CLUT_MenuEditField0 + actualId), CLUT_MenuEditFieldSelected); |
573 } | 583 } |
574 if(ident[id].maintype == FIELD_TOGGLE) | 584 if(ident[actualId].maintype == FIELD_TOGGLE) |
575 { | 585 { |
576 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); | 586 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); |
577 } | 587 } |
578 | 588 |
579 | 589 |
612 { | 622 { |
613 exitMenuEdit_to_InfoSensor(); | 623 exitMenuEdit_to_InfoSensor(); |
614 return; | 624 return; |
615 } | 625 } |
616 | 626 |
617 switch(ident[id].maintype) | 627 switch(ident[actualId].maintype) |
618 { | 628 { |
619 case FIELD_NUMBERS: | 629 case FIELD_NUMBERS: |
620 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); | 630 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); |
621 | 631 |
622 switch (ident[id].subtype) { | 632 switch (ident[actualId].subtype) { |
623 case FIELD_UDIGIT: | 633 case FIELD_UDIGIT: |
624 if((newContent >= '0') && (newContent <= '9')) | 634 if((newContent >= '0') && (newContent <= '9')) |
625 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | 635 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; |
626 | 636 |
627 mark_new_digit_of_actual_id_block_and_subBlock(); | 637 mark_new_digit_of_actual_id_block_and_subBlock(); |
628 | 638 |
629 break; | 639 break; |
630 case FIELD_3DIGIT: | 640 case FIELD_3DIGIT: |
631 if((newContent >= '0') && (newContent <= '0'+200)) | 641 if((newContent >= '0') && (newContent <= '0'+200)) |
632 { | 642 { |
633 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); | 643 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); |
634 ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; | 644 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + digit100; |
635 ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; | 645 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + digit10; |
636 ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; | 646 ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + digit1; |
637 mark_new_3digit_of_actual_id_block(); | 647 mark_new_3digit_of_actual_id_block(); |
638 } | 648 } |
639 | 649 |
640 break; | 650 break; |
641 case FIELD_2DIGIT: | 651 case FIELD_2DIGIT: |
642 if((newContent >= '0') && (newContent <= '0'+99)) | 652 if((newContent >= '0') && (newContent <= '0'+99)) |
643 { | 653 { |
644 ident[id].newText[ident[id].begin[block]] = '0' + (newContent - '0')/10; | 654 ident[actualId].newText[ident[actualId].begin[block]] = '0' + (newContent - '0')/10; |
645 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | 655 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); |
646 mark_new_2digit_of_actual_id_block(); | 656 mark_new_2digit_of_actual_id_block(); |
647 } | 657 } |
648 | 658 |
649 break; | 659 break; |
650 case FIELD_SDIGIT: | 660 case FIELD_SDIGIT: |
651 if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) { | 661 if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) { |
652 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | 662 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; |
653 } | 663 } |
654 | 664 |
655 mark_new_digit_of_actual_id_block_and_subBlock(); | 665 mark_new_digit_of_actual_id_block_and_subBlock(); |
656 | 666 |
657 break; | 667 break; |
661 case FIELD_ON_OFF: | 671 case FIELD_ON_OFF: |
662 set_globalState(menuID); | 672 set_globalState(menuID); |
663 | 673 |
664 break; | 674 break; |
665 case FIELD_SYMBOL: | 675 case FIELD_SYMBOL: |
666 ident[id].input[0] += 1; | 676 ident[actualId].input[0] += 1; |
667 if(ident[id].input[0] >= ident[id].input[1]) | 677 if(ident[actualId].input[0] >= ident[actualId].input[1]) |
668 ident[id].input[0] = 0; | 678 ident[actualId].input[0] = 0; |
669 ident[id].newText[0] = ident[id].orgText[ident[id].input[0]]; | 679 ident[actualId].newText[0] = ident[actualId].orgText[ident[actualId].input[0]]; |
670 write_content_of_actual_Id(); | 680 write_content_of_actual_Id(); |
671 set_globalState(menuID); | 681 set_globalState(menuID); |
672 break; | 682 break; |
673 case FIELD_SELECT: | 683 case FIELD_SELECT: |
674 write_buttonTextline(TXT2BYTE_ButtonMinus, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonPlus); | 684 write_buttonTextline(TXT2BYTE_ButtonMinus, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonPlus); |
682 { | 692 { |
683 uint8_t newContent; | 693 uint8_t newContent; |
684 | 694 |
685 set_globalState(menuID); | 695 set_globalState(menuID); |
686 | 696 |
687 if(event[evid].callerID != ident[id].callerID) | 697 if(event[actualevid].callerID != ident[actualId].callerID) |
688 return; | 698 return; |
689 | 699 |
690 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_TIMEOUT); | 700 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_TIMEOUT); |
691 | 701 |
692 /* | 702 /* |
733 uint8_t action; | 743 uint8_t action; |
734 uint8_t newContent; | 744 uint8_t newContent; |
735 int8_t blockOld = 0; | 745 int8_t blockOld = 0; |
736 int8_t subBlockPositionOld = 0; | 746 int8_t subBlockPositionOld = 0; |
737 | 747 |
738 if(event[evid].callerID != ident[id].callerID) | 748 if(event[actualevid].callerID != ident[actualId].callerID) |
739 return; | 749 return; |
740 | 750 |
741 blockOld = block; | 751 blockOld = block; |
742 subBlockPositionOld = subBlockPosition; | 752 subBlockPositionOld = subBlockPosition; |
743 | 753 |
776 | 786 |
777 return; | 787 return; |
778 } | 788 } |
779 } | 789 } |
780 | 790 |
781 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) | 791 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) |
782 { | 792 { |
783 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/100; | 793 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/100; |
784 ident[id].newText[ident[id].begin[block] + 1] = '0' + (newContent - '0')/10; | 794 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + (newContent - '0')/10; |
785 ident[id].newText[ident[id].begin[block] + 2] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | 795 ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); |
786 } | 796 } |
787 else | 797 else |
788 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) | 798 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) |
789 { | 799 { |
790 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; | 800 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/10; |
791 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | 801 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); |
792 } else if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT && action == ACTION_BUTTON_ENTER && subBlockPosition == 0) { | 802 } else if (ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT && action == ACTION_BUTTON_ENTER && subBlockPosition == 0) { |
793 if (newContent == '+' || newContent == '-') { | 803 if (newContent == '+' || newContent == '-') { |
794 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | 804 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; |
795 } | 805 } |
796 } | 806 } |
797 else | 807 else |
798 if((ident[id].maintype == FIELD_NUMBERS) && (action == ACTION_BUTTON_ENTER) && (newContent >= '0') && (newContent <= '9')) | 808 if((ident[actualId].maintype == FIELD_NUMBERS) && (action == ACTION_BUTTON_ENTER) && (newContent >= '0') && (newContent <= '9')) |
799 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | 809 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; |
800 | 810 |
801 if(action == ACTION_BUTTON_ENTER) | 811 if(action == ACTION_BUTTON_ENTER) |
802 { | 812 { |
803 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT)) | 813 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT)) |
804 { | 814 { |
805 mark_new_3digit_of_actual_id_block(); | 815 mark_new_3digit_of_actual_id_block(); |
806 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0); | 816 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0); |
807 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,1); | 817 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,1); |
808 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,2); | 818 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,2); |
809 } | 819 } |
810 else | 820 else |
811 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT)) | 821 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT)) |
812 { | 822 { |
813 mark_new_2digit_of_actual_id_block(); | 823 mark_new_2digit_of_actual_id_block(); |
814 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); |
815 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); |
816 } | 826 } |
850 | 860 |
851 | 861 |
852 static void checkUpdateSDigit(uint8_t newContent) | 862 static void checkUpdateSDigit(uint8_t newContent) |
853 { | 863 { |
854 if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) { | 864 if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) { |
855 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | 865 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; |
856 } | 866 } |
857 } | 867 } |
858 | 868 |
859 | 869 |
860 void upMenuEditFieldDigit(void) | 870 void upMenuEditFieldDigit(void) |
862 uint8_t newContent; | 872 uint8_t newContent; |
863 uint8_t digit100; | 873 uint8_t digit100; |
864 uint8_t digit10; | 874 uint8_t digit10; |
865 uint8_t digit1; | 875 uint8_t digit1; |
866 | 876 |
867 if(event[evid].callerID != ident[id].callerID) | 877 if(event[actualevid].callerID != ident[actualId].callerID) |
868 return; | 878 return; |
869 | 879 |
870 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_NEXT); | 880 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_NEXT); |
871 | 881 |
872 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) | 882 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) |
873 { | 883 { |
874 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); | 884 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); |
875 ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; | 885 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + digit100; |
876 ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; | 886 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + digit10; |
877 ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; | 887 ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + digit1; |
878 mark_new_3digit_of_actual_id_block(); | 888 mark_new_3digit_of_actual_id_block(); |
879 return; | 889 return; |
880 } | 890 } |
881 | 891 |
882 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) | 892 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) |
883 { | 893 { |
884 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; | 894 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/10; |
885 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | 895 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); |
886 mark_new_2digit_of_actual_id_block(); | 896 mark_new_2digit_of_actual_id_block(); |
887 return; | 897 return; |
888 } | 898 } |
889 | 899 |
890 if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT) { | 900 if (ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT) { |
891 checkUpdateSDigit(newContent); | 901 checkUpdateSDigit(newContent); |
892 } else if (ident[id].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { | 902 } else if (ident[actualId].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { |
893 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | 903 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; |
894 } | 904 } |
895 | 905 |
896 mark_new_digit_of_actual_id_block_and_subBlock(); | 906 mark_new_digit_of_actual_id_block_and_subBlock(); |
897 } | 907 } |
898 | 908 |
902 uint8_t newContent; | 912 uint8_t newContent; |
903 uint8_t digit100; | 913 uint8_t digit100; |
904 uint8_t digit10; | 914 uint8_t digit10; |
905 uint8_t digit1; | 915 uint8_t digit1; |
906 | 916 |
907 if(event[evid].callerID != ident[id].callerID) | 917 if(event[actualevid].callerID != ident[actualId].callerID) |
908 return; | 918 return; |
909 | 919 |
910 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_BACK); | 920 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_BACK); |
911 | 921 |
912 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) | 922 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) |
913 { | 923 { |
914 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); | 924 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); |
915 ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; | 925 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + digit100; |
916 ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; | 926 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + digit10; |
917 ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; | 927 ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + digit1; |
918 mark_new_3digit_of_actual_id_block(); | 928 mark_new_3digit_of_actual_id_block(); |
919 return; | 929 return; |
920 } | 930 } |
921 | 931 |
922 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) | 932 if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) |
923 { | 933 { |
924 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; | 934 ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/10; |
925 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | 935 ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); |
926 mark_new_2digit_of_actual_id_block(); | 936 mark_new_2digit_of_actual_id_block(); |
927 return; | 937 return; |
928 } | 938 } |
929 | 939 |
930 if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT) { | 940 if (ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT) { |
931 checkUpdateSDigit(newContent); | 941 checkUpdateSDigit(newContent); |
932 } else if (ident[id].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { | 942 } else if (ident[actualId].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { |
933 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | 943 ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; |
934 } | 944 } |
935 | 945 |
936 mark_new_digit_of_actual_id_block_and_subBlock(); | 946 mark_new_digit_of_actual_id_block_and_subBlock(); |
937 } | 947 } |
938 | 948 |
939 | 949 |
940 void evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4) | 950 void evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4) |
941 { | 951 { |
942 if(editID != ident[id].callerID) | 952 if(editID != ident[actualId].callerID) |
943 return; | 953 return; |
944 | 954 |
945 bool isSigned = ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT; | 955 bool isSigned = ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT; |
946 | 956 |
947 uint8_t i, digitCount, digit; | 957 uint8_t i, digitCount, digit; |
948 uint32_t sum[4], multiplier; | 958 uint32_t sum[4], multiplier; |
949 | 959 |
950 for(i=0;i<4;i++) | 960 for(i=0;i<4;i++) |
951 sum[i] = 0; | 961 sum[i] = 0; |
952 | 962 |
953 i = 0; | 963 i = 0; |
954 while( ident[id].size[i] && (i < 4)) | 964 while( ident[actualId].size[i] && (i < 4)) |
955 { | 965 { |
956 multiplier = 1; | 966 multiplier = 1; |
957 for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++) | 967 for(digitCount = 1; digitCount < ident[actualId].size[i]; digitCount++) |
958 multiplier *= 10; | 968 multiplier *= 10; |
959 | 969 |
960 bool isNegative = false; | 970 bool isNegative = false; |
961 for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++) | 971 for(digitCount = 0; digitCount < ident[actualId].size[i]; digitCount++) |
962 { | 972 { |
963 digit = ident[id].newText[ident[id].begin[i] + digitCount]; | 973 digit = ident[actualId].newText[ident[actualId].begin[i] + digitCount]; |
964 | 974 |
965 if (isSigned && digitCount == 0) { | 975 if (isSigned && digitCount == 0) { |
966 if (digit == '-') { | 976 if (digit == '-') { |
967 isNegative = true; | 977 isNegative = true; |
968 } | 978 } |
1004 | 1014 |
1005 uint8_t get_id_of(uint32_t editID) | 1015 uint8_t get_id_of(uint32_t editID) |
1006 { | 1016 { |
1007 uint8_t temp_id; | 1017 uint8_t temp_id; |
1008 | 1018 |
1009 if(editID == ident[id].callerID) | 1019 if(editID == ident[actualId].callerID) |
1010 return id; | 1020 return id; |
1011 else | 1021 else |
1012 { | 1022 { |
1013 temp_id = 0; | 1023 temp_id = 0; |
1014 while((temp_id < 9) && (editID != ident[temp_id].callerID)) | 1024 while((temp_id < 9) && (editID != ident[temp_id].callerID)) |
1070 uint8_t id_local = 0; | 1080 uint8_t id_local = 0; |
1071 id_local = get_id_of(editID); | 1081 id_local = get_id_of(editID); |
1072 | 1082 |
1073 if(id_local <= idLast) | 1083 if(id_local <= idLast) |
1074 { | 1084 { |
1075 id = id_local; | 1085 actualId = id_local; |
1076 set_cursorNew(id); | 1086 set_cursorNew(id_local); |
1077 } | 1087 } |
1078 } | 1088 } |
1079 | 1089 |
1080 #if OLD_SELECTION | 1090 #if OLD_SELECTION |
1081 void tMenuEdit_select(uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) | 1091 void tMenuEdit_select(uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) |
1174 break; | 1184 break; |
1175 | 1185 |
1176 } | 1186 } |
1177 } | 1187 } |
1178 else | 1188 else |
1179 if(get_globalState() == event[evid].callerID) | 1189 if(get_globalState() == event[actualevid].callerID) |
1180 { | 1190 { |
1181 switch(sendAction) | 1191 switch(sendAction) |
1182 { | 1192 { |
1183 case ACTION_BUTTON_ENTER: | 1193 case ACTION_BUTTON_ENTER: |
1184 nextMenuEditFieldDigit(); | 1194 nextMenuEditFieldDigit(); |
1222 } | 1232 } |
1223 } | 1233 } |
1224 } | 1234 } |
1225 | 1235 |
1226 | 1236 |
1237 void create_newText_for_Id_and_field_select(int8_t localId) | |
1238 { | |
1239 uint8_t i; | |
1240 | |
1241 i = 0; | |
1242 while( ident[localId].size[i] && (i < 4)) | |
1243 { | |
1244 if(ident[localId].input[i]) | |
1245 ident[localId].newText[ident[localId].begin[i]] = '\005'; | |
1246 else | |
1247 ident[localId].newText[ident[localId].begin[i]] = '\006'; | |
1248 i++; | |
1249 } | |
1250 } | |
1251 | |
1227 void create_newText_for_actual_Id_and_field_select(void) | 1252 void create_newText_for_actual_Id_and_field_select(void) |
1228 { | 1253 { |
1229 uint8_t i; | 1254 create_newText_for_Id_and_field_select(actualId); |
1230 | 1255 } |
1231 i = 0; | 1256 |
1232 while( ident[id].size[i] && (i < 4)) | 1257 void create_newText_for_Id(int8_t localId) |
1233 { | 1258 { |
1234 if(ident[id].input[i]) | 1259 bool isSigned = ident[localId].maintype == FIELD_NUMBERS && ident[localId].subtype == FIELD_SDIGIT; |
1235 ident[id].newText[ident[id].begin[i]] = '\005'; | 1260 |
1236 else | 1261 uint8_t i, digitCount; |
1237 ident[id].newText[ident[id].begin[i]] = '\006'; | 1262 uint32_t remainder, digit, divider; |
1238 i++; | 1263 i = 0; |
1239 } | 1264 |
1240 } | 1265 if( ident[localId].maintype == FIELD_SELECT) |
1241 | 1266 { |
1267 create_newText_for_Id_and_field_select(localId); | |
1268 return; | |
1269 } | |
1270 | |
1271 while( ident[localId].size[i] && (i < 4)) | |
1272 { | |
1273 bool isNegative = false; | |
1274 if (isSigned) { | |
1275 int32_t value = ((input_u)ident[localId].input[i]).int32; | |
1276 if (value < 0) { | |
1277 isNegative = true; | |
1278 } | |
1279 remainder = abs(value); | |
1280 } else { | |
1281 remainder = ident[localId].input[i]; | |
1282 } | |
1283 divider = 1; | |
1284 | |
1285 for(digitCount = 1; digitCount < ident[localId].size[i]; digitCount++) | |
1286 divider *= 10; | |
1287 | |
1288 for(digitCount = 0; digitCount < ident[localId].size[i]; digitCount++) | |
1289 { | |
1290 if (isSigned && digitCount == 0) { | |
1291 ident[localId].newText[ident[localId].begin[i] + digitCount] = isNegative ? '-' : '+'; | |
1292 } else { | |
1293 digit = remainder / divider; | |
1294 remainder -= digit * divider; | |
1295 if(digit < 10) | |
1296 ident[localId].newText[ident[localId].begin[i] + digitCount] = digit + '0'; | |
1297 else | |
1298 ident[localId].newText[ident[localId].begin[i] + digitCount] = 'x'; | |
1299 } | |
1300 | |
1301 divider /= 10; | |
1302 } | |
1303 i++; | |
1304 } | |
1305 } | |
1242 | 1306 |
1243 void create_newText_for_actual_Id(void) | 1307 void create_newText_for_actual_Id(void) |
1244 { | 1308 { |
1245 if( ident[id].maintype == FIELD_SELECT) | 1309 create_newText_for_Id(actualId); |
1246 { | |
1247 create_newText_for_actual_Id_and_field_select(); | |
1248 return; | |
1249 } | |
1250 | |
1251 bool isSigned = ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT; | |
1252 | |
1253 uint8_t i, digitCount; | |
1254 uint32_t remainder, digit, divider; | |
1255 | |
1256 i = 0; | |
1257 while( ident[id].size[i] && (i < 4)) | |
1258 { | |
1259 bool isNegative = false; | |
1260 if (isSigned) { | |
1261 int32_t value = ((input_u)ident[id].input[i]).int32; | |
1262 if (value < 0) { | |
1263 isNegative = true; | |
1264 } | |
1265 remainder = abs(value); | |
1266 } else { | |
1267 remainder = ident[id].input[i]; | |
1268 } | |
1269 divider = 1; | |
1270 | |
1271 for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++) | |
1272 divider *= 10; | |
1273 | |
1274 for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++) | |
1275 { | |
1276 if (isSigned && digitCount == 0) { | |
1277 ident[id].newText[ident[id].begin[i] + digitCount] = isNegative ? '-' : '+'; | |
1278 } else { | |
1279 digit = remainder / divider; | |
1280 remainder -= digit * divider; | |
1281 if(digit < 10) | |
1282 ident[id].newText[ident[id].begin[i] + digitCount] = digit + '0'; | |
1283 else | |
1284 ident[id].newText[ident[id].begin[i] + digitCount] = 'x'; | |
1285 } | |
1286 | |
1287 divider /= 10; | |
1288 } | |
1289 i++; | |
1290 } | |
1291 } | 1310 } |
1292 | 1311 |
1293 | 1312 |
1294 void write_content_without_Id(void) | 1313 void write_content_without_Id(void) |
1295 { | 1314 { |
1296 write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, CLUT_MenuEditFieldRegular); | 1315 write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, CLUT_MenuEditFieldRegular); |
1297 } | 1316 } |
1298 | 1317 |
1299 | 1318 |
1319 void write_content_of_Id(int8_t localId) | |
1320 { | |
1321 write_content( ident[localId].coord[0], ident[localId].coord[1], ident[localId].coord[2], ident[localId].fontUsed, ident[localId].newText, (CLUT_MenuEditField0 + localId)); | |
1322 } | |
1300 void write_content_of_actual_Id(void) | 1323 void write_content_of_actual_Id(void) |
1301 { | 1324 { |
1302 write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, (CLUT_MenuEditField0 + id)); | 1325 write_content_of_Id(actualId); |
1303 } | 1326 } |
1304 | 1327 |
1328 void clean_content_of_Id(int8_t localId) | |
1329 { | |
1330 clean_content( ident[localId].coord[0], ident[localId].coord[1], ident[localId].coord[2], ident[localId].fontUsed); | |
1331 } | |
1305 | 1332 |
1306 void clean_content_of_actual_Id(void) | 1333 void clean_content_of_actual_Id(void) |
1307 { | 1334 { |
1308 clean_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed); | 1335 clean_content_of_Id(actualId); |
1309 } | 1336 } |
1310 | |
1311 | 1337 |
1312 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) | 1338 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) |
1313 { | 1339 { |
1314 if(id >= 9) | 1340 if(id >= 9) |
1315 return; | 1341 return; |
1364 if(!tME_stop) | 1390 if(!tME_stop) |
1365 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | 1391 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); |
1366 else | 1392 else |
1367 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditInfo); | 1393 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditInfo); |
1368 | 1394 |
1369 create_newText_for_actual_Id(); | 1395 create_newText_for_Id(id); |
1370 | 1396 |
1371 if(editID == 0) | 1397 if(editID == 0) |
1372 write_content_without_Id(); | 1398 write_content_without_Id(); |
1373 else | 1399 else |
1374 { | 1400 { |
1375 write_content_of_actual_Id(); | 1401 write_content_of_Id(id); |
1376 if(!tME_stop) | 1402 if(!tME_stop) |
1377 idLast = id; | 1403 idLast = id; |
1378 id++; | 1404 id++; |
1379 } | 1405 } |
1380 } | 1406 } |
1447 break; | 1473 break; |
1448 } | 1474 } |
1449 | 1475 |
1450 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | 1476 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); |
1451 | 1477 |
1452 create_newText_for_actual_Id(); | 1478 create_newText_for_Id(id); |
1453 | 1479 |
1454 if(editID == 0) | 1480 if(editID == 0) |
1455 write_content_without_Id(); | 1481 write_content_without_Id(); |
1456 else | 1482 else |
1457 { | 1483 { |
1458 write_content_of_actual_Id(); | 1484 write_content_of_Id(id); |
1459 if(!tME_stop) | 1485 if(!tME_stop) |
1460 idLast = id; | 1486 idLast = id; |
1461 id++; | 1487 id++; |
1462 } | 1488 } |
1463 } | 1489 } |
1485 | 1511 |
1486 if(editID == 0) | 1512 if(editID == 0) |
1487 write_content_without_Id(); | 1513 write_content_without_Id(); |
1488 else | 1514 else |
1489 { | 1515 { |
1490 write_content_of_actual_Id(); | 1516 write_content_of_Id(id); |
1491 if(!tME_stop) | 1517 if(!tME_stop) |
1492 idLast = id; | 1518 idLast = id; |
1493 id++; | 1519 id++; |
1494 } | 1520 } |
1495 } | 1521 } |
1523 | 1549 |
1524 if(editID == 0) | 1550 if(editID == 0) |
1525 write_content_without_Id(); | 1551 write_content_without_Id(); |
1526 else | 1552 else |
1527 { | 1553 { |
1528 write_content_of_actual_Id(); | 1554 write_content_of_Id(id); |
1529 if(!tME_stop) | 1555 if(!tME_stop) |
1530 idLast = id; | 1556 idLast = id; |
1531 id++; | 1557 id++; |
1532 } | 1558 } |
1533 } | 1559 } |
1549 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditButtonColor1); | 1575 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditButtonColor1); |
1550 | 1576 |
1551 if(editID == 0) write_content_without_Id(); | 1577 if(editID == 0) write_content_without_Id(); |
1552 else | 1578 else |
1553 { | 1579 { |
1554 write_content_of_actual_Id(); | 1580 write_content_of_Id(id); |
1555 if(!tME_stop) idLast = id; | 1581 if(!tME_stop) idLast = id; |
1556 id++; | 1582 id++; |
1557 } | 1583 } |
1558 } | 1584 } |
1559 | 1585 |
1608 | 1634 |
1609 if(editID == 0) | 1635 if(editID == 0) |
1610 write_content_without_Id(); | 1636 write_content_without_Id(); |
1611 else | 1637 else |
1612 { | 1638 { |
1613 write_content_of_actual_Id(); | 1639 write_content_of_Id(id); |
1614 if(!tME_stop) | 1640 if(!tME_stop) |
1615 idLast = id; | 1641 idLast = id; |
1616 id++; | 1642 id++; |
1617 } | 1643 } |
1618 } | 1644 } |
1641 | 1667 |
1642 if(editID == 0) | 1668 if(editID == 0) |
1643 write_content_without_Id(); | 1669 write_content_without_Id(); |
1644 else | 1670 else |
1645 { | 1671 { |
1646 write_content_of_actual_Id(); | 1672 write_content_of_Id(id); |
1647 if(!tME_stop) | 1673 if(!tME_stop) |
1648 idLast = id; | 1674 idLast = id; |
1649 id++; | 1675 id++; |
1650 } | 1676 } |
1651 } | 1677 } |
1662 void setEvent(uint32_t inputEventID, uint32_t inputFunctionCall) | 1688 void setEvent(uint32_t inputEventID, uint32_t inputFunctionCall) |
1663 { | 1689 { |
1664 if(evidLast >= 9) | 1690 if(evidLast >= 9) |
1665 return; | 1691 return; |
1666 | 1692 |
1693 #if 0 | |
1667 /* set cursor to first field */ | 1694 /* set cursor to first field */ |
1668 if(evidLast < 0) | 1695 if(evidLast < 0) |
1669 { | 1696 { |
1670 startMenuEditFieldSelect(); | 1697 startMenuEditFieldSelect(); |
1671 } | 1698 } |
1672 | 1699 #endif |
1673 event[evid].callerID = inputEventID; | 1700 event[evid].callerID = inputEventID; |
1674 event[evid].pEventFunction = inputFunctionCall; | 1701 event[evid].pEventFunction = inputFunctionCall; |
1675 | 1702 |
1676 evidLast = evid; | 1703 evidLast = evid; |
1677 evid++; | 1704 evid++; |