From 9c95f8c015ba479308cab9cc361f05a527947d2f Mon Sep 17 00:00:00 2001 From: NotaRobotexe Date: Fri, 19 Jul 2019 18:34:46 +0200 Subject: [PATCH 1/5] sheet menu --- Firmware/menu.cpp | 37 ++++++++++++++++++ Firmware/menu.h | 2 + Firmware/ultralcd.cpp | 87 +++++++++++++++++++++++++++++++++++++++---- 3 files changed, 119 insertions(+), 7 deletions(-) diff --git a/Firmware/menu.cpp b/Firmware/menu.cpp index 096838cb..9b9d01db 100755 --- a/Firmware/menu.cpp +++ b/Firmware/menu.cpp @@ -196,6 +196,28 @@ void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer) buffer.c[index + 7] = '\0'; } +//! @brief Format sheet name in select menu +//! +//! @param[in] sheet_E Sheet in EEPROM +//! @param[out] buffer for formatted output +void menu_format_sheet_select_E(const Sheet &sheet_E, SheetFormatBuffer &buffer) +{ + uint_least8_t index = sprintf_P(buffer.c, PSTR("%.10S ["), _T(MSG_SHEET)); + eeprom_read_block(&(buffer.c[index]), sheet_E.name, 7); + buffer.c[index + 7] = ']'; + //index += 7; + buffer.c[index + 8] = '\0'; +} + +static void menu_draw_item_select_sheet_E(char type_char, const Sheet &sheet) +{ + lcd_set_cursor(0, menu_row); + SheetFormatBuffer buffer; + menu_format_sheet_select_E(sheet, buffer); + lcd_printf_P(PSTR("%c%-18.18s%c"), menu_selection_mark(), buffer.c, type_char); +} + + static void menu_draw_item_puts_E(char type_char, const Sheet &sheet) { lcd_set_cursor(0, menu_row); @@ -269,6 +291,21 @@ uint8_t menu_item_submenu_E(const Sheet &sheet, menu_func_t submenu) return 0; } +uint8_t menu_item_submenu_select_sheet_E(const Sheet &sheet, menu_func_t submenu) +{ + if (menu_item == menu_line) + { + if (lcd_draw_update) menu_draw_item_select_sheet_E(LCD_STR_ARROW_RIGHT[0], sheet); + if (menu_clicked && (lcd_encoder == menu_item)) + { + menu_submenu(submenu); + return menu_item_ret(); + } + } + menu_item++; + return 0; +} + uint8_t menu_item_back_P(const char* str) { if (menu_item == menu_line) diff --git a/Firmware/menu.h b/Firmware/menu.h index a4cb3010..d9bbf876 100755 --- a/Firmware/menu.h +++ b/Firmware/menu.h @@ -103,6 +103,8 @@ extern uint8_t menu_item_submenu_P(const char* str, menu_func_t submenu); #define MENU_ITEM_SUBMENU_E(sheet, submenu) do { if (menu_item_submenu_E(sheet, submenu)) return; } while (0) extern uint8_t menu_item_submenu_E(const Sheet &sheet, menu_func_t submenu); +#define MENU_ITEM_SUBMENU_SELECT_SHEET_E(sheet, submenu) do { if (menu_item_submenu_select_sheet_E(sheet, submenu)) return; } while (0) +extern uint8_t menu_item_submenu_select_sheet_E(const Sheet &sheet, menu_func_t submenu); #define MENU_ITEM_BACK_P(str) do { if (menu_item_back_P(str)) return; } while (0) extern uint8_t menu_item_back_P(const char* str); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index ee9c6c2b..5ab59e96 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -257,6 +257,7 @@ static void lcd_connect_printer(); void lcd_finishstatus(); static void lcd_sdcard_menu(); +static void lcd_sheet_menu(); #ifdef DELTA_CALIBRATION_MENU static void lcd_delta_calibrate_menu(); @@ -5517,15 +5518,41 @@ SETTINGS_VERSION; MENU_END(); } +//TODO: ---------- HW menu void lcd_hw_setup_menu(void) // can not be "static" { MENU_BEGIN(); MENU_ITEM_BACK_P(_T(bSettings?MSG_SETTINGS:MSG_BACK)); // i.e. default menu-item / menu-item after checking mismatch -if(!farm_mode) + +MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[0], lcd_sheet_menu); +MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[1], lcd_sheet_menu); +MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[2], lcd_sheet_menu); + +char buffer[] = "work cunt"; +//strncpy(buffer,_i("Sheet"),sizeof(buffer)); +//strncpy(buffer,_i(" "),sizeof(buffer)); +//strncpy(buffer,EEPROM_Sheets_base->s[0].name,sizeof(buffer)); + +//const char* menu = EEPROM_Sheets_base->s[0].name.c_str(); + +//const char *b = new char(buffer); +//const char *b = const char *b = new char(buffer);(buffer); +//printf_P(_N("UVLO - end %d\n"), _millis() - time_start); +//SERIAL_ECHOPGM(buffer); +//SERIAL_ECHOPGM(reinterpret_cast(buffer)); +//SERIAL_ECHOPGM("lakdjushasdjaljsdakjsdn"); +//char* p = &buffer[0]; + +//MENU_ITEM_SUBMENU_P(reinterpret_cast(p),lcd_sheet_menu); + +//delete(b); + +if(!farm_mode){ SETTINGS_NOZZLE; // ... a sem prijdou 'plechy' if(!farm_mode) MENU_ITEM_SUBMENU_P(_i("Checks"), lcd_checking_menu); +} MENU_END(); } @@ -6500,14 +6527,14 @@ static void lcd_select_sheet_2_menu() change_sheet(2); } -static void lcd_select_sheet_menu() +static void lcd_select_sheet_menu() //TODO: -----------------sheet menu { - MENU_BEGIN(); + /*MENU_BEGIN(); MENU_ITEM_BACK_P(_T(MSG_BACK)); MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[0], lcd_select_sheet_0_menu); MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[1], lcd_select_sheet_1_menu); MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[2], lcd_select_sheet_2_menu); - MENU_END(); + MENU_END();*/ } static void lcd_rename_sheet_menu() @@ -6554,13 +6581,59 @@ static void lcd_rename_sheet_menu() } } +static void lcd_reset_sheet() +{ + struct MenuData + { + bool initialized; + uint8_t selected; + char name[sizeof(Sheet::name)]; + }; + static_assert(sizeof(menu_data)>= sizeof(MenuData),"MenuData doesn't fit into menu_data"); + MenuData* menuData = (MenuData*)&(menu_data[0]); + + if (!menuData->initialized) + { + eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, sizeof(Sheet::name)); + lcd_encoder = menuData->name[0]; + menuData->initialized = true; + } + if (lcd_encoder < '\x20') lcd_encoder = '\x20'; + if (lcd_encoder > '\x7F') lcd_encoder = '\x7F'; + + menuData->name[menuData->selected] = lcd_encoder; + lcd_set_cursor(0,0); + for (uint_least8_t i = 0; i < sizeof(Sheet::name); ++i) + { + lcd_putc(menuData->name[i]); + } + lcd_set_cursor(menuData->selected, 1); + lcd_putc('^'); + if (lcd_clicked()) + { + if ((menuData->selected + 1u) < sizeof(Sheet::name)) + { + lcd_encoder = menuData->name[++(menuData->selected)]; + } + else + { + eeprom_update_block(menuData->name, + EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, + sizeof(Sheet::name)); + menu_back(); + } + } +} + static void lcd_sheet_menu() { MENU_BEGIN(); - MENU_ITEM_BACK_P(_T(MSG_MAIN)); + MENU_ITEM_BACK_P(_T(MSG_HW_SETUP)); + //if() MENU_ITEM_SUBMENU_P(_i("Select"), lcd_select_sheet_menu); //// c=18 - MENU_ITEM_SUBMENU_P(_i("Rename"), lcd_rename_sheet_menu); //// c=18 MENU_ITEM_SUBMENU_P(_T(MSG_V2_CALIBRATION), lcd_v2_calibration); + MENU_ITEM_SUBMENU_P(_i("Rename"), lcd_rename_sheet_menu); //// c=18 + MENU_ITEM_SUBMENU_P(_i("Reset"), lcd_reset_sheet); //// c=18 MENU_END(); } @@ -6700,7 +6773,7 @@ static void lcd_main_menu() } - if(!isPrintPaused)MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], lcd_sheet_menu); + if(!isPrintPaused)MENU_ITEM_SUBMENU_SELECT_SHEET_E(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], lcd_sheet_menu); if (!is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal)) { From ab2eafe1752e373bc65fbb34b1d100c480e3a88d Mon Sep 17 00:00:00 2001 From: NotaRobotexe Date: Mon, 22 Jul 2019 18:43:43 +0200 Subject: [PATCH 2/5] sheet menu, add hw setting, sheet change in menu, sheet name initialization in eeprom --- Firmware/eeprom.cpp | 11 ++-- Firmware/eeprom.h | 2 +- Firmware/menu.cpp | 3 +- Firmware/ultralcd.cpp | 114 ++++++++++++++++++------------------------ 4 files changed, 59 insertions(+), 71 deletions(-) diff --git a/Firmware/eeprom.cpp b/Firmware/eeprom.cpp index 1be708d0..5861109d 100644 --- a/Firmware/eeprom.cpp +++ b/Firmware/eeprom.cpp @@ -41,9 +41,9 @@ bool eeprom_is_uninitialized(char *address) return (0xff == eeprom_read_byte(reinterpret_cast(address))); } -bool is_sheet_initialized(){ +bool is_sheet_initialized(uint8_t sheet_num){ return (0xffff != eeprom_read_word(reinterpret_cast(&(EEPROM_Sheets_base-> - s[eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))].z_offset)))); + s[sheet_num].z_offset)))); } void eeprom_init() @@ -62,6 +62,8 @@ void eeprom_init() if (eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); if (eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); if (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == 0xff) eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 0); + + char defaultSheetNames[3][8] = {"Smooth1","Smooth2","Textur1"}; for (uint_least8_t i = 0; i < (sizeof(Sheets::s)/sizeof(Sheets::s[0])); ++i) { bool is_uninitialized = true; @@ -71,8 +73,9 @@ void eeprom_init() } if(is_uninitialized) { - eeprom_write(&(EEPROM_Sheets_base->s[i].name[0]), static_cast(i + '1')); - eeprom_write(&(EEPROM_Sheets_base->s[i].name[1]), '\0'); + for (uint_least8_t a = 0; a < sizeof(Sheet::name); ++a){ + eeprom_write(&(EEPROM_Sheets_base->s[i].name[a]), defaultSheetNames[i][a]); + } } } check_babystep(); diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 54f30ccd..c41fb9ff 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -5,7 +5,7 @@ #ifdef __cplusplus void eeprom_init(); -extern bool is_sheet_initialized(); +extern bool is_sheet_initialized(uint8_t sheet_num); #endif diff --git a/Firmware/menu.cpp b/Firmware/menu.cpp index 9b9d01db..e08b5710 100755 --- a/Firmware/menu.cpp +++ b/Firmware/menu.cpp @@ -202,10 +202,9 @@ void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer) //! @param[out] buffer for formatted output void menu_format_sheet_select_E(const Sheet &sheet_E, SheetFormatBuffer &buffer) { - uint_least8_t index = sprintf_P(buffer.c, PSTR("%.10S ["), _T(MSG_SHEET)); + uint_least8_t index = sprintf_P(buffer.c,PSTR("%.10S ["), _T(MSG_SHEET)); eeprom_read_block(&(buffer.c[index]), sheet_E.name, 7); buffer.c[index + 7] = ']'; - //index += 7; buffer.c[index + 8] = '\0'; } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5ab59e96..d94d29be 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -259,6 +259,10 @@ void lcd_finishstatus(); static void lcd_sdcard_menu(); static void lcd_sheet_menu(); +static void lcd_select_sheet_0_menu(); +static void lcd_select_sheet_1_menu(); +static void lcd_select_sheet_2_menu(); + #ifdef DELTA_CALIBRATION_MENU static void lcd_delta_calibrate_menu(); #endif // DELTA_CALIBRATION_MENU @@ -299,6 +303,9 @@ static void menu_action_sddirectory(const char* filename); bool lcd_oldcardstatus; #endif +uint8_t selected_sheet = 0; +char defaultSheetNames[3][8] = {"Smooth1","Smooth2","Textur1"}; + bool ignore_click = false; bool wait_for_unclick; @@ -3091,7 +3098,7 @@ static void lcd_babystep_z() _md->status = 1; check_babystep(); - if(!is_sheet_initialized()){ + if(!is_sheet_initialized(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))){ _md->babystepMemZ = 0; } else{ @@ -4700,6 +4707,7 @@ void lcd_toshiba_flash_air_compatibility_toggle() void lcd_v2_calibration() { + eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), selected_sheet); if (mmu_enabled) { const uint8_t filament = choose_menu_P(_i("Select PLA filament:"),_T(MSG_FILAMENT),_i("Cancel")); ////c=20 r=1 ////c=19 r=1 @@ -5518,17 +5526,15 @@ SETTINGS_VERSION; MENU_END(); } -//TODO: ---------- HW menu void lcd_hw_setup_menu(void) // can not be "static" { MENU_BEGIN(); MENU_ITEM_BACK_P(_T(bSettings?MSG_SETTINGS:MSG_BACK)); // i.e. default menu-item / menu-item after checking mismatch -MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[0], lcd_sheet_menu); -MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[1], lcd_sheet_menu); -MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[2], lcd_sheet_menu); +MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[0], lcd_select_sheet_0_menu); +MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[1], lcd_select_sheet_1_menu); +MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[2], lcd_select_sheet_2_menu); -char buffer[] = "work cunt"; //strncpy(buffer,_i("Sheet"),sizeof(buffer)); //strncpy(buffer,_i(" "),sizeof(buffer)); //strncpy(buffer,EEPROM_Sheets_base->s[0].name,sizeof(buffer)); @@ -5549,8 +5555,6 @@ char buffer[] = "work cunt"; if(!farm_mode){ SETTINGS_NOZZLE; -// ... a sem prijdou 'plechy' -if(!farm_mode) MENU_ITEM_SUBMENU_P(_i("Checks"), lcd_checking_menu); } MENU_END(); @@ -6503,38 +6507,36 @@ void lcd_resume_print() isPrintPaused = false; } -static void change_sheet(uint8_t sheet_num) +static void change_sheet() { - eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), sheet_num); - if(is_sheet_initialized()) - calibration_status_store(CALIBRATION_STATUS_CALIBRATED); - else - calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST); - + eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), selected_sheet); menu_back(3); } +static void change_sheet_from_menu(){ + uint8_t next_sheet = selected_sheet+1; + if(next_sheet > 2) next_sheet = 0; + if(is_sheet_initialized(next_sheet)){ + eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), next_sheet); + selected_sheet = next_sheet; + } + menu_back(); +} + static void lcd_select_sheet_0_menu() { - change_sheet(0); + selected_sheet = 0; + lcd_sheet_menu(); } static void lcd_select_sheet_1_menu() { - change_sheet(1); + selected_sheet = 1; + lcd_sheet_menu(); } static void lcd_select_sheet_2_menu() { - change_sheet(2); -} - -static void lcd_select_sheet_menu() //TODO: -----------------sheet menu -{ - /*MENU_BEGIN(); - MENU_ITEM_BACK_P(_T(MSG_BACK)); - MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[0], lcd_select_sheet_0_menu); - MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[1], lcd_select_sheet_1_menu); - MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[2], lcd_select_sheet_2_menu); - MENU_END();*/ + selected_sheet = 2; + lcd_sheet_menu(); } static void lcd_rename_sheet_menu() @@ -6550,7 +6552,7 @@ static void lcd_rename_sheet_menu() if (!menuData->initialized) { - eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, sizeof(Sheet::name)); + eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[selected_sheet].name, sizeof(Sheet::name)); lcd_encoder = menuData->name[0]; menuData->initialized = true; } @@ -6574,7 +6576,7 @@ static void lcd_rename_sheet_menu() else { eeprom_update_block(menuData->name, - EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, + EEPROM_Sheets_base->s[selected_sheet].name, sizeof(Sheet::name)); menu_back(); } @@ -6591,46 +6593,27 @@ static void lcd_reset_sheet() }; static_assert(sizeof(menu_data)>= sizeof(MenuData),"MenuData doesn't fit into menu_data"); MenuData* menuData = (MenuData*)&(menu_data[0]); + eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[selected_sheet].name, sizeof(Sheet::name)); + + menuData->initialized = false; + for (uint_least8_t i = 0; i < sizeof(Sheet::name); ++i){ + menuData->name[i] = defaultSheetNames[selected_sheet][i]; + } - if (!menuData->initialized) - { - eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, sizeof(Sheet::name)); - lcd_encoder = menuData->name[0]; - menuData->initialized = true; - } - if (lcd_encoder < '\x20') lcd_encoder = '\x20'; - if (lcd_encoder > '\x7F') lcd_encoder = '\x7F'; - - menuData->name[menuData->selected] = lcd_encoder; - lcd_set_cursor(0,0); - for (uint_least8_t i = 0; i < sizeof(Sheet::name); ++i) - { - lcd_putc(menuData->name[i]); - } - lcd_set_cursor(menuData->selected, 1); - lcd_putc('^'); - if (lcd_clicked()) - { - if ((menuData->selected + 1u) < sizeof(Sheet::name)) - { - lcd_encoder = menuData->name[++(menuData->selected)]; - } - else - { - eeprom_update_block(menuData->name, - EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, - sizeof(Sheet::name)); - menu_back(); - } - } + eeprom_update_word(reinterpret_cast(&(EEPROM_Sheets_base->s[selected_sheet].z_offset)),0xffff); + eeprom_update_block(menuData->name,EEPROM_Sheets_base->s[selected_sheet].name,sizeof(Sheet::name)); + menu_back(2); } static void lcd_sheet_menu() { MENU_BEGIN(); MENU_ITEM_BACK_P(_T(MSG_HW_SETUP)); - //if() - MENU_ITEM_SUBMENU_P(_i("Select"), lcd_select_sheet_menu); //// c=18 + + if(is_sheet_initialized(selected_sheet)){ + MENU_ITEM_SUBMENU_P(_i("Select"), change_sheet); //// c=18 + } + MENU_ITEM_SUBMENU_P(_T(MSG_V2_CALIBRATION), lcd_v2_calibration); MENU_ITEM_SUBMENU_P(_i("Rename"), lcd_rename_sheet_menu); //// c=18 MENU_ITEM_SUBMENU_P(_i("Reset"), lcd_reset_sheet); //// c=18 @@ -6773,7 +6756,10 @@ static void lcd_main_menu() } - if(!isPrintPaused)MENU_ITEM_SUBMENU_SELECT_SHEET_E(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], lcd_sheet_menu); + if(!isPrintPaused && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal)) + { + MENU_ITEM_SUBMENU_SELECT_SHEET_E(EEPROM_Sheets_base->s[selected_sheet], change_sheet_from_menu); + } if (!is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal)) { From 19e7838c20e499a093356ec34c2de0a81787856b Mon Sep 17 00:00:00 2001 From: NotaRobotexe Date: Mon, 22 Jul 2019 20:35:10 +0200 Subject: [PATCH 3/5] add default names to PROGMEM, text formating edit --- Firmware/Marlin.h | 4 ++++ Firmware/eeprom.cpp | 6 +++--- Firmware/menu.cpp | 2 +- Firmware/ultralcd.cpp | 5 +---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index a4434661..6b2261c3 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -331,6 +331,10 @@ extern float retract_length_swap; extern float retract_recover_length_swap; #endif +const char smooth1[] PROGMEM = "Smooth1"; +const char smooth2[] PROGMEM = "Smooth2"; +const char textured[] PROGMEM = "Textur1"; +const char *const defaultSheetNames[] PROGMEM = {smooth1,smooth2,textured}; extern uint8_t host_keepalive_interval; diff --git a/Firmware/eeprom.cpp b/Firmware/eeprom.cpp index 5861109d..726288b5 100644 --- a/Firmware/eeprom.cpp +++ b/Firmware/eeprom.cpp @@ -8,7 +8,6 @@ #include #include - #include "language.h" #if 0 @@ -63,7 +62,6 @@ void eeprom_init() if (eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); if (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == 0xff) eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 0); - char defaultSheetNames[3][8] = {"Smooth1","Smooth2","Textur1"}; for (uint_least8_t i = 0; i < (sizeof(Sheets::s)/sizeof(Sheets::s[0])); ++i) { bool is_uninitialized = true; @@ -73,8 +71,10 @@ void eeprom_init() } if(is_uninitialized) { + char sheet_PROGMEM_buffer[8]; + strcpy_P(sheet_PROGMEM_buffer, (char *)pgm_read_word(&(defaultSheetNames[i]))); for (uint_least8_t a = 0; a < sizeof(Sheet::name); ++a){ - eeprom_write(&(EEPROM_Sheets_base->s[i].name[a]), defaultSheetNames[i][a]); + eeprom_write(&(EEPROM_Sheets_base->s[i].name[a]), sheet_PROGMEM_buffer[a]); } } } diff --git a/Firmware/menu.cpp b/Firmware/menu.cpp index e08b5710..7f1ab12f 100755 --- a/Firmware/menu.cpp +++ b/Firmware/menu.cpp @@ -202,7 +202,7 @@ void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer) //! @param[out] buffer for formatted output void menu_format_sheet_select_E(const Sheet &sheet_E, SheetFormatBuffer &buffer) { - uint_least8_t index = sprintf_P(buffer.c,PSTR("%.10S ["), _T(MSG_SHEET)); + uint_least8_t index = sprintf_P(buffer.c,PSTR("%-9.10S["), _T(MSG_SHEET)); eeprom_read_block(&(buffer.c[index]), sheet_E.name, 7); buffer.c[index + 7] = ']'; buffer.c[index + 8] = '\0'; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d94d29be..ee5d06ac 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -304,7 +304,6 @@ bool lcd_oldcardstatus; #endif uint8_t selected_sheet = 0; -char defaultSheetNames[3][8] = {"Smooth1","Smooth2","Textur1"}; bool ignore_click = false; bool wait_for_unclick; @@ -6596,9 +6595,7 @@ static void lcd_reset_sheet() eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[selected_sheet].name, sizeof(Sheet::name)); menuData->initialized = false; - for (uint_least8_t i = 0; i < sizeof(Sheet::name); ++i){ - menuData->name[i] = defaultSheetNames[selected_sheet][i]; - } + strcpy_P(menuData->name, (char *)pgm_read_word(&(defaultSheetNames[selected_sheet]))); eeprom_update_word(reinterpret_cast(&(EEPROM_Sheets_base->s[selected_sheet].z_offset)),0xffff); eeprom_update_block(menuData->name,EEPROM_Sheets_base->s[selected_sheet].name,sizeof(Sheet::name)); From b5129ff2ecf3a2dce3cb7a0ac0867973b1fc49dd Mon Sep 17 00:00:00 2001 From: NotaRobotexe Date: Tue, 23 Jul 2019 11:12:53 +0200 Subject: [PATCH 4/5] Revert "force push" This reverts commit 19e7838c20e499a093356ec34c2de0a81787856b. --- Firmware/Marlin.h | 4 ---- Firmware/eeprom.cpp | 6 +++--- Firmware/menu.cpp | 2 +- Firmware/ultralcd.cpp | 5 ++++- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 6b2261c3..a4434661 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -331,10 +331,6 @@ extern float retract_length_swap; extern float retract_recover_length_swap; #endif -const char smooth1[] PROGMEM = "Smooth1"; -const char smooth2[] PROGMEM = "Smooth2"; -const char textured[] PROGMEM = "Textur1"; -const char *const defaultSheetNames[] PROGMEM = {smooth1,smooth2,textured}; extern uint8_t host_keepalive_interval; diff --git a/Firmware/eeprom.cpp b/Firmware/eeprom.cpp index 726288b5..5861109d 100644 --- a/Firmware/eeprom.cpp +++ b/Firmware/eeprom.cpp @@ -8,6 +8,7 @@ #include #include + #include "language.h" #if 0 @@ -62,6 +63,7 @@ void eeprom_init() if (eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); if (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == 0xff) eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 0); + char defaultSheetNames[3][8] = {"Smooth1","Smooth2","Textur1"}; for (uint_least8_t i = 0; i < (sizeof(Sheets::s)/sizeof(Sheets::s[0])); ++i) { bool is_uninitialized = true; @@ -71,10 +73,8 @@ void eeprom_init() } if(is_uninitialized) { - char sheet_PROGMEM_buffer[8]; - strcpy_P(sheet_PROGMEM_buffer, (char *)pgm_read_word(&(defaultSheetNames[i]))); for (uint_least8_t a = 0; a < sizeof(Sheet::name); ++a){ - eeprom_write(&(EEPROM_Sheets_base->s[i].name[a]), sheet_PROGMEM_buffer[a]); + eeprom_write(&(EEPROM_Sheets_base->s[i].name[a]), defaultSheetNames[i][a]); } } } diff --git a/Firmware/menu.cpp b/Firmware/menu.cpp index 7f1ab12f..e08b5710 100755 --- a/Firmware/menu.cpp +++ b/Firmware/menu.cpp @@ -202,7 +202,7 @@ void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer) //! @param[out] buffer for formatted output void menu_format_sheet_select_E(const Sheet &sheet_E, SheetFormatBuffer &buffer) { - uint_least8_t index = sprintf_P(buffer.c,PSTR("%-9.10S["), _T(MSG_SHEET)); + uint_least8_t index = sprintf_P(buffer.c,PSTR("%.10S ["), _T(MSG_SHEET)); eeprom_read_block(&(buffer.c[index]), sheet_E.name, 7); buffer.c[index + 7] = ']'; buffer.c[index + 8] = '\0'; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index ee5d06ac..d94d29be 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -304,6 +304,7 @@ bool lcd_oldcardstatus; #endif uint8_t selected_sheet = 0; +char defaultSheetNames[3][8] = {"Smooth1","Smooth2","Textur1"}; bool ignore_click = false; bool wait_for_unclick; @@ -6595,7 +6596,9 @@ static void lcd_reset_sheet() eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[selected_sheet].name, sizeof(Sheet::name)); menuData->initialized = false; - strcpy_P(menuData->name, (char *)pgm_read_word(&(defaultSheetNames[selected_sheet]))); + for (uint_least8_t i = 0; i < sizeof(Sheet::name); ++i){ + menuData->name[i] = defaultSheetNames[selected_sheet][i]; + } eeprom_update_word(reinterpret_cast(&(EEPROM_Sheets_base->s[selected_sheet].z_offset)),0xffff); eeprom_update_block(menuData->name,EEPROM_Sheets_base->s[selected_sheet].name,sizeof(Sheet::name)); From b9f622f8a6ad503b7840d12ec4e924171b99494d Mon Sep 17 00:00:00 2001 From: NotaRobotexe Date: Tue, 23 Jul 2019 11:31:20 +0200 Subject: [PATCH 5/5] variables to PROGMEM, text formating --- Firmware/Marlin.h | 5 +++++ Firmware/eeprom.cpp | 5 +++-- Firmware/menu.cpp | 2 +- Firmware/ultralcd.cpp | 6 ++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index a4434661..c42bfca0 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -314,6 +314,11 @@ extern bool axis_known_position[3]; extern int fanSpeed; extern int8_t lcd_change_fil_state; +const char smooth1[] PROGMEM = "Smooth1"; +const char smooth2[] PROGMEM = "Smooth2"; +const char textured[] PROGMEM = "Textur1"; +const char *const defaultSheetNames[] PROGMEM = {smooth1,smooth2,textured}; + #ifdef TMC2130 void homeaxis(int axis, uint8_t cnt = 1, uint8_t* pstep = 0); #else diff --git a/Firmware/eeprom.cpp b/Firmware/eeprom.cpp index 5861109d..c5faec41 100644 --- a/Firmware/eeprom.cpp +++ b/Firmware/eeprom.cpp @@ -63,7 +63,6 @@ void eeprom_init() if (eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); if (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == 0xff) eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 0); - char defaultSheetNames[3][8] = {"Smooth1","Smooth2","Textur1"}; for (uint_least8_t i = 0; i < (sizeof(Sheets::s)/sizeof(Sheets::s[0])); ++i) { bool is_uninitialized = true; @@ -73,8 +72,10 @@ void eeprom_init() } if(is_uninitialized) { + char sheet_PROGMEM_buffer[8]; + strcpy_P(sheet_PROGMEM_buffer, (char *)pgm_read_word(&(defaultSheetNames[i]))); for (uint_least8_t a = 0; a < sizeof(Sheet::name); ++a){ - eeprom_write(&(EEPROM_Sheets_base->s[i].name[a]), defaultSheetNames[i][a]); + eeprom_write(&(EEPROM_Sheets_base->s[i].name[a]), sheet_PROGMEM_buffer[a]); } } } diff --git a/Firmware/menu.cpp b/Firmware/menu.cpp index e08b5710..7839bbdc 100755 --- a/Firmware/menu.cpp +++ b/Firmware/menu.cpp @@ -202,7 +202,7 @@ void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer) //! @param[out] buffer for formatted output void menu_format_sheet_select_E(const Sheet &sheet_E, SheetFormatBuffer &buffer) { - uint_least8_t index = sprintf_P(buffer.c,PSTR("%.10S ["), _T(MSG_SHEET)); + uint_least8_t index = sprintf_P(buffer.c,PSTR("%-9.9S["), _T(MSG_SHEET)); eeprom_read_block(&(buffer.c[index]), sheet_E.name, 7); buffer.c[index + 7] = ']'; buffer.c[index + 8] = '\0'; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d94d29be..4e36c3f7 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -304,7 +304,6 @@ bool lcd_oldcardstatus; #endif uint8_t selected_sheet = 0; -char defaultSheetNames[3][8] = {"Smooth1","Smooth2","Textur1"}; bool ignore_click = false; bool wait_for_unclick; @@ -6596,9 +6595,8 @@ static void lcd_reset_sheet() eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[selected_sheet].name, sizeof(Sheet::name)); menuData->initialized = false; - for (uint_least8_t i = 0; i < sizeof(Sheet::name); ++i){ - menuData->name[i] = defaultSheetNames[selected_sheet][i]; - } + strcpy_P(menuData->name, (char *)pgm_read_word(&(defaultSheetNames[selected_sheet]))); + eeprom_update_word(reinterpret_cast(&(EEPROM_Sheets_base->s[selected_sheet].z_offset)),0xffff); eeprom_update_block(menuData->name,EEPROM_Sheets_base->s[selected_sheet].name,sizeof(Sheet::name));