From 01da6d14e35504b5f37d523c59d2c31889c1a9f9 Mon Sep 17 00:00:00 2001 From: kisslorand Date: Mon, 17 Apr 2023 11:08:36 +0300 Subject: [PATCH] Another FW size reduction --- TFT/src/User/API/AddonHardware.c | 2 +- TFT/src/User/API/LevelingControl.c | 6 +- TFT/src/User/API/Notification.c | 2 +- TFT/src/User/API/Printing.c | 10 +- TFT/src/User/API/UI/ListItem.c | 104 ++--- TFT/src/User/API/UI/ListItem.h | 3 - TFT/src/User/API/UI/ListManager.c | 80 ++-- TFT/src/User/API/UI/ListManager.h | 3 - TFT/src/User/API/boot.c | 60 +-- TFT/src/User/API/boot.h | 1 - TFT/src/User/API/config.c | 620 ++++++++++++------------- TFT/src/User/API/config.h | 12 - TFT/src/User/API/interfaceCmd.c | 12 +- TFT/src/User/API/menu.c | 102 ++-- TFT/src/User/API/menu.h | 4 - TFT/src/User/API/parseACK.c | 8 +- TFT/src/User/Fatfs/myfatfs.c | 6 +- TFT/src/User/Menu/Babystep.c | 2 +- TFT/src/User/Menu/BedLeveling.c | 2 +- TFT/src/User/Menu/CaseLight.c | 2 +- TFT/src/User/Menu/ConnectionSettings.c | 2 +- TFT/src/User/Menu/FeatureSettings.c | 2 +- TFT/src/User/Menu/LEDColor.c | 14 +- TFT/src/User/Menu/LevelCorner.c | 12 +- TFT/src/User/Menu/MBL.c | 4 +- TFT/src/User/Menu/MPC.c | 2 +- TFT/src/User/Menu/MeshEditor.c | 6 +- TFT/src/User/Menu/MeshTuner.c | 2 +- TFT/src/User/Menu/Move.c | 6 +- TFT/src/User/Menu/PersistentInfo.c | 2 +- TFT/src/User/Menu/Pid.c | 6 +- TFT/src/User/Menu/Print.c | 6 +- TFT/src/User/Menu/RRFMacros.c | 6 +- TFT/src/User/Menu/SelectMode.c | 2 +- TFT/src/User/Menu/StatusScreen.c | 4 +- TFT/src/User/Menu/StatusScreen.h | 1 - TFT/src/User/Menu/TuneExtruder.c | 2 +- TFT/src/User/Menu/ZOffset.c | 4 +- 38 files changed, 550 insertions(+), 574 deletions(-) diff --git a/TFT/src/User/API/AddonHardware.c b/TFT/src/User/API/AddonHardware.c index 7c00c6fe89..f1a848e5cb 100644 --- a/TFT/src/User/API/AddonHardware.c +++ b/TFT/src/User/API/AddonHardware.c @@ -198,7 +198,7 @@ bool FIL_SmartRunoutDetect(void) return false; } -bool FIL_IsRunout(void) +static bool FIL_IsRunout(void) { if (GET_BIT(infoSettings.runout, RUNOUT_ENABLED)) { diff --git a/TFT/src/User/API/LevelingControl.c b/TFT/src/User/API/LevelingControl.c index 21cd6ce8ff..4732c2d0ec 100644 --- a/TFT/src/User/API/LevelingControl.c +++ b/TFT/src/User/API/LevelingControl.c @@ -10,13 +10,13 @@ typedef struct XY_coord LEVELING_POINT probedPoint = LEVEL_NO_POINT; // last probed point or LEVEL_NO_POINT in case of no new updates float probedZ = 0.0f; // last Z offset measured by probe -int16_t setCoordValue(AXIS axis, ALIGN_POSITION align) +static int16_t __attribute__ ((noinline)) setCoordValue(AXIS axis, ALIGN_POSITION align) { return ((align == LEFT || align == BOTTOM) ? infoSettings.machine_size_min[axis] + infoSettings.level_edge : infoSettings.machine_size_max[axis] - infoSettings.level_edge) - infoParameters.HomeOffset[axis]; } -void levelingGetPointCoords(LEVELING_POINT_COORDS coords) +static void levelingGetPointCoords(LEVELING_POINT_COORDS coords) { int16_t x_left = setCoordValue(X_AXIS, LEFT); int16_t x_right = setCoordValue(X_AXIS, RIGHT); @@ -45,7 +45,7 @@ void levelingGetPointCoords(LEVELING_POINT_COORDS coords) coords[LEVEL_CENTER] = (COORD){(x_left + x_right) / 2, (y_bottom + y_top) / 2}; } -LEVELING_POINT levelingGetPoint(int16_t x, int16_t y) +static LEVELING_POINT levelingGetPoint(int16_t x, int16_t y) { LEVELING_POINT_COORDS coords; uint8_t i; diff --git a/TFT/src/User/API/Notification.c b/TFT/src/User/API/Notification.c index dededf3055..9f2a34a027 100644 --- a/TFT/src/User/API/Notification.c +++ b/TFT/src/User/API/Notification.c @@ -39,7 +39,7 @@ bool toastRunning(void) } // check if any new notification is available -bool toastAvailable(void) +static bool toastAvailable(void) { for (int i = 0; i < TOAST_MSG_COUNT; i++) { diff --git a/TFT/src/User/API/Printing.c b/TFT/src/User/API/Printing.c index 1e5ca80900..f0c7c92d71 100644 --- a/TFT/src/User/API/Printing.c +++ b/TFT/src/User/API/Printing.c @@ -49,7 +49,7 @@ bool getRunoutAlarm(void) return filamentRunoutAlarm; } -void clearQueueAndMore(void) +static void clearQueueAndMore(void) { clearCmdQueue(); setRunoutAlarmFalse(); @@ -75,7 +75,7 @@ void resumeAndContinue(void) sendEmergencyCmd("M876 S1\n"); } -void abortAndTerminate(void) +static void abortAndTerminate(void) { clearQueueAndMore(); @@ -98,7 +98,7 @@ void abortAndTerminate(void) } } -void loopBreakToCondition(CONDITION_CALLBACK condCallback) +static void loopBreakToCondition(CONDITION_CALLBACK condCallback) { // M108 is sent to Marlin because consecutive blocking operations such as heating bed, extruder may defer processing of other gcodes. // If there's any ongoing blocking command, "M108" will take that out from the closed loop and a response will be received @@ -319,7 +319,7 @@ void preparePrintSummary(void) } // send print codes [0: start gcode, 1: end gcode 2: cancel gcode] -void sendPrintCodes(uint8_t index) +static void sendPrintCodes(uint8_t index) { PRINT_GCODES printcodes; @@ -365,7 +365,7 @@ void clearInfoPrint(void) memset(&infoPrinting, 0, sizeof(PRINTING)); } -void completePrint(void) +static void completePrint(void) { infoPrinting.cur = infoPrinting.size; // always update the print progress to 100% even if the print terminated infoPrinting.progress = 100; // set progress to 100% in case progress is controlled by slicer diff --git a/TFT/src/User/API/UI/ListItem.c b/TFT/src/User/API/UI/ListItem.c index 460f0cb226..9896532a3a 100644 --- a/TFT/src/User/API/UI/ListItem.c +++ b/TFT/src/User/API/UI/ListItem.c @@ -39,7 +39,7 @@ void setDynamicValue(uint8_t i, float value) } // draw item pressed feedback -void DrawListItemPress(const GUI_RECT * rect, bool pressed) +static void DrawListItemPress(const GUI_RECT * rect, bool pressed) { if (pressed) { @@ -57,6 +57,57 @@ void DrawListItemPress(const GUI_RECT * rect, bool pressed) GUI_RestoreColorDefault(); } +// draw title text of list item +static void draw_itemtitle(GUI_POINT pos, LABEL label, uint8_t position, int textarea_width) +{ + if (label.index != LABEL_NULL) + { + int textarea_width = LISTITEM_WIDTH - (pos.x + 1); // width after removing the width for icon + + if (label.index == LABEL_DYNAMIC) + GUI_DispLenString(pos.x, pos.y, (uint8_t *)getDynamicLabel(position), textarea_width, true); + else + GUI_DispLenString(pos.x, pos.y, labelGetAddress(&label), textarea_width, true); + } +} + +// display toggle button +static void ListItem_DisplayToggle(uint16_t sx, uint16_t sy, uint8_t iconchar_state) +{ + GUI_SetTextMode(GUI_TEXTMODE_NORMAL); + GUI_SetColor(infoSettings.list_border_color); + _GUI_DispString(sx, sy, (uint8_t *)(char *)IconCharSelect(CHARICON_TOGGLE_BODY)); + + GUI_SetTextMode(GUI_TEXTMODE_TRANS); + GUI_SetColor(charIconColor[iconchar_state]); + + _GUI_DispString(sx + (iconchar_state == CHARICON_TOGGLE_OFF ? 0 : BYTE_HEIGHT), sy, IconCharSelect(CHARICON_TOGGLE_SWITCH)); + + GUI_RestoreColorDefault(); +} + +// draw custom value for list item +static void ListItem_DisplayCustomValue(const GUI_RECT * rect, LABEL value, int i) +{ + const GUI_RECT rectVal = {rect->x1 - BYTE_WIDTH * (CUSTOM_VAL_LEN + 1) - 1, rect->y0 + (LISTITEM_HEIGHT - BYTE_HEIGHT) / 2, rect->x1 - 1, + rect->y1 - (LISTITEM_HEIGHT - BYTE_HEIGHT) / 2}; + + GUI_ClearPrect(&rectVal); + GUI_SetTextMode(GUI_TEXTMODE_NORMAL); + GUI_SetColor(infoSettings.list_border_color); + GUI_DrawPrect(&rectVal); + + GUI_SetTextMode(GUI_TEXTMODE_TRANS); + GUI_SetColor(LI_VAL_COLOR); + + if (value.index == LABEL_CUSTOM_VALUE || value.index == LABEL_DYNAMIC) // show custom text value + GUI_DispStringInPrect(&rectVal, (uint8_t *)getDynamicTextValue(i)); + else // show regular text labels + GUI_DispStringInPrect(&rectVal, (int32_t)value.index); + + GUI_RestoreColorDefault(); +} + void ListItem_Display(const GUI_RECT * rect, uint8_t position, const LISTITEM * curitem, bool pressed) { // draw navigation icons @@ -161,54 +212,3 @@ void ListItem_Display(const GUI_RECT * rect, uint8_t position, const LISTITEM * } GUI_RestoreColorDefault(); } - -// draw title text of list item -void draw_itemtitle(GUI_POINT pos, LABEL label, uint8_t position, int textarea_width) -{ - if (label.index != LABEL_NULL) - { - int textarea_width = LISTITEM_WIDTH - (pos.x + 1); // width after removing the width for icon - - if (label.index == LABEL_DYNAMIC) - GUI_DispLenString(pos.x, pos.y, (uint8_t *)getDynamicLabel(position), textarea_width, true); - else - GUI_DispLenString(pos.x, pos.y, labelGetAddress(&label), textarea_width, true); - } -} - -// display toggle button -void ListItem_DisplayToggle(uint16_t sx, uint16_t sy, uint8_t iconchar_state) -{ - GUI_SetTextMode(GUI_TEXTMODE_NORMAL); - GUI_SetColor(infoSettings.list_border_color); - _GUI_DispString(sx, sy, (uint8_t *)(char *)IconCharSelect(CHARICON_TOGGLE_BODY)); - - GUI_SetTextMode(GUI_TEXTMODE_TRANS); - GUI_SetColor(charIconColor[iconchar_state]); - - _GUI_DispString(sx + (iconchar_state == CHARICON_TOGGLE_OFF ? 0 : BYTE_HEIGHT), sy, IconCharSelect(CHARICON_TOGGLE_SWITCH)); - - GUI_RestoreColorDefault(); -} - -// draw custom value for list item -void ListItem_DisplayCustomValue(const GUI_RECT * rect, LABEL value, int i) -{ - const GUI_RECT rectVal = {rect->x1 - BYTE_WIDTH * (CUSTOM_VAL_LEN + 1) - 1, rect->y0 + (LISTITEM_HEIGHT - BYTE_HEIGHT) / 2, rect->x1 - 1, - rect->y1 - (LISTITEM_HEIGHT - BYTE_HEIGHT) / 2}; - - GUI_ClearPrect(&rectVal); - GUI_SetTextMode(GUI_TEXTMODE_NORMAL); - GUI_SetColor(infoSettings.list_border_color); - GUI_DrawPrect(&rectVal); - - GUI_SetTextMode(GUI_TEXTMODE_TRANS); - GUI_SetColor(LI_VAL_COLOR); - - if (value.index == LABEL_CUSTOM_VALUE || value.index == LABEL_DYNAMIC) // show custom text value - GUI_DispStringInPrect(&rectVal, (uint8_t *)getDynamicTextValue(i)); - else // show regular text labels - GUI_DispStringInPrect(&rectVal, (int32_t)value.index); - - GUI_RestoreColorDefault(); -} diff --git a/TFT/src/User/API/UI/ListItem.h b/TFT/src/User/API/UI/ListItem.h index 7fa590ae37..c6ad33052b 100644 --- a/TFT/src/User/API/UI/ListItem.h +++ b/TFT/src/User/API/UI/ListItem.h @@ -23,9 +23,6 @@ void setDynamicValue(uint8_t i, float value); // set list item value to any void ListItem_Display(const GUI_RECT * rect, uint8_t position, const LISTITEM * curitem, bool pressed); void ListMenuSetItem(const LISTITEM * menuItem, uint8_t position); -void draw_itemtitle(GUI_POINT pos, LABEL label, uint8_t position, int textarea_width); -void ListItem_DisplayToggle(uint16_t sx, uint16_t sy, uint8_t iconchar_state); -void ListItem_DisplayCustomValue(const GUI_RECT * rect, LABEL value, int i); GUI_POINT getTextStartPoint(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey,ALIGN_POSITION pos, const char * textchar); #ifdef __cplusplus diff --git a/TFT/src/User/API/UI/ListManager.c b/TFT/src/User/API/UI/ListManager.c index 1e1e400f94..c3d238caf8 100644 --- a/TFT/src/User/API/UI/ListManager.c +++ b/TFT/src/User/API/UI/ListManager.c @@ -17,6 +17,44 @@ static bool handleBack = true; static void (*action_preparePage)(LISTITEMS * listItems, uint8_t index) = NULL; static void (*action_prepareItem)(LISTITEM * item, uint16_t index, uint8_t itemPos) = NULL; +// display page at selected index +static void listViewSetCurPage(uint8_t curPage) +{ + if (action_preparePage != NULL) + { + action_preparePage(&listItems, curPage); + } + else + { + for (uint8_t i = 0; i < LISTITEM_PER_PAGE; i++) + { + uint16_t index = curPage * LISTITEM_PER_PAGE + i; + + if (index < maxItemCount) + { + if (totalItems != NULL) + listItems.items[i] = totalItems[index]; + + if (action_prepareItem != NULL) + action_prepareItem(&listItems.items[i], index, i); + } + else + { + listItems.items[i].icon = CHARICON_NULL; + } + } + } + + // only 1 page or in first page, hide up button + listItems.items[5].icon = ((maxItemCount <= LISTITEM_PER_PAGE) || (curPage == 0)) ? CHARICON_NULL : CHARICON_PAGEUP; + // only 1 page or in last page, hide down button + listItems.items[6].icon = ((maxItemCount <= LISTITEM_PER_PAGE) || (curPage == maxPageCount - 1)) ? CHARICON_NULL : CHARICON_PAGEDOWN; + + listItems.items[7].icon = CHARICON_BACK; + + curPageIndex = curPage; +} + /** * @brief Set and innitialize list menu * @@ -60,46 +98,8 @@ uint8_t listViewGetCurPage(void) return curPageIndex; } -// display page at selected index -void listViewSetCurPage(uint8_t curPage) -{ - if (action_preparePage != NULL) - { - action_preparePage(&listItems, curPage); - } - else - { - for (uint8_t i = 0; i < LISTITEM_PER_PAGE; i++) - { - uint16_t index = curPage * LISTITEM_PER_PAGE + i; - - if (index < maxItemCount) - { - if (totalItems != NULL) - listItems.items[i] = totalItems[index]; - - if (action_prepareItem != NULL) - action_prepareItem(&listItems.items[i], index, i); - } - else - { - listItems.items[i].icon = CHARICON_NULL; - } - } - } - - // only 1 page or in first page, hide up button - listItems.items[5].icon = ((maxItemCount <= LISTITEM_PER_PAGE) || (curPage == 0)) ? CHARICON_NULL : CHARICON_PAGEUP; - // only 1 page or in last page, hide down button - listItems.items[6].icon = ((maxItemCount <= LISTITEM_PER_PAGE) || (curPage == maxPageCount - 1)) ? CHARICON_NULL : CHARICON_PAGEDOWN; - - listItems.items[7].icon = CHARICON_BACK; - - curPageIndex = curPage; -} - // open next page -bool listViewNextPage(void) +static bool listViewNextPage(void) { if (maxPageCount <= 1) return false; // only 0 or 1 page, can't goto next page if (curPageIndex + 1 >= maxPageCount) return false; // already last page @@ -116,7 +116,7 @@ bool listViewNextPage(void) } // open previous page -bool listViewPreviousPage(void) +static bool listViewPreviousPage(void) { if (maxPageCount <= 1) return false; // only 0 or 1 page, can't goto previous page if (curPageIndex == 0) return false; // already first page diff --git a/TFT/src/User/API/UI/ListManager.h b/TFT/src/User/API/UI/ListManager.h index 0768675109..64664ed98d 100644 --- a/TFT/src/User/API/UI/ListManager.h +++ b/TFT/src/User/API/UI/ListManager.h @@ -14,9 +14,6 @@ void listViewCreate(LABEL title, LISTITEM * items, uint16_t max_items, uint16_t void (*prepareItem_action)(LISTITEM * item, uint16_t index, uint8_t itemPos)); void listViewSetTitle(LABEL title); -void listViewSetCurPage(uint8_t cur_page); -bool listViewPreviousPage(void); -bool listViewNextPage(void); void listViewRefreshPage(void); void listViewRefreshMenu(void); void listViewRefreshItem(uint16_t item); diff --git a/TFT/src/User/API/boot.c b/TFT/src/User/API/boot.c index feb78b4cdd..71e5eb6b5d 100644 --- a/TFT/src/User/API/boot.c +++ b/TFT/src/User/API/boot.c @@ -133,6 +133,35 @@ BMPUPDATE_STAT bmpDecode(char * bmp, uint32_t addr) return BMP_SUCCESS; } +void dispIconFail(uint8_t * lbl, BMPUPDATE_STAT bmpState) +{ + char * stat_txt; + char error_txt[30]; + + GUI_SetColor(infoSettings.reminder_color); + GUI_ClearPrect(&labelFailedRect); + GUI_DispString(labelFailedRect.x0, labelFailedRect.y0, lbl); + + switch (bmpState) + { + case BMP_INVALIDFILE: + stat_txt = "BMP file not valid "; + break; + case BMP_NOT24BIT: + stat_txt = "Format is not 24Bit"; + break; + case BMP_NOTFOUND: + default: + stat_txt = "BMP file not found "; + break; + } + + sprintf(error_txt, "Error: %s", stat_txt); + GUI_DispString(labelFailedRect.x0, labelFailedRect.y0 + BYTE_HEIGHT + 2, (uint8_t *)error_txt); + GUI_RestoreColorDefault(); + Delay_ms(1000); // give some time to the user to read failed icon name. +} + static inline bool updateIcon(char * rootDir) { uint16_t found = 0; @@ -208,36 +237,7 @@ static inline bool updateIcon(char * rootDir) return false; } -void dispIconFail(uint8_t * lbl, BMPUPDATE_STAT bmpState) -{ - char * stat_txt; - char error_txt[30]; - - GUI_SetColor(infoSettings.reminder_color); - GUI_ClearPrect(&labelFailedRect); - GUI_DispString(labelFailedRect.x0, labelFailedRect.y0, lbl); - - switch (bmpState) - { - case BMP_INVALIDFILE: - stat_txt = "BMP file not valid "; - break; - case BMP_NOT24BIT: - stat_txt = "Format is not 24Bit"; - break; - case BMP_NOTFOUND: - default: - stat_txt = "BMP file not found "; - break; - } - - sprintf(error_txt, "Error: %s", stat_txt); - GUI_DispString(labelFailedRect.x0, labelFailedRect.y0 + BYTE_HEIGHT + 2, (uint8_t *)error_txt); - GUI_RestoreColorDefault(); - Delay_ms(1000); // give some time to the user to read failed icon name. -} - -bool updateFont(char * font, uint32_t addr) +static bool updateFont(char * font, uint32_t addr) { uint8_t progress = 0; UINT rnum = 0; diff --git a/TFT/src/User/API/boot.h b/TFT/src/User/API/boot.h index 39534600bc..d46271c61b 100644 --- a/TFT/src/User/API/boot.h +++ b/TFT/src/User/API/boot.h @@ -112,7 +112,6 @@ typedef union } GUI_COLOR; void scanUpdates(void); -void dispIconFail(uint8_t * lbl, BMPUPDATE_STAT bmpState); BMPUPDATE_STAT bmpDecode(char * bmp, uint32_t addr); #ifdef __cplusplus diff --git a/TFT/src/User/API/config.c b/TFT/src/User/API/config.c index 0e63e21b3e..71a8180c3f 100644 --- a/TFT/src/User/API/config.c +++ b/TFT/src/User/API/config.c @@ -40,109 +40,71 @@ uint8_t customcode_index = 0; uint8_t customcode_good[CUSTOM_GCODES_COUNT]; bool scheduleRotate = false; -bool getConfigFromFile(char * configPath) +static void drawProgressPage(uint8_t * title) { - if (f_file_exists(configPath) == false) - { - PRINTDEBUG("configFile not found\n"); - return false; - } - - CUSTOM_GCODES tempCustomGcodes; - PRINT_GCODES tempPrintCodes; - STRINGS_STORE tempStringStore; - PREHEAT_STORE tempPreheatStore; - - configCustomGcodes = &tempCustomGcodes; - configPrintGcodes = &tempPrintCodes; - configStringsStore = &tempStringStore; - configPreheatStore = &tempPreheatStore; - customcode_index = 0; - foundkeys = 0; - - char cur_line_buffer[LINE_MAX_CHAR]; - cur_line = cur_line_buffer; - - drawProgressPage((uint8_t*)"Updating Configuration..."); - - if (readConfigFile(configPath, parseConfigLine, LINE_MAX_CHAR)) - { - // store custom codes count - configCustomGcodes->count = customcode_index; - - PRINTDEBUG("\nCustom gcode stored at 1:"); - PRINTDEBUG(configCustomGcodes->gcode[1]); - if (scheduleRotate) - { - LCD_RefreshDirection(infoSettings.rotated_ui); - TSC_Calibration(); - } - storePara(); // TODO: The touch sign will also be written if the touch calibration data is invalid - saveConfig(); - PRINTDEBUG("config saved\n"); - return true; - } - else - { - PRINTDEBUG("configFile save failed\n"); - return false; - } + GUI_Clear(BLACK); + GUI_DispString(2, 2, title); + GUI_FillRectColor(rectTitleline.x0, rectTitleline.y0, rectTitleline.x1, rectTitleline.y1, BLUE); + GUI_DrawPrect(&rectProgressframe); } -bool getLangFromFile(char * rootDir) +static void drawProgress(void) { - bool success = false; - foundkeys = 0; - DIR d; - FILINFO f; - FRESULT r = f_findfirst(&d, &f, rootDir, "language_*.ini"); - - f_closedir(&d); - if (r != FR_OK) - return false; - - char langpath[256]; - sprintf(langpath, "%s/%s", rootDir, f.fname); - - if (!f_file_exists(langpath)) - return false; + char tempstr[50]; + sprintf(tempstr, "Total keywords found: %d", foundkeys); + GUI_DispString(pointProgressText.x, pointProgressText.y, (uint8_t *)tempstr); + uint16_t p = map(CurConfigFile->cur, 0, CurConfigFile->size, rectProgressframe.x0, rectProgressframe.x1); + GUI_FillRect(rectProgressframe.x0, rectProgressframe.y0, p, rectProgressframe.y1); +} - char cur_line_buffer[MAX_LANG_LABEL_LENGTH + 100]; - cur_line = cur_line_buffer; +static void showError(CONFIG_STATS stat) +{ + char *ttl; + char *txt; + char tempstr[50]; - drawProgressPage((uint8_t*)f.fname); + GUI_SetBkColor(BLACK); + GUI_SetColor(RED); + GUI_ClearPrect(&recterrortxt); + GUI_DrawPrect(&recterror); - // erase part of flash to be rewritten - for (int i = 0; i < (LANGUAGE_SIZE / W25QXX_SECTOR_SIZE); i++) + switch (stat) { - W25Qxx_EraseSector(LANGUAGE_ADDR + (i * W25QXX_SECTOR_SIZE)); - } + case CSTAT_INVALID_VALUE: + GUI_SetColor(ORANGE); + ttl = "Invalid Value(s) in:"; + txt = cur_line; + break; - success = readConfigFile(langpath, parseLangLine, MAX_LANG_LABEL_LENGTH + 100); + case CSTAT_UNKNOWN_KEYWORD: + ttl = "Invalid Keyword:"; + txt = cur_line; + break; - if (foundkeys != LABEL_NUM) - { - showError(CSTAT_FILE_INVALID); - success = false; - } - else - { // rename file if update was successful - if (!f_file_exists(FILE_ADMIN_MODE) && f_file_exists(langpath)) - { // language exists - char newlangpath[256]; - sprintf(newlangpath, "%s/%s.CUR", rootDir, f.fname); + case CSTAT_FILE_NOTOPEN: + ttl = "Error:"; + sprintf(tempstr, "Unable to open %s", CONFIG_FILE_PATH); + txt = tempstr; + break; - if (f_file_exists(newlangpath)) - { // old language also exists - f_unlink(newlangpath); - } - f_rename(langpath, newlangpath); - } + case CSTAT_STORAGE_LOW: + ttl = "Write Error:"; + txt = "Config size is larger than allocated size"; + break; + + case CSTAT_FILE_INVALID: + default: + ttl = "Error:"; + txt = "Invalid config File"; + break; } - return success; + GUI_DispString(recterrortxt.x0, recterrortxt.y0, (uint8_t*)ttl); + GUI_DispStringInRect(recterrortxt.x0, recterrortxt.y0 + (BYTE_HEIGHT * 2), recterrortxt.x1, recterrortxt.y1, (uint8_t*)txt); + GUI_SetColor(WHITE); + Delay_ms(5000); } -bool readConfigFile(const char * path, void (* lineParser)(), uint16_t maxLineLen) +static bool readConfigFile(const char * path, void (* lineParser)(), uint16_t maxLineLen) { bool comment_mode = false; bool comment_space = true; @@ -234,22 +196,8 @@ bool readConfigFile(const char * path, void (* lineParser)(), uint16_t maxLineLe } } -// check if the value is within min and max limits -bool inLimit(int val, int min, int max) -{ - if (val < min || val > max) - { - showError(CSTAT_INVALID_VALUE); - return false; - } - else - { - return true; - } -} - // check if config keyword exits in the buffer line -bool key_seen(const char * keyStr) +static bool key_seen(const char * keyStr) { uint16_t i; for (c_index = 0, i = 0; c_index < LINE_MAX_CHAR && cur_line[c_index] != '\0'; c_index++, i = 0) @@ -267,7 +215,7 @@ bool key_seen(const char * keyStr) } // check if config keyword exits with a full matching in the buffer line -bool param_seen(const char * keyStr) +static bool param_seen(const char * keyStr) { bool found = key_seen(keyStr); if (found) @@ -282,97 +230,22 @@ bool param_seen(const char * keyStr) return found; } -// Get the int after config keyword. -static inline int config_int(void) -{ - return (strtol(&cur_line[c_index], NULL, 10)); -} - -// Get valid int value or old value -static int valid_intValue(int min, int max, int defaultVal) -{ - if (inLimit(config_int(), min, max)) - return config_int(); - else - return defaultVal; -} - -// Treat all values other than 0 as 1. -int8_t getOnOff(void) -{ - if (config_int() == 0) - return 0; - else - return 1; -} - -// Get the float after config keyword. -static inline float config_float(void) -{ - return (strtod(&cur_line[c_index], NULL)); -} - -// Get valid float value or old value -static float valid_floatValue(float min, float max, float defaultVal) -{ - if (inLimit(config_float(), min, max)) - return config_float(); - else - return defaultVal; -} - -// check if value is hex format -static inline bool config_is_hex(void) -{ - return (strstr(&cur_line[c_index], "0x") != NULL); -} - -// Get the hex after config keyword. -static inline uint32_t config_hex(void) -{ - return (strtol(&cur_line[c_index], NULL, 16)); -} - -// convert RGB888 to RGB565 -static inline uint16_t RGB888_to_RGB565(uint32_t rgb888) -{ - uint8_t r = ((rgb888 >> 16) & 0xFF) >> 3; // R5 - uint8_t g = ((rgb888 >> 8) & 0xFF) >> 2; // G6 - uint8_t b = (rgb888 & 0xFF) >> 3; // B5 - return ((r << 11) | (g << 5) | b); -} - -static inline void config_set_color(uint16_t *color_src) +// check if the value is within min and max limits +static bool inLimit(int val, int min, int max) { - if (config_is_hex()) - { - *color_src = RGB888_to_RGB565(config_hex()); - } - else if (inLimit(config_int(), 0, LCD_COLOR_COUNT - 1)) + if (val < min || val > max) { - *color_src = lcd_colors[config_int()]; + showError(CSTAT_INVALID_VALUE); + return false; } -} - -// check keywords in the config line in buffer -void parseConfigLine(void) -{ - for (uint16_t i = 0; i < CONFIG_COUNT; i++) + else { - if (param_seen(config_keywords[i])) - { - PRINTDEBUG("\n"); - PRINTDEBUG((char *)config_keywords[i]); - parseConfigKey(i); - foundkeys++; - return; - } + return true; } - showError(CSTAT_UNKNOWN_KEYWORD); } // parse keywords from line read from language file -void parseLangLine(void) +static void parseLangLine(void) { for (int i = 0; i < LABEL_NUM; i++) { @@ -403,151 +276,80 @@ void parseLangLine(void) showError(CSTAT_UNKNOWN_KEYWORD); } -void saveConfig(void) +// Get the int after config keyword. +static inline int config_int(void) { - writeConfig((uint8_t *)configCustomGcodes, sizeof(CUSTOM_GCODES), CUSTOM_GCODE_ADDR, CUSTOM_GCODE_MAX_SIZE); - writeConfig((uint8_t *)configPrintGcodes, sizeof(PRINT_GCODES), PRINT_GCODES_ADDR, PRINT_GCODES_MAX_SIZE); - writeConfig((uint8_t *)configStringsStore, sizeof(STRINGS_STORE), STRINGS_STORE_ADDR, STRINGS_STORE_MAX_SIZE); - writeConfig((uint8_t *)configPreheatStore, sizeof(PREHEAT_STORE), PREHEAT_STORE_ADDR, PREHEAT_STORE_MAX_SIZE); - - #ifdef CONFIG_DEBUG - CUSTOM_GCODES tempgcode; // = NULL; - uint8_t * data_r = (uint8_t *)&tempgcode; - - W25Qxx_ReadBuffer(data_r, CUSTOM_GCODE_ADDR, sizeof(CUSTOM_GCODES)); - PRINTDEBUG("\nread done"); - PRINTDEBUG("\nread from flash:"); - PRINTDEBUG(tempgcode.gcode[1]); - #endif + return (strtol(&cur_line[c_index], NULL, 10)); } -void writeConfig(uint8_t * dataBytes, uint16_t numBytes, uint32_t addr, uint32_t maxSize) +// Get valid int value or old value +static int valid_intValue(int min, int max, int defaultVal) { - // do not proceed if data size is larger than reserved max size. - if (numBytes > maxSize) - { - PRINTDEBUG("\nwrite error\n"); - showError(CSTAT_STORAGE_LOW); - return; - } - int sectorCount = maxSize / W25QXX_SECTOR_SIZE; - - // erase part of flash to be rewritten - for (int i = 0; i < sectorCount; i++) - { - W25Qxx_EraseSector(addr + (i * W25QXX_SECTOR_SIZE)); - } - Delay_ms(100); // give time for spi flash to settle - W25Qxx_WriteBuffer(dataBytes, addr, numBytes); // write data to spi flash - Delay_ms(100); // give time for spi flash to settle + if (inLimit(config_int(), min, max)) + return config_int(); + else + return defaultVal; } -// Reset & store config settings -void resetConfig(void) +// Treat all values other than 0 as 1. +static int8_t getOnOff(void) { - CUSTOM_GCODES tempCG; - STRINGS_STORE tempST; - PRINT_GCODES tempPC; - PREHEAT_STORE tempPH; - - // restore custom gcode presets - int n = 0; - for (int i = 0; i < CUSTOM_GCODES_COUNT; i++) - { - if (default_custom_enabled[i] == 1) - { - strcpy(tempCG.gcode[n],cgList[i]); - strcpy(tempCG.name[n],cgNames[i]); - n++; - } - } - tempCG.count = n; - - // restore strings store - strcpy(tempST.marlin_title, MARLIN_TITLE); - - for (int i = 0; i < PREHEAT_COUNT; i++) - { - strcpy(tempPH.preheat_name[i], preheatNames[i]); - } + if (config_int() == 0) + return 0; + else + return 1; +} - // restore print gcodes - strcpy(tempPC.start_gcode, START_GCODE); - strcpy(tempPC.end_gcode, END_GCODE); - strcpy(tempPC.cancel_gcode, CANCEL_GCODE); +// Get the float after config keyword. +static inline float config_float(void) +{ + return (strtod(&cur_line[c_index], NULL)); +} - // write restored config - writeConfig((uint8_t *)&tempCG, sizeof(CUSTOM_GCODES), CUSTOM_GCODE_ADDR, CUSTOM_GCODE_MAX_SIZE); - writeConfig((uint8_t *)&tempPC, sizeof(PRINT_GCODES), PRINT_GCODES_ADDR, PRINT_GCODES_MAX_SIZE); - writeConfig((uint8_t *)&tempST, sizeof(STRINGS_STORE), STRINGS_STORE_ADDR, STRINGS_STORE_MAX_SIZE); +// Get valid float value or old value +static float valid_floatValue(float min, float max, float defaultVal) +{ + if (inLimit(config_float(), min, max)) + return config_float(); + else + return defaultVal; } -void drawProgressPage(uint8_t * title) +// check if value is hex format +static inline bool config_is_hex(void) { - GUI_Clear(BLACK); - GUI_DispString(2, 2, title); - GUI_FillRectColor(rectTitleline.x0, rectTitleline.y0, rectTitleline.x1, rectTitleline.y1, BLUE); - GUI_DrawPrect(&rectProgressframe); + return (strstr(&cur_line[c_index], "0x") != NULL); +} + +// Get the hex after config keyword. +static inline uint32_t config_hex(void) +{ + return (strtol(&cur_line[c_index], NULL, 16)); } -void drawProgress(void) +// convert RGB888 to RGB565 +static inline uint16_t RGB888_to_RGB565(uint32_t rgb888) { - char tempstr[50]; - sprintf(tempstr, "Total keywords found: %d", foundkeys); - GUI_DispString(pointProgressText.x, pointProgressText.y, (uint8_t *)tempstr); - uint16_t p = map(CurConfigFile->cur, 0, CurConfigFile->size, rectProgressframe.x0, rectProgressframe.x1); - GUI_FillRect(rectProgressframe.x0, rectProgressframe.y0, p, rectProgressframe.y1); + uint8_t r = ((rgb888 >> 16) & 0xFF) >> 3; // R5 + uint8_t g = ((rgb888 >> 8) & 0xFF) >> 2; // G6 + uint8_t b = (rgb888 & 0xFF) >> 3; // B5 + return ((r << 11) | (g << 5) | b); } -void showError(CONFIG_STATS stat) +static inline void config_set_color(uint16_t *color_src) { - char *ttl; - char *txt; - char tempstr[50]; - - GUI_SetBkColor(BLACK); - GUI_SetColor(RED); - GUI_ClearPrect(&recterrortxt); - GUI_DrawPrect(&recterror); - - switch (stat) + if (config_is_hex()) { - case CSTAT_INVALID_VALUE: - GUI_SetColor(ORANGE); - ttl = "Invalid Value(s) in:"; - txt = cur_line; - break; - - case CSTAT_UNKNOWN_KEYWORD: - ttl = "Invalid Keyword:"; - txt = cur_line; - break; - - case CSTAT_FILE_NOTOPEN: - ttl = "Error:"; - sprintf(tempstr, "Unable to open %s", CONFIG_FILE_PATH); - txt = tempstr; - break; - - case CSTAT_STORAGE_LOW: - ttl = "Write Error:"; - txt = "Config size is larger than allocated size"; - break; - - case CSTAT_FILE_INVALID: - default: - ttl = "Error:"; - txt = "Invalid config File"; - break; + *color_src = RGB888_to_RGB565(config_hex()); + } + else if (inLimit(config_int(), 0, LCD_COLOR_COUNT - 1)) + { + *color_src = lcd_colors[config_int()]; } - GUI_DispString(recterrortxt.x0, recterrortxt.y0, (uint8_t*)ttl); - GUI_DispStringInRect(recterrortxt.x0, recterrortxt.y0 + (BYTE_HEIGHT * 2), recterrortxt.x1, recterrortxt.y1, (uint8_t*)txt); - GUI_SetColor(WHITE); - Delay_ms(5000); } // parse the keyword values in the buffer -void parseConfigKey(uint16_t index) +static void parseConfigKey(uint16_t index) { switch (index) { @@ -1156,3 +958,201 @@ void parseConfigKey(uint16_t index) break; } } + +// check keywords in the config line in buffer +static void parseConfigLine(void) +{ + for (uint16_t i = 0; i < CONFIG_COUNT; i++) + { + if (param_seen(config_keywords[i])) + { + PRINTDEBUG("\n"); + PRINTDEBUG((char *)config_keywords[i]); + parseConfigKey(i); + foundkeys++; + return; + } + } + showError(CSTAT_UNKNOWN_KEYWORD); +} + +static void writeConfig(uint8_t * dataBytes, uint16_t numBytes, uint32_t addr, uint32_t maxSize) +{ + // do not proceed if data size is larger than reserved max size. + if (numBytes > maxSize) + { + PRINTDEBUG("\nwrite error\n"); + showError(CSTAT_STORAGE_LOW); + return; + } + int sectorCount = maxSize / W25QXX_SECTOR_SIZE; + + // erase part of flash to be rewritten + for (int i = 0; i < sectorCount; i++) + { + W25Qxx_EraseSector(addr + (i * W25QXX_SECTOR_SIZE)); + } + Delay_ms(100); // give time for spi flash to settle + W25Qxx_WriteBuffer(dataBytes, addr, numBytes); // write data to spi flash + Delay_ms(100); // give time for spi flash to settle +} + +static void saveConfig(void) +{ + writeConfig((uint8_t *)configCustomGcodes, sizeof(CUSTOM_GCODES), CUSTOM_GCODE_ADDR, CUSTOM_GCODE_MAX_SIZE); + writeConfig((uint8_t *)configPrintGcodes, sizeof(PRINT_GCODES), PRINT_GCODES_ADDR, PRINT_GCODES_MAX_SIZE); + writeConfig((uint8_t *)configStringsStore, sizeof(STRINGS_STORE), STRINGS_STORE_ADDR, STRINGS_STORE_MAX_SIZE); + writeConfig((uint8_t *)configPreheatStore, sizeof(PREHEAT_STORE), PREHEAT_STORE_ADDR, PREHEAT_STORE_MAX_SIZE); + + #ifdef CONFIG_DEBUG + CUSTOM_GCODES tempgcode; // = NULL; + uint8_t * data_r = (uint8_t *)&tempgcode; + + W25Qxx_ReadBuffer(data_r, CUSTOM_GCODE_ADDR, sizeof(CUSTOM_GCODES)); + PRINTDEBUG("\nread done"); + PRINTDEBUG("\nread from flash:"); + PRINTDEBUG(tempgcode.gcode[1]); + #endif +} + +// Reset & store config settings +void resetConfig(void) +{ + CUSTOM_GCODES tempCG; + STRINGS_STORE tempST; + PRINT_GCODES tempPC; + PREHEAT_STORE tempPH; + + // restore custom gcode presets + int n = 0; + for (int i = 0; i < CUSTOM_GCODES_COUNT; i++) + { + if (default_custom_enabled[i] == 1) + { + strcpy(tempCG.gcode[n],cgList[i]); + strcpy(tempCG.name[n],cgNames[i]); + n++; + } + } + tempCG.count = n; + + // restore strings store + strcpy(tempST.marlin_title, MARLIN_TITLE); + + for (int i = 0; i < PREHEAT_COUNT; i++) + { + strcpy(tempPH.preheat_name[i], preheatNames[i]); + } + + // restore print gcodes + strcpy(tempPC.start_gcode, START_GCODE); + strcpy(tempPC.end_gcode, END_GCODE); + strcpy(tempPC.cancel_gcode, CANCEL_GCODE); + + // write restored config + writeConfig((uint8_t *)&tempCG, sizeof(CUSTOM_GCODES), CUSTOM_GCODE_ADDR, CUSTOM_GCODE_MAX_SIZE); + writeConfig((uint8_t *)&tempPC, sizeof(PRINT_GCODES), PRINT_GCODES_ADDR, PRINT_GCODES_MAX_SIZE); + writeConfig((uint8_t *)&tempST, sizeof(STRINGS_STORE), STRINGS_STORE_ADDR, STRINGS_STORE_MAX_SIZE); +} + +bool getConfigFromFile(char * configPath) +{ + if (f_file_exists(configPath) == false) + { + PRINTDEBUG("configFile not found\n"); + return false; + } + + CUSTOM_GCODES tempCustomGcodes; + PRINT_GCODES tempPrintCodes; + STRINGS_STORE tempStringStore; + PREHEAT_STORE tempPreheatStore; + + configCustomGcodes = &tempCustomGcodes; + configPrintGcodes = &tempPrintCodes; + configStringsStore = &tempStringStore; + configPreheatStore = &tempPreheatStore; + customcode_index = 0; + foundkeys = 0; + + char cur_line_buffer[LINE_MAX_CHAR]; + cur_line = cur_line_buffer; + + drawProgressPage((uint8_t*)"Updating Configuration..."); + + if (readConfigFile(configPath, parseConfigLine, LINE_MAX_CHAR)) + { + // store custom codes count + configCustomGcodes->count = customcode_index; + + PRINTDEBUG("\nCustom gcode stored at 1:"); + PRINTDEBUG(configCustomGcodes->gcode[1]); + if (scheduleRotate) + { + LCD_RefreshDirection(infoSettings.rotated_ui); + TSC_Calibration(); + } + storePara(); // TODO: The touch sign will also be written if the touch calibration data is invalid + saveConfig(); + PRINTDEBUG("config saved\n"); + return true; + } + else + { + PRINTDEBUG("configFile save failed\n"); + return false; + } +} + +bool getLangFromFile(char * rootDir) +{ + bool success = false; + foundkeys = 0; + DIR d; + FILINFO f; + FRESULT r = f_findfirst(&d, &f, rootDir, "language_*.ini"); + + f_closedir(&d); + if (r != FR_OK) + return false; + + char langpath[256]; + sprintf(langpath, "%s/%s", rootDir, f.fname); + + if (!f_file_exists(langpath)) + return false; + + char cur_line_buffer[MAX_LANG_LABEL_LENGTH + 100]; + cur_line = cur_line_buffer; + + drawProgressPage((uint8_t*)f.fname); + + // erase part of flash to be rewritten + for (int i = 0; i < (LANGUAGE_SIZE / W25QXX_SECTOR_SIZE); i++) + { + W25Qxx_EraseSector(LANGUAGE_ADDR + (i * W25QXX_SECTOR_SIZE)); + } + + success = readConfigFile(langpath, parseLangLine, MAX_LANG_LABEL_LENGTH + 100); + + if (foundkeys != LABEL_NUM) + { + showError(CSTAT_FILE_INVALID); + success = false; + } + else + { // rename file if update was successful + if (!f_file_exists(FILE_ADMIN_MODE) && f_file_exists(langpath)) + { // language exists + char newlangpath[256]; + sprintf(newlangpath, "%s/%s.CUR", rootDir, f.fname); + + if (f_file_exists(newlangpath)) + { // old language also exists + f_unlink(newlangpath); + } + f_rename(langpath, newlangpath); + } + } + return success; +} diff --git a/TFT/src/User/API/config.h b/TFT/src/User/API/config.h index 8024e7719d..0bf6a6a43a 100644 --- a/TFT/src/User/API/config.h +++ b/TFT/src/User/API/config.h @@ -223,20 +223,8 @@ typedef enum bool getConfigFromFile(char * configPath); bool getLangFromFile(char * rootDir); -bool readConfigFile(const char * path, void (* lineParser)(), uint16_t maxLineLen); - -void parseConfigLine(void); -void parseLangLine(void); - -void parseConfigKey(uint16_t index); -void writeConfig(uint8_t* dataBytes, uint16_t numBytes, uint32_t addr, uint32_t maxSize); -void saveConfig(void); void resetConfig(void); -void drawProgressPage(uint8_t * title); -void drawProgress(void); -void showError(CONFIG_STATS stat); - // This List is Auto-Generated. Please add new config in config.inc only enum { diff --git a/TFT/src/User/API/interfaceCmd.c b/TFT/src/User/API/interfaceCmd.c index cfe3522a92..9637c9a1c0 100644 --- a/TFT/src/User/API/interfaceCmd.c +++ b/TFT/src/User/API/interfaceCmd.c @@ -208,7 +208,7 @@ void clearCmdQueue(void) // Strip out any leading space from the passed command. // Furthermore, skip any N[-0-9] (line number) and return a pointer to the beginning of the command. -char * stripCmd(char ** cmdPtr) +static char * stripCmd(char ** cmdPtr) { char * strPtr = *cmdPtr; @@ -355,7 +355,7 @@ static float cmd_float(void) return (strtod(&cmd_ptr[cmd_index], NULL)); } -bool initRemoteTFT() +static bool initRemoteTFT() { // examples: // @@ -388,7 +388,7 @@ bool initRemoteTFT() return true; } -bool openRemoteTFT(bool writingMode) +static bool openRemoteTFT(bool writingMode) { bool open = false; @@ -440,7 +440,7 @@ bool openRemoteTFT(bool writingMode) return open; } -void writeRemoteTFT() +static void writeRemoteTFT() { // examples: // @@ -475,7 +475,7 @@ void writeRemoteTFT() Serial_Forward(cmd_port_index, "ok\n"); } -void setWaitHeating(uint8_t index) +static void setWaitHeating(uint8_t index) { if (cmd_seen('R')) { @@ -488,7 +488,7 @@ void setWaitHeating(uint8_t index) } } -void syncTargetTemp(uint8_t index) +static void syncTargetTemp(uint8_t index) { uint16_t temp; diff --git a/TFT/src/User/API/menu.c b/TFT/src/User/API/menu.c index 253a8dd06b..acda9eba95 100644 --- a/TFT/src/User/API/menu.c +++ b/TFT/src/User/API/menu.c @@ -822,6 +822,56 @@ void menuDrawTitle(void) if (reminder.status != SYS_STATUS_IDLE) drawReminderMsg(); } +// When there is a button value, the icon changes color and redraws +static void itemDrawIconPress(uint8_t position, uint8_t is_press) +{ + if (position > KEY_ICON_7) return; + + if (menuType == MENU_TYPE_ICON) + { + if (curMenuItems == NULL) return; + if (curMenuItems->items[position].icon == ICON_NULL) return; + + const GUI_RECT *rect = curRect + position; + + if (is_press) // Turn green when pressed + ICON_PressedDisplay(rect->x0, rect->y0, curMenuItems->items[position].icon); + else // Redraw normal icon when released + ICON_ReadDisplay(rect->x0, rect->y0,curMenuItems->items[position].icon); + } + else if (menuType == MENU_TYPE_LISTVIEW) + { // draw rec over list item if pressed + if (curListItems == NULL) + return; + + const GUI_RECT *rect = rect_of_keyListView + position; + + if (curListItems->items[position].icon == CHARICON_NULL) + { + GUI_ClearPrect(rect); + return; + } + if (is_press) + ListItem_Display(rect,position,&curListItems->items[position], true); + else + ListItem_Display(rect,position,&curListItems->items[position], false); + } +} + +// When there is a button value, the icon changes color and redraws +static void itemDrawIconPress_PS(uint8_t position, uint8_t is_press) +{ + if (position < PS_KEY_6 || position > PS_KEY_9) return; + position -= PS_TOUCH_OFFSET; + + const GUI_RECT *rect = curRect + position; + + if (is_press) // Turn green when pressed + ICON_PressedDisplay(rect->x0, rect->y0, curMenuItems->items[position].icon); + else // Redraw normal icon when released + ICON_ReadDisplay(rect->x0, rect->y0,curMenuItems->items[position].icon); +} + // Draw the entire interface void menuDrawPage(const MENUITEMS *menuItems) { @@ -993,56 +1043,6 @@ void displayExhibitValue(const char * valueStr) setFontSize(FONT_SIZE_NORMAL); } -// When there is a button value, the icon changes color and redraws -void itemDrawIconPress(uint8_t position, uint8_t is_press) -{ - if (position > KEY_ICON_7) return; - - if (menuType == MENU_TYPE_ICON) - { - if (curMenuItems == NULL) return; - if (curMenuItems->items[position].icon == ICON_NULL) return; - - const GUI_RECT *rect = curRect + position; - - if (is_press) // Turn green when pressed - ICON_PressedDisplay(rect->x0, rect->y0, curMenuItems->items[position].icon); - else // Redraw normal icon when released - ICON_ReadDisplay(rect->x0, rect->y0,curMenuItems->items[position].icon); - } - else if (menuType == MENU_TYPE_LISTVIEW) - { // draw rec over list item if pressed - if (curListItems == NULL) - return; - - const GUI_RECT *rect = rect_of_keyListView + position; - - if (curListItems->items[position].icon == CHARICON_NULL) - { - GUI_ClearPrect(rect); - return; - } - if (is_press) - ListItem_Display(rect,position,&curListItems->items[position], true); - else - ListItem_Display(rect,position,&curListItems->items[position], false); - } -} - -// When there is a button value, the icon changes color and redraws -void itemDrawIconPress_PS(uint8_t position, uint8_t is_press) -{ - if (position < PS_KEY_6 || position > PS_KEY_9) return; - position -= PS_TOUCH_OFFSET; - - const GUI_RECT *rect = curRect + position; - - if (is_press) // Turn green when pressed - ICON_PressedDisplay(rect->x0, rect->y0, curMenuItems->items[position].icon); - else // Redraw normal icon when released - ICON_ReadDisplay(rect->x0, rect->y0,curMenuItems->items[position].icon); -} - // Get button value KEY_VALUES menuKeyGetValue(void) { @@ -1128,7 +1128,7 @@ KEY_VALUES menuKeyGetValue(void) // Smart home (long press on back button to go to status screen) #ifdef SMART_HOME -void loopCheckBackPress(void) +static void loopCheckBackPress(void) { static bool longPress = false; diff --git a/TFT/src/User/API/menu.h b/TFT/src/User/API/menu.h index d27df4c1f7..f41dd55e29 100644 --- a/TFT/src/User/API/menu.h +++ b/TFT/src/User/API/menu.h @@ -200,15 +200,11 @@ void showLiveInfo(uint8_t index, const LIVE_INFO * liveicon, bool redrawIcon); void displayExhibitHeader(const char * titleStr, const char * unitStr); void displayExhibitValue(const char * valueStr); -void itemDrawIconPress(uint8_t position, uint8_t is_press); -void itemDrawIconPress_PS(uint8_t position, uint8_t is_press); KEY_VALUES menuKeyGetValue(void); // Smart home #ifdef SMART_HOME #define LONG_TOUCH (MODE_SWITCHING_INTERVAL / 3) // keep it lower than MODE_SWITCHING_INTERVAL - - void loopCheckBackPress(void); #endif void menuDummy(void); diff --git a/TFT/src/User/API/parseACK.c b/TFT/src/User/API/parseACK.c index d43a332caf..0e32928d42 100644 --- a/TFT/src/User/API/parseACK.c +++ b/TFT/src/User/API/parseACK.c @@ -151,7 +151,7 @@ static float ack_second_value() return -0.5; } -void ack_values_sum(float * data) +static void ack_values_sum(float * data) { while (((ack_cache[ack_index] < '0') || (ack_cache[ack_index] > '9')) && ack_cache[ack_index] != '\n') { @@ -170,7 +170,7 @@ void ack_values_sum(float * data) ack_values_sum(data); } -void ackPopupInfo(const char * info) +static void ackPopupInfo(const char * info) { bool show_dialog = true; @@ -202,7 +202,7 @@ void ackPopupInfo(const char * info) } } -bool processKnownEcho(void) +static bool processKnownEcho(void) { bool isKnown = false; uint8_t i; @@ -238,7 +238,7 @@ bool processKnownEcho(void) return isKnown; } -void hostActionCommands(void) +static void __attribute__ ((noinline)) hostActionCommands(void) { if (ack_seen(":notification ")) { diff --git a/TFT/src/User/Fatfs/myfatfs.c b/TFT/src/User/Fatfs/myfatfs.c index 7e79bb917b..f337680026 100644 --- a/TFT/src/User/Fatfs/myfatfs.c +++ b/TFT/src/User/Fatfs/myfatfs.c @@ -12,7 +12,7 @@ FATFS fatfs[FF_VOLUMES]; // FATFS work area * @param name2 name of second file/folder * @param date2 date/time for second file/folder */ -bool compareFile(char * name1, uint32_t date1, char * name2, uint32_t date2) +static bool compareFile(char * name1, uint32_t date1, char * name2, uint32_t date2) { if (infoSettings.files_sort_by <= SORT_DATE_OLD_FIRST) // sort by date { @@ -42,7 +42,7 @@ bool compareFile(char * name1, uint32_t date1, char * name2, uint32_t date2) /** * sort file list */ -void sortFile(uint16_t fileCount, TCHAR * fileName[], uint32_t fileDate[]) +static void sortFile(uint16_t fileCount, TCHAR * fileName[], uint32_t fileDate[]) { for (int i = 1; i < fileCount; i++) { @@ -153,7 +153,7 @@ bool f_dir_exists(const TCHAR* path) return false; } -FRESULT f_remove_node( +static FRESULT f_remove_node( TCHAR* path, // Path name buffer with the sub-directory to delete UINT sz_buff, // Size of path name buffer (items) FILINFO* fno // Name read buffer diff --git a/TFT/src/User/Menu/Babystep.c b/TFT/src/User/Menu/Babystep.c index 383aba9a30..a752c36873 100644 --- a/TFT/src/User/Menu/Babystep.c +++ b/TFT/src/User/Menu/Babystep.c @@ -3,7 +3,7 @@ static uint8_t moveLenSteps_index = 0; -void babyReDraw(float babystep, float z_offset, bool force_z_offset, bool drawHeader) +static void babyReDraw(float babystep, float z_offset, bool force_z_offset, bool drawHeader) { if (drawHeader) { diff --git a/TFT/src/User/Menu/BedLeveling.c b/TFT/src/User/Menu/BedLeveling.c index 3f69099e07..45863a8e66 100644 --- a/TFT/src/User/Menu/BedLeveling.c +++ b/TFT/src/User/Menu/BedLeveling.c @@ -1,7 +1,7 @@ #include "BedLeveling.h" #include "includes.h" -void blUpdateState(MENUITEMS * menu, const uint8_t bedLevelState) +static void __attribute__ ((noinline)) blUpdateState(MENUITEMS * menu, const uint8_t bedLevelState) { if (bedLevelState == ENABLED) { diff --git a/TFT/src/User/Menu/CaseLight.c b/TFT/src/User/Menu/CaseLight.c index 93d9f3de82..3535fa3f7c 100644 --- a/TFT/src/User/Menu/CaseLight.c +++ b/TFT/src/User/Menu/CaseLight.c @@ -12,7 +12,7 @@ static void updateCaseLightIcon(MENUITEMS * curmenu, const bool state) curmenu->items[KEY_ICON_5].label.index = state ? LABEL_ON : LABEL_OFF; } -void caseLightPercentReDraw(void) +static void caseLightPercentReDraw(void) { char tempstr[20]; diff --git a/TFT/src/User/Menu/ConnectionSettings.c b/TFT/src/User/Menu/ConnectionSettings.c index 70e664be90..4c5a4f573d 100644 --- a/TFT/src/User/Menu/ConnectionSettings.c +++ b/TFT/src/User/Menu/ConnectionSettings.c @@ -3,7 +3,7 @@ SERIAL_PORT_INDEX portIndex = 0; // index on serialPort array -void updateListeningMode(MENUITEMS * menu) +static void updateListeningMode(MENUITEMS * menu) { if (GET_BIT(infoSettings.general_settings, INDEX_LISTENING_MODE) == 1) { diff --git a/TFT/src/User/Menu/FeatureSettings.c b/TFT/src/User/Menu/FeatureSettings.c index d5cf28bb68..99bf13b5db 100644 --- a/TFT/src/User/Menu/FeatureSettings.c +++ b/TFT/src/User/Menu/FeatureSettings.c @@ -59,7 +59,7 @@ void resetSettings(void) } // perform action on button press -void updateFeatureSettings(uint8_t item_index) +static void updateFeatureSettings(uint8_t item_index) { switch (item_index) { diff --git a/TFT/src/User/Menu/LEDColor.c b/TFT/src/User/Menu/LEDColor.c index 41399cd92a..447aef99d8 100644 --- a/TFT/src/User/Menu/LEDColor.c +++ b/TFT/src/User/Menu/LEDColor.c @@ -130,7 +130,7 @@ const char * const ledString[LED_COLOR_COMPONENT_COUNT] = {"R", "G", "B", "W", " uint8_t ledPage = 0; uint8_t ledIndex = 0; -uint8_t ledGetComponentIndex(uint8_t index) +static uint8_t ledGetComponentIndex(uint8_t index) { return ledPage * PAGE_ITEMS + index; } @@ -147,24 +147,24 @@ static inline uint8_t ledEditComponentValue(uint8_t index) return ledColor[realIndex] = editIntValue(LED_MIN_VALUE, LED_MAX_VALUE, ledColor[realIndex], ledColor[realIndex]); } -uint8_t ledUpdateComponentValue(uint8_t index, int8_t unit) +static uint8_t ledUpdateComponentValue(uint8_t index, int8_t unit) { uint8_t realIndex = ledGetComponentIndex(index); return ledColor[realIndex] = NOBEYOND(LED_MIN_VALUE, ledColor[realIndex] + unit, LED_MAX_VALUE); } -uint8_t ledGetControlIndex(uint8_t keyNum) +static uint8_t ledGetControlIndex(uint8_t keyNum) { return (keyNum - (LED_KEY_OK + 1)) / 4; } -uint8_t ledGetControlSubIndex(uint8_t keyNum) +static uint8_t ledGetControlSubIndex(uint8_t keyNum) { return (keyNum - (LED_KEY_OK + 1)) % 4; } -uint16_t ledGetComponentRGBColor(uint8_t component, uint8_t index) +static uint16_t ledGetComponentRGBColor(uint8_t component, uint8_t index) { LED_COLOR led = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // component RGB color in RGB 565 16 bit format @@ -182,7 +182,7 @@ static inline void ledDrawPageNumber(void) drawStandardValue(&ledPageRect, VALUE_STRING, &tempstr, FONT_SIZE_LARGE, LC_CTRL_FONT_COLOR, LC_CTRL_BG_COLOR, 1, true); } -void ledDrawControl(uint8_t index, bool isFocused, bool drawFocus, bool drawAll) +static void ledDrawControl(uint8_t index, bool isFocused, bool drawFocus, bool drawAll) { GUI_RECT rect, rect2; uint16_t bgColorFocus; @@ -248,7 +248,7 @@ void ledDrawButton(uint8_t index, uint8_t isPressed) } } -void ledDrawKeyboard(void) +static void ledDrawKeyboard(void) { // draw horizontal button borders GUI_SetColor(LC_KB_BORDER_COLOR); diff --git a/TFT/src/User/Menu/LevelCorner.c b/TFT/src/User/Menu/LevelCorner.c index 6a9188268a..24b9caecae 100644 --- a/TFT/src/User/Menu/LevelCorner.c +++ b/TFT/src/User/Menu/LevelCorner.c @@ -8,7 +8,7 @@ float levelCornerPosition[LEVELING_POINT_COUNT] = {0}; int16_t origLevelEdge = -1; -uint8_t getLevelEdgeMin(void) +static uint8_t getLevelEdgeMin(void) { // min edge limit for the probe with probe offset set in parseACK.c int16_t maxXedge = getParameter(P_PROBE_OFFSET, AXIS_INDEX_X) + getParameter(P_HOME_OFFSET, AXIS_INDEX_X); @@ -20,24 +20,24 @@ uint8_t getLevelEdgeMin(void) return MAX(maxXedge, maxYedge) + 1; } -uint8_t getLevelEdgeDefault(void) +static uint8_t getLevelEdgeDefault(void) { return MAX(origLevelEdge, getLevelEdgeMin()); } -void setLevelEdgeMin(void) +static void setLevelEdgeMin(void) { infoSettings.level_edge = getLevelEdgeMin(); } // draw values under icons -void refreshValue(MENUITEMS * levelItems, uint8_t index) +static void refreshValue(MENUITEMS * levelItems, uint8_t index) { sprintf((char *)levelItems->items[valIconIndex[index]].label.address, "%.4f", levelCornerPosition[index]); menuDrawIconText(&levelItems->items[valIconIndex[index]], valIconIndex[index]); } -void checkRefreshValue(MENUITEMS * levelItems) +static void checkRefreshValue(MENUITEMS * levelItems) { LEVELING_POINT levelingPoint = levelingGetProbedPoint(); @@ -51,7 +51,7 @@ void checkRefreshValue(MENUITEMS * levelItems) } // show M48 on icon -void drawProbeAccuracyIcon(MENUITEMS * levelItems) +static void drawProbeAccuracyIcon(MENUITEMS * levelItems) { uint8_t index = 4; GUI_POINT loc; diff --git a/TFT/src/User/Menu/MBL.c b/TFT/src/User/Menu/MBL.c index 51a1ebb5a5..cc4e6cf93d 100644 --- a/TFT/src/User/Menu/MBL.c +++ b/TFT/src/User/Menu/MBL.c @@ -81,7 +81,7 @@ void mblUpdateStatus(bool succeeded) } // Show an error notification -void mblNotifyError(bool isStarted) +static void mblNotifyError(bool isStarted) { LABELCHAR(tempMsg, LABEL_MBL); @@ -90,7 +90,7 @@ void mblNotifyError(bool isStarted) addToast(DIALOG_TYPE_ERROR, tempMsg); } -void mblDraw(COORDINATE *val) +static void mblDraw(COORDINATE *val) { char tempstr[24], tempstr2[24], tempstr3[24]; diff --git a/TFT/src/User/Menu/MPC.c b/TFT/src/User/Menu/MPC.c index 05a2711665..777d711450 100644 --- a/TFT/src/User/Menu/MPC.c +++ b/TFT/src/User/Menu/MPC.c @@ -41,7 +41,7 @@ const MENUITEMS mpcItems = { } }; -void mpcDisplayValues(void) +static void mpcDisplayValues(void) { char tmpStr[15]; MPC_Parameter * parameter = &mpcParameter[curTool_index]; diff --git a/TFT/src/User/Menu/MeshEditor.c b/TFT/src/User/Menu/MeshEditor.c index eb08da2320..033f360437 100644 --- a/TFT/src/User/Menu/MeshEditor.c +++ b/TFT/src/User/Menu/MeshEditor.c @@ -252,7 +252,7 @@ const char * meshErrorMsg[] = {"Invalid mesh"}; // list of possible error respo static MESH_DATA * meshData = NULL; -static inline void meshInitData(void) +static void meshInitData(void) { if (meshData == NULL) return; @@ -288,7 +288,7 @@ static inline void meshAllocData(void) } } -void meshDeallocData(void) +static void meshDeallocData(void) { if (meshData != NULL) { @@ -686,7 +686,7 @@ static inline void processGridData(void) memcpy(meshData->oriData, meshData->curData, sizeof(meshData->curData)); // copy the inversed rows data back to oriData } - else // copy oriData to curData + else // store grid data with the rows in normal order { memcpy(meshData->curData, meshData->oriData, sizeof(meshData->oriData)); } diff --git a/TFT/src/User/Menu/MeshTuner.c b/TFT/src/User/Menu/MeshTuner.c index 8b194e91ea..2c5e4ad287 100644 --- a/TFT/src/User/Menu/MeshTuner.c +++ b/TFT/src/User/Menu/MeshTuner.c @@ -26,7 +26,7 @@ static inline void meshResetPoint(void) // probeHeightDisable(); // restore original software endstops state and ABL state } -void meshDraw(uint16_t col, uint16_t row, COORDINATE *val) +static void meshDraw(uint16_t col, uint16_t row, COORDINATE *val) { char tempstr[24], tempstr2[24], tempstr3[24]; diff --git a/TFT/src/User/Menu/Move.c b/TFT/src/User/Menu/Move.c index ca23c3757e..c579c4077b 100644 --- a/TFT/src/User/Menu/Move.c +++ b/TFT/src/User/Menu/Move.c @@ -20,7 +20,7 @@ const char *const xyzMoveCmd[] = {X_MOVE_GCODE, Y_MOVE_GCODE, Z_MOVE_GCODE}; static uint8_t item_moveLen_index = 1; AXIS nowAxis = X_AXIS; -void storeMoveCmd(const AXIS xyz, const float amount) +static void storeMoveCmd(const AXIS xyz, const float amount) { // if invert is true, use 'amount' multiplied by -1 storeCmd(xyzMoveCmd[xyz], GET_BIT(infoSettings.inverted_axis, xyz) ? -amount : amount, @@ -29,7 +29,7 @@ void storeMoveCmd(const AXIS xyz, const float amount) nowAxis = xyz; // update now axis } -void drawXYZ(void) +static void drawXYZ(void) { char tempstr[30]; @@ -47,7 +47,7 @@ void drawXYZ(void) GUI_SetColor(infoSettings.font_color); } -void updateGantry(void) +static void updateGantry(void) { if (nextScreenUpdate(GANTRY_UPDATE_DELAY)) { diff --git a/TFT/src/User/Menu/PersistentInfo.c b/TFT/src/User/Menu/PersistentInfo.c index b3c1fd278d..a166c69a7e 100644 --- a/TFT/src/User/Menu/PersistentInfo.c +++ b/TFT/src/User/Menu/PersistentInfo.c @@ -7,7 +7,7 @@ #define GLOBALICON_INTERVAL 2 // check current menu to avoid display info -bool temperatureStatusValid(void) +static bool temperatureStatusValid(void) { if (infoSettings.persistent_info != 1) return false; if (infoHost.connected == false) return false; diff --git a/TFT/src/User/Menu/Pid.c b/TFT/src/User/Menu/Pid.c index 62c5399361..d0bc566c40 100644 --- a/TFT/src/User/Menu/Pid.c +++ b/TFT/src/User/Menu/Pid.c @@ -21,7 +21,7 @@ void pidUpdateStatus(PID_STATUS status) pidStatus = status; } -uint8_t checkFirstValidPID(void) +static uint8_t checkFirstValidPID(void) { uint8_t tool = 0; @@ -36,7 +36,7 @@ uint8_t checkFirstValidPID(void) return tool; } -void pidRun(void) +static void pidRun(void) { uint8_t tool = checkFirstValidPID(); @@ -57,7 +57,7 @@ static inline void pidStart(void) pidRun(); } -void pidResultAction(void) +static void pidResultAction(void) { if (pidStatus == PID_TIMEOUT) { diff --git a/TFT/src/User/Menu/Print.c b/TFT/src/User/Menu/Print.c index 6d6de7b5fd..b268b0ae82 100644 --- a/TFT/src/User/Menu/Print.c +++ b/TFT/src/User/Menu/Print.c @@ -56,7 +56,7 @@ const int16_t labelVolumeError[3] = {LABEL_TFT_SD_READ_ERROR, LABEL_TFT_USB_READ static bool list_mode = true; -void normalNameDisp(const GUI_RECT *rect, uint8_t *name) +static void normalNameDisp(const GUI_RECT *rect, uint8_t *name) { if (name == NULL) return; @@ -68,7 +68,7 @@ void normalNameDisp(const GUI_RECT *rect, uint8_t *name) } // update files menu in icon mode -void gocdeIconDraw(void) +static void gocdeIconDraw(void) { ITEM curItem = {ICON_NULL, LABEL_NULL}; uint8_t baseIndex = infoFile.curPage * NUM_PER_PAGE; @@ -131,7 +131,7 @@ void gocdeListDraw(LISTITEM * item, uint16_t index, uint8_t itemPos) } // open selected file/folder -bool printPageItemSelected(uint16_t index) +static bool printPageItemSelected(uint16_t index) { bool hasUpdate = true; diff --git a/TFT/src/User/Menu/RRFMacros.c b/TFT/src/User/Menu/RRFMacros.c index a6e925ab24..f255e45e77 100644 --- a/TFT/src/User/Menu/RRFMacros.c +++ b/TFT/src/User/Menu/RRFMacros.c @@ -6,7 +6,7 @@ static const char *running_macro_name; extern const GUI_RECT titleRect; // Scan files in RRF -void scanInfoFilesFs(void) +static void scanInfoFilesFs(void) { clearInfoFile(); request_M20_rrf(infoFile.path, false, parseMacroListResponse); @@ -21,7 +21,7 @@ void rrfShowRunningMacro(void) GUI_DispStringInRect(0, 0, LCD_WIDTH, LCD_HEIGHT, (uint8_t *)running_macro_name); } -void runMacro(const char *display_name) +static void runMacro(const char *display_name) { running_macro_name = display_name; rrfShowRunningMacro(); @@ -33,7 +33,7 @@ void runMacro(const char *display_name) // Draw Macro file list // update items in list mode -void macroListDraw(LISTITEM * item, uint16_t index, uint8_t itemPos) +static void macroListDraw(LISTITEM * item, uint16_t index, uint8_t itemPos) { if (index < infoFile.folderCount) { diff --git a/TFT/src/User/Menu/SelectMode.c b/TFT/src/User/Menu/SelectMode.c index a6fb610d6b..605ac07d69 100644 --- a/TFT/src/User/Menu/SelectMode.c +++ b/TFT/src/User/Menu/SelectMode.c @@ -19,7 +19,7 @@ const uint8_t icon_mode [MODE_COUNT] = { ICON_TOUCH_MODE, }; -void drawModeIcon(void) +static void drawModeIcon(void) { for (uint8_t i = 0; i < MODE_COUNT; i++) { diff --git a/TFT/src/User/Menu/StatusScreen.c b/TFT/src/User/Menu/StatusScreen.c index 8d703aceae..2adc623ae2 100644 --- a/TFT/src/User/Menu/StatusScreen.c +++ b/TFT/src/User/Menu/StatusScreen.c @@ -75,7 +75,7 @@ const GUI_POINT ss_val_point = {SS_ICON_WIDTH / 2, SS_ICON_VAL_Y0}; START_X + 4 * ICON_WIDTH + 3 * SPACE_X, ICON_HEIGHT + SPACE_Y + ICON_START_Y - STATUS_GANTRY_YOFFSET}; #endif -void drawStatus(void) +static void drawStatus(void) { // icons and their values are updated one by one to reduce flicker/clipping char tempstr[45]; @@ -219,7 +219,7 @@ void statusScreen_setReady(void) msgNeedRefresh = true; } -void drawStatusScreenMsg(void) +static void drawStatusScreenMsg(void) { GUI_SetTextMode(GUI_TEXTMODE_TRANS); diff --git a/TFT/src/User/Menu/StatusScreen.h b/TFT/src/User/Menu/StatusScreen.h index a4f00074a3..607b7f521c 100644 --- a/TFT/src/User/Menu/StatusScreen.h +++ b/TFT/src/User/Menu/StatusScreen.h @@ -15,7 +15,6 @@ void drawTemperature(void); void storegantry(int n, float val); void statusScreen_setMsg(const uint8_t *title,const uint8_t *msg); void statusScreen_setReady(void); -void drawStatusScreenMsg(void); float getAxisLocation(uint8_t n); void gantry_dec(int n, float val); void gantry_inc(int n, float val); diff --git a/TFT/src/User/Menu/TuneExtruder.c b/TFT/src/User/Menu/TuneExtruder.c index 8c309fcd11..a457825e92 100644 --- a/TFT/src/User/Menu/TuneExtruder.c +++ b/TFT/src/User/Menu/TuneExtruder.c @@ -11,7 +11,7 @@ static uint8_t degreeSteps_index = 1; static uint8_t extStep_index = 0; static bool loadRequested = false; -void showNewESteps(const float measured_length, const float old_esteps, float * new_esteps) +static void showNewESteps(const float measured_length, const float old_esteps, float * new_esteps) { char tempstr[20]; diff --git a/TFT/src/User/Menu/ZOffset.c b/TFT/src/User/Menu/ZOffset.c index 9af7dc88c4..882a4372b0 100644 --- a/TFT/src/User/Menu/ZOffset.c +++ b/TFT/src/User/Menu/ZOffset.c @@ -6,7 +6,7 @@ static uint8_t curUnit_index = 0; static uint8_t curSubmenu_index = 0; // Show an error notification -void zOffsetNotifyError(bool isStarted) +static void zOffsetNotifyError(bool isStarted) { LABELCHAR(tempMsg, LABEL_PROBE_OFFSET) @@ -21,7 +21,7 @@ void zOffsetNotifyError(bool isStarted) addToast(DIALOG_TYPE_ERROR, tempMsg); } -void zOffsetDraw(bool status, float val) +static void zOffsetDraw(bool status, float val) { char tempstr[20], tempstr2[20], tempstr3[30];