From cdcd45d651adb4b8997ea27d8815fa59b3efea14 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Wed, 26 Feb 2020 04:04:02 -0500 Subject: [PATCH] Set LCD status for EEPROM errors (#16977) --- Marlin/src/MarlinCore.cpp | 24 +++++++++++------------ Marlin/src/lcd/language/language_en.h | 3 +++ Marlin/src/lcd/ultralcd.cpp | 6 ++++-- Marlin/src/lcd/ultralcd.h | 4 ++-- Marlin/src/module/configuration_store.cpp | 9 +++++++++ 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index a07948e0c9..ab469d5818 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -995,32 +995,28 @@ void setup() { ui.show_bootscreen(); #endif - #if ENABLED(SDSUPPORT) - card.mount(); // Mount the SD card before settings.first_load - #endif + ui.reset_status(); // Load welcome message early. (Retained if no errors exist.) - // Load data from EEPROM if available (or use defaults) - // This also updates variables in the planner, elsewhere - settings.first_load(); + #if ENABLED(SDSUPPORT) + card.mount(); // Mount the SD card before settings.first_load + #endif + // Load data from EEPROM if available (or use defaults) + settings.first_load(); // This also updates variables in the planner, elsewhere #if ENABLED(TOUCH_BUTTONS) touch.init(); #endif - #if HAS_M206_COMMAND - // Initialize current position based on home_offset + #if HAS_M206_COMMAND // Initialize current position based on home_offset current_position += home_offset; #endif - // Vital to init stepper/planner equivalent for current_position - sync_plan_position(); + sync_plan_position(); // Vital to init stepper/planner equivalent for current_position thermalManager.init(); // Initialize temperature loop print_job_timer.init(); // Initial setup of print job timer - ui.reset_status(); // Print startup message after print statistics are loaded - endstops.init(); // Init endstops and pullups stepper.init(); // Init stepper. This enables interrupts! @@ -1175,6 +1171,10 @@ void setup() { #if ENABLED(PRUSA_MMU2) mmu2.init(); #endif + + #if HAS_SERVICE_INTERVALS + ui.reset_status(true); // Show service messages or keep current status + #endif } /** diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 6f1adbbf84..b5f508973d 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -314,6 +314,9 @@ namespace Language_en { PROGMEM Language_Str MSG_LOAD_EEPROM = _UxGT("Load Settings"); PROGMEM Language_Str MSG_RESTORE_DEFAULTS = _UxGT("Restore Defaults"); PROGMEM Language_Str MSG_INIT_EEPROM = _UxGT("Initialize EEPROM"); + PROGMEM Language_Str MSG_ERR_EEPROM_CRC = _UxGT("Err: EEPROM CRC"); + PROGMEM Language_Str MSG_ERR_EEPROM_INDEX = _UxGT("Err: EEPROM Index"); + PROGMEM Language_Str MSG_ERR_EEPROM_VERSION = _UxGT("Err: EEPROM Version"); PROGMEM Language_Str MSG_MEDIA_UPDATE = _UxGT("Media Update"); PROGMEM Language_Str MSG_RESET_PRINTER = _UxGT("Reset Printer"); PROGMEM Language_Str MSG_REFRESH = LCD_STR_REFRESH _UxGT("Refresh"); diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 8ad02acfba..422c8b0b81 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -1453,7 +1453,7 @@ void MarlinUI::update() { /** * Reset the status message */ - void MarlinUI::reset_status() { + void MarlinUI::reset_status(const bool no_welcome) { PGM_P printing = GET_TEXT(MSG_PRINTING); PGM_P welcome = GET_TEXT(WELCOME_MSG); #if SERVICE_INTERVAL_1 > 0 @@ -1485,8 +1485,10 @@ void MarlinUI::update() { else if (print_job_timer.needsService(3)) msg = service3; #endif - else + else if (!no_welcome) msg = welcome; + else + return; set_status_P(msg, -1); } diff --git a/Marlin/src/lcd/ultralcd.h b/Marlin/src/lcd/ultralcd.h index 8a328c4b91..f614e2009b 100644 --- a/Marlin/src/lcd/ultralcd.h +++ b/Marlin/src/lcd/ultralcd.h @@ -402,7 +402,7 @@ public: static void set_status(const char* const message, const bool persist=false); static void set_status_P(PGM_P const message, const int8_t level=0); static void status_printf_P(const uint8_t level, PGM_P const fmt, ...); - static void reset_status(); + static void reset_status(const bool no_welcome=false); #else // No LCD @@ -416,7 +416,7 @@ public: static inline void refresh() {} static inline void return_to_status() {} static inline void set_alert_status_P(PGM_P const) {} - static inline void reset_status() {} + static inline void reset_status(const bool=false) {} static inline void reset_alert_level() {} static constexpr bool has_status() { return false; } diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index efd9dadede..906038638f 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -1397,6 +1397,9 @@ void MarlinSettings::postprocess() { } DEBUG_ECHO_START(); DEBUG_ECHOLNPAIR("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); + #if HAS_LCD_MENU && DISABLED(EEPROM_AUTO_INIT) + ui.set_status_P(GET_TEXT(MSG_ERR_EEPROM_VERSION)); + #endif eeprom_error = true; } else { @@ -2205,11 +2208,17 @@ void MarlinSettings::postprocess() { if (eeprom_error) { DEBUG_ECHO_START(); DEBUG_ECHOLNPAIR("Index: ", int(eeprom_index - (EEPROM_OFFSET)), " Size: ", datasize()); + #if HAS_LCD_MENU && DISABLED(EEPROM_AUTO_INIT) + ui.set_status_P(GET_TEXT(MSG_ERR_EEPROM_INDEX)); + #endif } else if (working_crc != stored_crc) { eeprom_error = true; DEBUG_ERROR_START(); DEBUG_ECHOLNPAIR("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); + #if HAS_LCD_MENU && DISABLED(EEPROM_AUTO_INIT) + ui.set_status_P(GET_TEXT(MSG_ERR_EEPROM_CRC)); + #endif } else if (!validating) { DEBUG_ECHO_START();