diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 50988092..90d83868 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -323,6 +323,7 @@ extern float retract_recover_length_swap; extern uint8_t host_keepalive_interval; +extern bool is_sheet_inicialized(); extern unsigned long starttime; extern unsigned long stoptime; diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index d9e210b6..9dcb4f47 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8143,6 +8143,11 @@ static void wait_for_heater(long codenum, uint8_t extruder) { } } +bool is_sheet_inicialized(){ + return (0xffff != eeprom_read_word(reinterpret_cast(&(EEPROM_Sheets_base-> + s[eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))].z_offset)))); +} + void check_babystep() { int babystep_z = eeprom_read_word(reinterpret_cast(&(EEPROM_Sheets_base-> diff --git a/Firmware/eeprom.cpp b/Firmware/eeprom.cpp index a677241c..03dee689 100644 --- a/Firmware/eeprom.cpp +++ b/Firmware/eeprom.cpp @@ -8,6 +8,9 @@ #include #include + +#include "language.h" + #if 0 template static T eeprom_read(T *address); @@ -65,6 +68,7 @@ void eeprom_init() { eeprom_write(&(EEPROM_Sheets_base->s[i].name[0]), static_cast(i + '1')); eeprom_write(&(EEPROM_Sheets_base->s[i].name[1]), '\0'); + //eeprom_write_word(reinterpret_cast(&(EEPROM_Sheets_base->s[i].z_offset)),0); //TODO: nedavat dalsi } } check_babystep(); diff --git a/Firmware/messages.c b/Firmware/messages.c index 5f30a54a..57d2aba9 100644 --- a/Firmware/messages.c +++ b/Firmware/messages.c @@ -127,3 +127,4 @@ const char MSG_ENDSTOP_OPEN[] PROGMEM_N1 = "open"; //// const char MSG_POWERUP[] PROGMEM_N1 = "PowerUp"; //// const char MSG_ERR_STOPPED[] PROGMEM_N1 = "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"; //// const char MSG_ENDSTOP_HIT[] PROGMEM_N1 = "TRIGGERED"; //// +const char MSG_V2_CALIBRATION[] PROGMEM_N1 = "First layer cal."; ////c=17 r=1 diff --git a/Firmware/messages.h b/Firmware/messages.h index bbfc1065..e4c4187c 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -128,6 +128,7 @@ extern const char MSG_ERR_STOPPED[]; extern const char MSG_ENDSTOP_HIT[]; extern const char MSG_EJECT_FILAMENT[]; extern const char MSG_CUT_FILAMENT[]; +extern const char MSG_V2_CALIBRATION[]; #if defined(__cplusplus) } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5f7328be..40a49025 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3084,9 +3084,14 @@ static void lcd_babystep_z() // Initialize its status. _md->status = 1; check_babystep(); - - _md->babystepMemZ = eeprom_read_word(reinterpret_cast(&(EEPROM_Sheets_base-> - s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset))); + + if(!is_sheet_inicialized()){ + _md->babystepMemZ = 0; + } + else{ + _md->babystepMemZ = eeprom_read_word(reinterpret_cast(&(EEPROM_Sheets_base-> + s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset))); + } // same logic as in babystep_load if (calibration_status() >= CALIBRATION_STATUS_LIVE_ADJUST) @@ -6300,26 +6305,34 @@ void lcd_resume_print() isPrintPaused = false; } +static void sheet_check(uint8_t sheet_num) +{ + eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), sheet_num); + if(is_sheet_inicialized()) + calibration_status_store(CALIBRATION_STATUS_CALIBRATED); + else + calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST); + + menu_back(3); +} + static void lcd_select_sheet_0_menu() { - eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 0); - menu_back(3); + sheet_check(0); } static void lcd_select_sheet_1_menu() { - eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 1); - menu_back(3); + sheet_check(1); } static void lcd_select_sheet_2_menu() { - eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 2); - menu_back(3); + sheet_check(2); } static void lcd_select_sheet_menu() { MENU_BEGIN(); - MENU_ITEM_BACK_P(_T(MSG_SHEET)); + 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); @@ -6376,7 +6389,7 @@ static void lcd_sheet_menu() MENU_ITEM_BACK_P(_T(MSG_MAIN)); 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_BABYSTEP_Z), lcd_babystep_z); + MENU_ITEM_SUBMENU_P(_T(MSG_V2_CALIBRATION), lcd_v2_calibration); ////MSG_V2_CALIBRATION c=17 r=1 MENU_END(); } @@ -6415,7 +6428,6 @@ static void lcd_main_menu() } else { MENU_ITEM_SUBMENU_P(_i("Preheat"), lcd_preheat_menu);////MSG_PREHEAT - MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], lcd_sheet_menu); } @@ -6510,6 +6522,8 @@ 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 (!is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal)) { MENU_ITEM_SUBMENU_P(_i("Statistics "), lcd_menu_statistics);////MSG_STATISTICS