Improved EEPROM boot error (#17916)

This commit is contained in:
Scott Lahteine 2020-05-10 00:12:56 -05:00 committed by GitHub
parent 91fe0e1022
commit 52aa459a2d
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 125 additions and 106 deletions

View file

@ -328,9 +328,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_ERR_EEPROM_CRC = _UxGT("EEPROM CRC Error");
PROGMEM Language_Str MSG_ERR_EEPROM_INDEX = _UxGT("EEPROM Index Error");
PROGMEM Language_Str MSG_ERR_EEPROM_VERSION = _UxGT("EEPROM Version Error");
PROGMEM Language_Str MSG_SETTINGS_STORED = _UxGT("Settings Stored");
PROGMEM Language_Str MSG_MEDIA_UPDATE = _UxGT("Media Update");
PROGMEM Language_Str MSG_RESET_PRINTER = _UxGT("Reset Printer");
@ -344,6 +344,7 @@ namespace Language_en {
PROGMEM Language_Str MSG_BUTTON_STOP = _UxGT("Stop");
PROGMEM Language_Str MSG_BUTTON_PRINT = _UxGT("Print");
PROGMEM Language_Str MSG_BUTTON_RESET = _UxGT("Reset");
PROGMEM Language_Str MSG_BUTTON_IGNORE = _UxGT("Ignore");
PROGMEM Language_Str MSG_BUTTON_CANCEL = _UxGT("Cancel");
PROGMEM Language_Str MSG_BUTTON_DONE = _UxGT("Done");
PROGMEM Language_Str MSG_BUTTON_BACK = _UxGT("Back");

View file

@ -34,10 +34,6 @@
#include "../../libs/buzzer.h"
#endif
#if ENABLED(EEPROM_SETTINGS)
#include "../../module/configuration_store.h"
#endif
#if WATCH_HOTENDS || WATCH_BED
#include "../../module/temperature.h"
#endif
@ -228,7 +224,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
if (on_status_screen())
doubleclick_expire_ms = millis() + DOUBLECLICK_MAX_INTERVAL;
}
else if (screen == status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
else if (on_status_screen() && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
if ( (ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_known())
&& (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || printer_busy()) )
screen = TERN(BABYSTEP_ZPROBE_OFFSET, lcd_babystep_zoffset, lcd_babystep_z);
@ -245,7 +241,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
encoderPosition = encoder;
encoderTopLine = top;
screen_items = items;
if (screen == status_screen) {
if (on_status_screen()) {
defer_status_screen(false);
TERN_(AUTO_BED_LEVELING_UBL, ubl.lcd_map_control = false);
screen_history_depth = 0;
@ -256,7 +252,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
// Re-initialize custom characters that may be re-used
#if HAS_CHARACTER_LCD
if (TERN1(AUTO_BED_LEVELING_UBL, !ubl.lcd_map_control))
set_custom_characters(screen == status_screen ? CHARSET_INFO : CHARSET_MENU);
set_custom_characters(on_status_screen() ? CHARSET_INFO : CHARSET_MENU);
#endif
refresh(LCDVIEW_CALL_REDRAW_NEXT);
@ -383,11 +379,6 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
#endif // BABYSTEP_ZPROBE_OFFSET
#if ENABLED(EEPROM_SETTINGS)
void lcd_store_settings() { ui.completion_feedback(settings.save()); }
void lcd_load_settings() { ui.completion_feedback(settings.load()); }
#endif
void _lcd_draw_homing() {
constexpr uint8_t line = (LCD_HEIGHT - 1) / 2;
if (ui.should_draw()) MenuItem_static::draw(line, GET_TEXT(MSG_LEVEL_BED_HOMING));
@ -416,6 +407,7 @@ void MenuItem_confirm::select_screen(PGM_P const yes, PGM_P const no, selectFunc
if (got_click || ui.should_draw()) {
draw_select_screen(yes, no, ui_selection, pref, string, suff);
if (got_click) { ui_selection ? yesFunc() : noFunc(); }
ui.defer_status_screen();
}
}

View file

@ -589,11 +589,6 @@ void _lcd_draw_homing();
#endif
#endif
#if ENABLED(EEPROM_SETTINGS)
void lcd_store_settings();
void lcd_load_settings();
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
void menu_job_recovery();
#endif

View file

@ -47,7 +47,7 @@
#include "../../feature/runout.h"
#endif
#if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS)
#if ENABLED(SD_FIRMWARE_UPDATE)
#include "../../module/configuration_store.h"
#endif
@ -97,10 +97,6 @@ void menu_cancelobject();
#endif
#if ENABLED(SD_FIRMWARE_UPDATE)
#include "../../module/configuration_store.h"
#endif
#if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
//
// Advanced Settings > Filament
@ -591,13 +587,8 @@ void menu_advanced_settings() {
#if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS)
CONFIRM_ITEM(MSG_INIT_EEPROM,
MSG_BUTTON_INIT, MSG_BUTTON_CANCEL,
[]{
const bool inited = settings.init_eeprom();
ui.completion_feedback(inited);
UNUSED(inited);
},
ui.goto_previous_screen,
GET_TEXT(MSG_INIT_EEPROM), (PGM_P)nullptr, PSTR("?")
ui.init_eeprom, ui.goto_previous_screen,
GET_TEXT(MSG_INIT_EEPROM), (const char *)nullptr, PSTR("?")
);
#endif

View file

@ -86,7 +86,7 @@ static inline void _lcd_level_bed_corners_homing() {
ui.goto_previous_screen_no_defer();
}
, GET_TEXT(TERN(LEVEL_CENTER_TOO, MSG_LEVEL_BED_NEXT_POINT, MSG_NEXT_CORNER))
, (PGM_P)nullptr, PSTR("?")
, (const char*)nullptr, PSTR("?")
);
});
ui.set_selection(true);

View file

@ -279,8 +279,8 @@ void menu_bed_leveling() {
#endif
#if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_LOAD_EEPROM, lcd_load_settings);
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings);
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
#endif
END_MENU();
}

View file

@ -30,8 +30,6 @@
#include "menu.h"
#include "../../module/configuration_store.h"
#if HAS_FILAMENT_SENSOR
#include "../../feature/runout.h"
#endif
@ -174,7 +172,7 @@ void menu_advanced_settings();
EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_Y, &hotend_offset[1].y, -99.0, 99.0, _recalc_offsets);
EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_Z, &hotend_offset[1].z, Z_PROBE_LOW_POINT, 10.0, _recalc_offsets);
#if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
#endif
END_MENU();
}
@ -335,7 +333,7 @@ void menu_advanced_settings();
EDIT_ITEM(int3, MSG_BED, &ui.preheat_bed_temp[material], BED_MINTEMP, BED_MAX_TARGET);
#endif
#if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
#endif
END_MENU();
}
@ -439,12 +437,11 @@ void menu_configuration() {
#endif
#if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
if (!busy) ACTION_ITEM(MSG_LOAD_EEPROM, lcd_load_settings);
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
if (!busy) ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings);
#endif
if (!busy)
ACTION_ITEM(MSG_RESTORE_DEFAULTS, []{ settings.reset(); ui.completion_feedback(); });
if (!busy) ACTION_ITEM(MSG_RESTORE_DEFAULTS, ui.reset_settings);
END_MENU();
}

View file

@ -126,8 +126,8 @@ void menu_delta_calibrate() {
#if ENABLED(DELTA_AUTO_CALIBRATION)
GCODES_ITEM(MSG_DELTA_AUTO_CALIBRATE, PSTR("G33"));
#if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
ACTION_ITEM(MSG_LOAD_EEPROM, lcd_load_settings);
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings);
#endif
#endif

View file

@ -103,7 +103,7 @@ void menu_main() {
MenuItem_confirm::select_screen(
GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK),
ui.abort_print, ui.goto_previous_screen,
GET_TEXT(MSG_STOP_PRINT), (PGM_P)nullptr, PSTR("?")
GET_TEXT(MSG_STOP_PRINT), (const char *)nullptr, PSTR("?")
);
});
#endif

View file

@ -265,7 +265,7 @@ void menu_mixer() {
ui.return_to_status();
},
ui.goto_previous_screen,
GET_TEXT(MSG_RESET_VTOOLS), (PGM_P)nullptr, PSTR("?")
GET_TEXT(MSG_RESET_VTOOLS), (const char *)nullptr, PSTR("?")
);
#if ENABLED(GRADIENT_MIX)

View file

@ -95,6 +95,7 @@ MarlinUI ui;
#include "lcdprint.h"
#include "../sd/cardreader.h"
#include "../module/configuration_store.h"
#include "../module/temperature.h"
#include "../module/planner.h"
#include "../module/motion.h"
@ -879,11 +880,7 @@ void MarlinUI::update() {
// This runs every ~100ms when idling often enough.
// Instead of tracking changes just redraw the Status Screen once per second.
if (on_status_screen() && !lcd_status_update_delay--) {
lcd_status_update_delay = 9
#if HAS_GRAPHICAL_LCD
+ 3
#endif
;
lcd_status_update_delay = TERN(HAS_GRAPHICAL_LCD, 12, 9);
max_display_update_time--;
refresh(LCDVIEW_REDRAW_NOW);
}
@ -1167,11 +1164,7 @@ void MarlinUI::update() {
WRITE(SHIFT_CLK, HIGH);
WRITE(SHIFT_CLK, LOW);
}
#if ENABLED(REPRAPWORLD_KEYPAD)
keypad_buttons = ~val;
#else
buttons = ~val;
#endif
TERN(REPRAPWORLD_KEYPAD, keypad_buttons, buttons) = ~val;
#endif
} // next_button_update_ms
@ -1238,7 +1231,7 @@ void MarlinUI::update() {
void MarlinUI::finish_status(const bool persist) {
#if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0))
#if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE) > 0)
UNUSED(persist);
#endif
@ -1438,18 +1431,10 @@ void MarlinUI::update() {
#if HAS_PRINT_PROGRESS
MarlinUI::progress_t MarlinUI::_get_progress() {
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
const progress_t p = progress_override & PROGRESS_MASK;
#else
constexpr progress_t p = 0;
#endif
return (p
return (
TERN0(LCD_SET_PROGRESS_MANUALLY, (progress_override & PROGRESS_MASK))
#if ENABLED(SDSUPPORT)
#if HAS_PRINT_PROGRESS_PERMYRIAD
?: card.permyriadDone()
#else
?: card.percentDone()
#endif
?: TERN(HAS_PRINT_PROGRESS_PERMYRIAD, card.permyriadDone(), card.percentDone())
#endif
);
}
@ -1461,29 +1446,14 @@ void MarlinUI::update() {
//
// Send the status line as a host notification
//
void MarlinUI::set_status(const char * const message, const bool) {
#if ENABLED(HOST_PROMPT_SUPPORT)
host_action_notify(message);
#else
UNUSED(message);
#endif
TERN(HOST_PROMPT_SUPPORT, host_action_notify(message), UNUSED(message));
}
void MarlinUI::set_status_P(PGM_P message, const int8_t) {
#if ENABLED(HOST_PROMPT_SUPPORT)
host_action_notify(message);
#else
UNUSED(message);
#endif
TERN(HOST_PROMPT_SUPPORT, host_action_notify(message), UNUSED(message));
}
void MarlinUI::status_printf_P(const uint8_t, PGM_P const message, ...) {
#if ENABLED(HOST_PROMPT_SUPPORT)
host_action_notify(message);
#else
UNUSED(message);
#endif
TERN(HOST_PROMPT_SUPPORT, host_action_notify(message), UNUSED(message));
}
#endif // !HAS_DISPLAY
@ -1507,7 +1477,9 @@ void MarlinUI::update() {
TERN_(EXTENSIBLE_UI, ExtUI::onMediaRemoved()); // ExtUI response
#if PIN_EXISTS(SD_DETECT)
set_status_P(GET_TEXT(MSG_MEDIA_REMOVED));
TERN_(HAS_LCD_MENU, return_to_status());
#if HAS_LCD_MENU
if (!defer_return_to_status) return_to_status();
#endif
#endif
}
}
@ -1530,3 +1502,56 @@ void MarlinUI::update() {
}
#endif // SDSUPPORT
#if HAS_LCD_MENU
void MarlinUI::reset_settings() { settings.reset(); completion_feedback(); }
#endif
#if ENABLED(EEPROM_SETTINGS)
#if HAS_LCD_MENU
void MarlinUI::init_eeprom() {
const bool good = settings.init_eeprom();
completion_feedback(good);
return_to_status();
}
void MarlinUI::load_settings() {
const bool good = settings.load();
completion_feedback(good);
}
void MarlinUI::store_settings() {
const bool good = settings.save();
completion_feedback(good);
}
#endif
#if DISABLED(EEPROM_AUTO_INIT)
static inline PGM_P eeprom_err(const uint8_t msgid) {
switch (msgid) {
default:
case 0: return GET_TEXT(MSG_ERR_EEPROM_CRC);
case 1: return GET_TEXT(MSG_ERR_EEPROM_INDEX);
case 2: return GET_TEXT(MSG_ERR_EEPROM_VERSION);
}
}
void MarlinUI::eeprom_alert(const uint8_t msgid) {
#if HAS_LCD_MENU
editable.uint8 = msgid;
goto_screen([]{
PGM_P const restore_msg = GET_TEXT(MSG_RESTORE_DEFAULTS);
char msg[utf8_strlen_P(restore_msg) + 1];
strcpy_P(msg, restore_msg);
MenuItem_confirm::select_screen(
GET_TEXT(MSG_BUTTON_RESET), GET_TEXT(MSG_BUTTON_IGNORE),
init_eeprom, return_to_status,
eeprom_err(editable.uint8), msg, PSTR("?")
);
});
#else
set_status_P(eeprom_err(msgid));
#endif
}
#endif
#endif

View file

@ -544,14 +544,40 @@ public:
#endif
#define LCD_HAS_WAIT_FOR_MOVE EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) || (ENABLED(LCD_BED_LEVELING) && EITHER(PROBE_MANUALLY, MESH_BED_LEVELING))
//
// EEPROM: Reset / Init / Load / Store
//
#if HAS_LCD_MENU
static void reset_settings();
#endif
#if LCD_HAS_WAIT_FOR_MOVE
#if ENABLED(EEPROM_SETTINGS)
#if HAS_LCD_MENU
static void init_eeprom();
static void load_settings();
static void store_settings();
#endif
#if DISABLED(EEPROM_AUTO_INIT)
static void eeprom_alert(const uint8_t msgid);
static inline void eeprom_alert_crc() { eeprom_alert(0); }
static inline void eeprom_alert_index() { eeprom_alert(1); }
static inline void eeprom_alert_version() { eeprom_alert(2); }
#endif
#endif
//
// Special handling if a move is underway
//
#if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) || (ENABLED(LCD_BED_LEVELING) && EITHER(PROBE_MANUALLY, MESH_BED_LEVELING))
#define LCD_HAS_WAIT_FOR_MOVE 1
static bool wait_for_move;
#else
static constexpr bool wait_for_move = false;
#endif
//
// Block interaction while under external control
//
#if HAS_LCD_MENU && EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION)
static bool external_control;
FORCE_INLINE static void capture() { external_control = true; }
@ -615,12 +641,10 @@ private:
#endif
#if HAS_SPI_LCD
#if HAS_LCD_MENU
#if LCD_TIMEOUT_TO_STATUS > 0
static bool defer_return_to_status;
#else
static constexpr bool defer_return_to_status = false;
#endif
#if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS > 0
static bool defer_return_to_status;
#else
static constexpr bool defer_return_to_status = false;
#endif
static void draw_status_screen();
#endif

View file

@ -37,7 +37,7 @@
*/
// Change EEPROM version if the structure changes
#define EEPROM_VERSION "V78"
#define EEPROM_VERSION "V79"
#define EEPROM_OFFSET 100
// Check the integrity of data offsets.
@ -1367,9 +1367,7 @@ 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)
LCD_MESSAGEPGM(MSG_ERR_EEPROM_VERSION);
#endif
TERN(EEPROM_AUTO_INIT,,ui.eeprom_alert_version());
eeprom_error = true;
}
else {
@ -2141,17 +2139,13 @@ 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)
LCD_MESSAGEPGM(MSG_ERR_EEPROM_INDEX);
#endif
TERN(EEPROM_AUTO_INIT,,ui.eeprom_alert_index());
}
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)
LCD_MESSAGEPGM(MSG_ERR_EEPROM_CRC);
#endif
TERN(EEPROM_AUTO_INIT,,ui.eeprom_alert_crc());
}
else if (!validating) {
DEBUG_ECHO_START();