# HG changeset patch # User Ideenmodellierer # Date 1709844678 -3600 # Node ID de6023cc058070946607c99561f6e1b3d7d42de9 # Parent b2aad621aeb0e39cb2091034f57ea572f14d1aa8 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" diff -r b2aad621aeb0 -r de6023cc0580 Discovery/Src/tMenuEdit.c --- a/Discovery/Src/tMenuEdit.c Thu Mar 07 21:46:49 2024 +0100 +++ b/Discovery/Src/tMenuEdit.c Thu Mar 07 21:51:18 2024 +0100 @@ -97,11 +97,13 @@ static uint8_t menuColor; static int8_t id = 0; +static int8_t actualId = 0; static int8_t idLast = -1; static SEditIdent ident[10]; static int8_t tME_stop = 0; static int8_t evid = 0; +static int8_t actualevid = 0; static int8_t evidLast = -1; static SEventHandler event[10]; @@ -156,12 +158,22 @@ tME_stop = 1; } -void resetMenuEdit(uint8_t color) +void resetMenuContentStructure() { id = 0; idLast = -1; evid = 0; evidLast = -1; +} + +void resetMenuEdit(uint8_t color) +{ + id = 0; + actualId = 0; + idLast = -1; + evid = 0; + actualevid = 0; + evidLast = -1; tME_stop = 0; EnterPressed = 0; EnterPressedBeforeButtonAction = 0; @@ -185,10 +197,8 @@ menuColor = color; -// draw_tMEdesign(); -// GFX_SetFramesTopBottom(tMEscreen.FBStartAdress, tMEcursor.FBStartAdress,480); + /* set cursor to first line */ uint8_t line = 1; -// GFX_SetFramesTopBottom(tMEscreen.FBStartAdress, (tMEcursorNew.FBStartAdress) + 65*2*(line - 1),390); GFX_SetFrameTop(tMEscreen.FBStartAdress); if(!settingsGetPointer()->FlipDisplay) { @@ -385,20 +395,20 @@ void startMenuEditFieldSelect(void) { - id = 0; - helperGotoMenuEditField(id); + actualId = 0; + helperGotoMenuEditField(actualId); } void nextMenuEditField(void) { - helperLeaveMenuEditField(id); + helperLeaveMenuEditField(actualId); - if(id < idLast) - id++; + if(actualId < idLast) + actualId++; else - id = 0; - helperGotoMenuEditField(id); + actualId = 0; + helperGotoMenuEditField(actualId); } /* @@ -415,16 +425,16 @@ _Bool inc_subBlock_or_block_of_actual_id(void) { - if(event[evid].callerID != ident[id].callerID) + if(event[actualevid].callerID != ident[actualId].callerID) return 0; - if((ident[id].subtype != FIELD_3DIGIT) && (ident[id].subtype != FIELD_2DIGIT) && ((subBlockPosition + 1) < ident[id].size[block])) + if((ident[actualId].subtype != FIELD_3DIGIT) && (ident[actualId].subtype != FIELD_2DIGIT) && ((subBlockPosition + 1) < ident[actualId].size[block])) { subBlockPosition++; return 1; } - if(((block + 1) < 4) && (ident[id].size[block+1] > 0)) + if(((block + 1) < 4) && (ident[actualId].size[block+1] > 0)) { block++; subBlockPosition = 0; @@ -440,33 +450,33 @@ uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); uint8_t content; - if(event[evid].callerID != ident[id].callerID) + if(event[actualevid].callerID != ident[actualId].callerID) return 0; - onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(event[evid].pEventFunction); + onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(event[actualevid].pEventFunction); - if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT)) + if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT)) { - content = 100 * ( ident[id].newText[ident[id].begin[block] + 0] - '0'); - content += 10 * ( ident[id].newText[ident[id].begin[block] + 1] - '0'); - content += ident[id].newText[ident[id].begin[block] + 2]; + content = 100 * ( ident[id].newText[ident[actualId].begin[block] + 0] - '0'); + content += 10 * ( ident[id].newText[ident[actualId].begin[block] + 1] - '0'); + content += ident[id].newText[ident[actualId].begin[block] + 2]; } else - if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT)) + if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT)) { - content = 10 * (ident[id].newText[ident[id].begin[block] + 0] - '0'); - content += ident[id].newText[ident[id].begin[block] + 1]; + content = 10 * (ident[actualId].newText[ident[actualId].begin[block] + 0] - '0'); + content += ident[actualId].newText[ident[actualId].begin[block] + 1]; } else - if(ident[id].maintype == FIELD_NUMBERS) - content = ident[id].newText[ident[id].begin[block] + subBlockPosition]; + if(ident[actualId].maintype == FIELD_NUMBERS) + content = ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition]; else - if((ident[id].maintype == FIELD_ON_OFF) || (ident[id].maintype == FIELD_TOGGLE)) - content = ident[id].input[block]; + if((ident[actualId].maintype == FIELD_ON_OFF) || (ident[actualId].maintype == FIELD_TOGGLE)) + content = ident[actualId].input[block]; else content = 0; /* just a default for protection */ - return onActionFunc(ident[id].callerID, block, subBlockPosition, content, action); + return onActionFunc(ident[actualId].callerID, block, subBlockPosition, content, action); } void mark_digit_of_actual_id_with_this_block_and_subBlock(int8_t oldblock, int8_t oldsubblockpos) @@ -474,15 +484,15 @@ char oneCharText[2]; uint16_t positionOffset; - if(event[evid].callerID != ident[id].callerID) + if(event[actualevid].callerID != ident[actualId].callerID) return; - if(ident[id].maintype == FIELD_NUMBERS) + if(ident[actualId].maintype == FIELD_NUMBERS) { - oneCharText[0] = ident[id].newText[ident[id].begin[oldblock] + oldsubblockpos]; + oneCharText[0] = ident[actualId].newText[ident[actualId].begin[oldblock] + oldsubblockpos]; oneCharText[1] = 0; - positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[oldblock] + oldsubblockpos); - write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditFieldSelected); + positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[oldblock] + oldsubblockpos); + write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditFieldSelected); } } @@ -492,16 +502,16 @@ char oneCharText[3]; uint16_t positionOffset; - if(event[evid].callerID != ident[id].callerID) + if(event[actualevid].callerID != ident[actualId].callerID) return; if(ident[id].maintype == FIELD_NUMBERS) { - oneCharText[0] = ident[id].newText[ident[id].begin[block] + 0]; - oneCharText[1] = ident[id].newText[ident[id].begin[block] + 1]; + oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + 0]; + oneCharText[1] = ident[actualId].newText[ident[actualId].begin[block] + 1]; oneCharText[2] = 0; - positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + 0); - write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); + positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block] + 0); + write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit); } } @@ -511,17 +521,17 @@ char oneCharText[4]; uint16_t positionOffset; - if(event[evid].callerID != ident[id].callerID) + if(event[actualevid].callerID != ident[actualId].callerID) return; - if(ident[id].maintype == FIELD_NUMBERS) + if(ident[actualId].maintype == FIELD_NUMBERS) { - oneCharText[0] = ident[id].newText[ident[id].begin[block] + 0]; - oneCharText[1] = ident[id].newText[ident[id].begin[block] + 1]; - oneCharText[2] = ident[id].newText[ident[id].begin[block] + 2]; + oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + 0]; + oneCharText[1] = ident[actualId].newText[ident[actualId].begin[block] + 1]; + oneCharText[2] = ident[actualId].newText[ident[actualId].begin[block] + 2]; oneCharText[3] = 0; - positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + 0); - write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); + positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block] + 0); + write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit); } } @@ -531,15 +541,15 @@ char oneCharText[2]; uint16_t positionOffset; - if(event[evid].callerID != ident[id].callerID) + if(event[actualevid].callerID != ident[actualId].callerID) return; - if(ident[id].maintype == FIELD_NUMBERS) + if(ident[actualId].maintype == FIELD_NUMBERS) { - oneCharText[0] = ident[id].newText[ident[id].begin[block] + subBlockPosition]; + oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition]; oneCharText[1] = 0; - positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + subBlockPosition); - write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); + positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block] + subBlockPosition); + write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[id].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit); } } @@ -551,27 +561,27 @@ uint8_t digit10; uint8_t digit1; - evid = 0; - while((evid < evidLast) && (event[evid].callerID != ident[id].callerID)) + actualevid = 0; + while((actualevid < evidLast) && (event[actualevid].callerID != ident[actualId].callerID)) { - evid++; + actualevid++; } - if(event[evid].callerID != ident[id].callerID) + if(event[actualevid].callerID != ident[actualId].callerID) return; - set_globalState(event[evid].callerID); + set_globalState(event[actualevid].callerID); block = 0; subBlockPosition = 0; - if(ident[id].maintype == FIELD_NUMBERS) + if(ident[actualId].maintype == FIELD_NUMBERS) { change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); // old stuff? hw 150916, reactivated 150923, this shows which digit will be changed now as it marks the other grey/black // now fixed for button settings with newContent <= '0'+99 condition - change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldSelected); + change_CLUT_entry((CLUT_MenuEditField0 + actualId), CLUT_MenuEditFieldSelected); } - if(ident[id].maintype == FIELD_TOGGLE) + if(ident[actualId].maintype == FIELD_TOGGLE) { change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); } @@ -614,15 +624,15 @@ return; } - switch(ident[id].maintype) + switch(ident[actualId].maintype) { case FIELD_NUMBERS: write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); - switch (ident[id].subtype) { + switch (ident[actualId].subtype) { case FIELD_UDIGIT: if((newContent >= '0') && (newContent <= '9')) - ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; + ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; mark_new_digit_of_actual_id_block_and_subBlock(); @@ -631,9 +641,9 @@ if((newContent >= '0') && (newContent <= '0'+200)) { split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); - ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; - ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; - ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; + ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + digit100; + ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + digit10; + ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + digit1; mark_new_3digit_of_actual_id_block(); } @@ -641,15 +651,15 @@ case FIELD_2DIGIT: if((newContent >= '0') && (newContent <= '0'+99)) { - ident[id].newText[ident[id].begin[block]] = '0' + (newContent - '0')/10; - ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); + ident[actualId].newText[ident[actualId].begin[block]] = '0' + (newContent - '0')/10; + ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); mark_new_2digit_of_actual_id_block(); } break; case FIELD_SDIGIT: if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) { - ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; + ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; } mark_new_digit_of_actual_id_block_and_subBlock(); @@ -663,10 +673,10 @@ break; case FIELD_SYMBOL: - ident[id].input[0] += 1; - if(ident[id].input[0] >= ident[id].input[1]) - ident[id].input[0] = 0; - ident[id].newText[0] = ident[id].orgText[ident[id].input[0]]; + ident[actualId].input[0] += 1; + if(ident[actualId].input[0] >= ident[actualId].input[1]) + ident[actualId].input[0] = 0; + ident[actualId].newText[0] = ident[actualId].orgText[ident[actualId].input[0]]; write_content_of_actual_Id(); set_globalState(menuID); break; @@ -684,7 +694,7 @@ set_globalState(menuID); - if(event[evid].callerID != ident[id].callerID) + if(event[actualevid].callerID != ident[actualId].callerID) return; newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_TIMEOUT); @@ -735,7 +745,7 @@ int8_t blockOld = 0; int8_t subBlockPositionOld = 0; - if(event[evid].callerID != ident[id].callerID) + if(event[actualevid].callerID != ident[actualId].callerID) return; blockOld = block; @@ -778,29 +788,29 @@ } } - if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) + if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) { - ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/100; - ident[id].newText[ident[id].begin[block] + 1] = '0' + (newContent - '0')/10; - ident[id].newText[ident[id].begin[block] + 2] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); + ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/100; + ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + (newContent - '0')/10; + ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); } else - if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) + if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) { - ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; - ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); - } else if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT && action == ACTION_BUTTON_ENTER && subBlockPosition == 0) { + ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/10; + ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); + } else if (ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT && action == ACTION_BUTTON_ENTER && subBlockPosition == 0) { if (newContent == '+' || newContent == '-') { - ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; + ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; } } else - if((ident[id].maintype == FIELD_NUMBERS) && (action == ACTION_BUTTON_ENTER) && (newContent >= '0') && (newContent <= '9')) - ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; + if((ident[actualId].maintype == FIELD_NUMBERS) && (action == ACTION_BUTTON_ENTER) && (newContent >= '0') && (newContent <= '9')) + ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; if(action == ACTION_BUTTON_ENTER) { - if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT)) + if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT)) { mark_new_3digit_of_actual_id_block(); mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0); @@ -808,7 +818,7 @@ mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,2); } else - if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT)) + if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT)) { mark_new_2digit_of_actual_id_block(); mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0); @@ -852,7 +862,7 @@ static void checkUpdateSDigit(uint8_t newContent) { if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) { - ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; + ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; } } @@ -864,33 +874,33 @@ uint8_t digit10; uint8_t digit1; - if(event[evid].callerID != ident[id].callerID) + if(event[actualevid].callerID != ident[actualId].callerID) return; newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_NEXT); - if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) + if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) { split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); - ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; - ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; - ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; + ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + digit100; + ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + digit10; + ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + digit1; mark_new_3digit_of_actual_id_block(); return; } - if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) + if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) { - ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; - ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); + ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/10; + ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); mark_new_2digit_of_actual_id_block(); return; } - if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT) { + if (ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT) { checkUpdateSDigit(newContent); - } else if (ident[id].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { - ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; + } else if (ident[actualId].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { + ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; } mark_new_digit_of_actual_id_block_and_subBlock(); @@ -904,33 +914,33 @@ uint8_t digit10; uint8_t digit1; - if(event[evid].callerID != ident[id].callerID) + if(event[actualevid].callerID != ident[actualId].callerID) return; newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_BACK); - if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) + if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) { split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); - ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; - ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; - ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; + ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + digit100; + ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + digit10; + ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + digit1; mark_new_3digit_of_actual_id_block(); return; } - if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) + if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) { - ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; - ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); + ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/10; + ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); mark_new_2digit_of_actual_id_block(); return; } - if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT) { + if (ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT) { checkUpdateSDigit(newContent); - } else if (ident[id].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { - ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; + } else if (ident[actualId].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { + ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; } mark_new_digit_of_actual_id_block_and_subBlock(); @@ -939,10 +949,10 @@ void evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4) { - if(editID != ident[id].callerID) + if(editID != ident[actualId].callerID) return; - bool isSigned = ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT; + bool isSigned = ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT; uint8_t i, digitCount, digit; uint32_t sum[4], multiplier; @@ -951,16 +961,16 @@ sum[i] = 0; i = 0; - while( ident[id].size[i] && (i < 4)) + while( ident[actualId].size[i] && (i < 4)) { multiplier = 1; - for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++) + for(digitCount = 1; digitCount < ident[actualId].size[i]; digitCount++) multiplier *= 10; bool isNegative = false; - for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++) + for(digitCount = 0; digitCount < ident[actualId].size[i]; digitCount++) { - digit = ident[id].newText[ident[id].begin[i] + digitCount]; + digit = ident[actualId].newText[ident[actualId].begin[i] + digitCount]; if (isSigned && digitCount == 0) { if (digit == '-') { @@ -1006,7 +1016,7 @@ { uint8_t temp_id; - if(editID == ident[id].callerID) + if(editID == ident[actualId].callerID) return id; else { @@ -1072,8 +1082,8 @@ if(id_local <= idLast) { - id = id_local; - set_cursorNew(id); + actualId = id_local; + set_cursorNew(id_local); } } @@ -1176,7 +1186,7 @@ } } else - if(get_globalState() == event[evid].callerID) + if(get_globalState() == event[actualevid].callerID) { switch(sendAction) { @@ -1224,70 +1234,79 @@ } -void create_newText_for_actual_Id_and_field_select(void) +void create_newText_for_Id_and_field_select(int8_t localId) { uint8_t i; i = 0; - while( ident[id].size[i] && (i < 4)) + while( ident[localId].size[i] && (i < 4)) { - if(ident[id].input[i]) - ident[id].newText[ident[id].begin[i]] = '\005'; + if(ident[localId].input[i]) + ident[localId].newText[ident[localId].begin[i]] = '\005'; else - ident[id].newText[ident[id].begin[i]] = '\006'; + ident[localId].newText[ident[localId].begin[i]] = '\006'; i++; } } +void create_newText_for_actual_Id_and_field_select(void) +{ + create_newText_for_Id_and_field_select(actualId); +} -void create_newText_for_actual_Id(void) +void create_newText_for_Id(int8_t localId) { - if( ident[id].maintype == FIELD_SELECT) + bool isSigned = ident[localId].maintype == FIELD_NUMBERS && ident[localId].subtype == FIELD_SDIGIT; + + uint8_t i, digitCount; + uint32_t remainder, digit, divider; + i = 0; + + if( ident[localId].maintype == FIELD_SELECT) { - create_newText_for_actual_Id_and_field_select(); + create_newText_for_Id_and_field_select(localId); return; } - bool isSigned = ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT; - - uint8_t i, digitCount; - uint32_t remainder, digit, divider; + while( ident[localId].size[i] && (i < 4)) + { + bool isNegative = false; + if (isSigned) { + int32_t value = ((input_u)ident[localId].input[i]).int32; + if (value < 0) { + isNegative = true; + } + remainder = abs(value); + } else { + remainder = ident[localId].input[i]; + } + divider = 1; - i = 0; - while( ident[id].size[i] && (i < 4)) - { - bool isNegative = false; - if (isSigned) { - int32_t value = ((input_u)ident[id].input[i]).int32; - if (value < 0) { - isNegative = true; - } - remainder = abs(value); - } else { - remainder = ident[id].input[i]; - } - divider = 1; + for(digitCount = 1; digitCount < ident[localId].size[i]; digitCount++) + divider *= 10; - for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++) - divider *= 10; + for(digitCount = 0; digitCount < ident[localId].size[i]; digitCount++) + { + if (isSigned && digitCount == 0) { + ident[localId].newText[ident[localId].begin[i] + digitCount] = isNegative ? '-' : '+'; + } else { + digit = remainder / divider; + remainder -= digit * divider; + if(digit < 10) + ident[localId].newText[ident[localId].begin[i] + digitCount] = digit + '0'; + else + ident[localId].newText[ident[localId].begin[i] + digitCount] = 'x'; + } - for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++) - { - if (isSigned && digitCount == 0) { - ident[id].newText[ident[id].begin[i] + digitCount] = isNegative ? '-' : '+'; - } else { - digit = remainder / divider; - remainder -= digit * divider; - if(digit < 10) - ident[id].newText[ident[id].begin[i] + digitCount] = digit + '0'; - else - ident[id].newText[ident[id].begin[i] + digitCount] = 'x'; - } + divider /= 10; + } + i++; + } +} - divider /= 10; - } - i++; - } +void create_newText_for_actual_Id(void) +{ + create_newText_for_Id(actualId); } @@ -1297,18 +1316,25 @@ } +void write_content_of_Id(int8_t localId) +{ + write_content( ident[localId].coord[0], ident[localId].coord[1], ident[localId].coord[2], ident[localId].fontUsed, ident[localId].newText, (CLUT_MenuEditField0 + localId)); +} void write_content_of_actual_Id(void) { - write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, (CLUT_MenuEditField0 + id)); + write_content_of_Id(actualId); } +void clean_content_of_Id(int8_t localId) +{ + clean_content( ident[localId].coord[0], ident[localId].coord[1], ident[localId].coord[2], ident[localId].fontUsed); +} void clean_content_of_actual_Id(void) { - clean_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed); + clean_content_of_Id(actualId); } - 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) { if(id >= 9) @@ -1366,13 +1392,13 @@ else change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditInfo); - create_newText_for_actual_Id(); + create_newText_for_Id(id); if(editID == 0) - write_content_without_Id(); + write_content_without_Id(); else { - write_content_of_actual_Id(); + write_content_of_Id(id); if(!tME_stop) idLast = id; id++; @@ -1449,13 +1475,13 @@ change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); - create_newText_for_actual_Id(); + create_newText_for_Id(id); if(editID == 0) - write_content_without_Id(); + write_content_without_Id(); else { - write_content_of_actual_Id(); + write_content_of_Id(id); if(!tME_stop) idLast = id; id++; @@ -1487,7 +1513,7 @@ write_content_without_Id(); else { - write_content_of_actual_Id(); + write_content_of_Id(id); if(!tME_stop) idLast = id; id++; @@ -1525,7 +1551,7 @@ write_content_without_Id(); else { - write_content_of_actual_Id(); + write_content_of_Id(id); if(!tME_stop) idLast = id; id++; @@ -1551,7 +1577,7 @@ if(editID == 0) write_content_without_Id(); else { - write_content_of_actual_Id(); + write_content_of_Id(id); if(!tME_stop) idLast = id; id++; } @@ -1610,7 +1636,7 @@ write_content_without_Id(); else { - write_content_of_actual_Id(); + write_content_of_Id(id); if(!tME_stop) idLast = id; id++; @@ -1643,7 +1669,7 @@ write_content_without_Id(); else { - write_content_of_actual_Id(); + write_content_of_Id(id); if(!tME_stop) idLast = id; id++; @@ -1664,12 +1690,13 @@ if(evidLast >= 9) return; +#if 0 /* set cursor to first field */ if(evidLast < 0) { startMenuEditFieldSelect(); } - +#endif event[evid].callerID = inputEventID; event[evid].pEventFunction = inputFunctionCall;