Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved EEPROM boot error #17916

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Marlin/src/lcd/language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
16 changes: 4 additions & 12 deletions Marlin/src/lcd/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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();
}
}

Expand Down
5 changes: 0 additions & 5 deletions Marlin/src/lcd/menu/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 3 additions & 12 deletions Marlin/src/lcd/menu/menu_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_bed_corners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/menu/menu_bed_leveling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
13 changes: 5 additions & 8 deletions Marlin/src/lcd/menu/menu_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

#include "menu.h"

#include "../../module/configuration_store.h"

#if HAS_FILAMENT_SENSOR
#include "../../feature/runout.h"
#endif
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/menu/menu_delta_calibrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
107 changes: 66 additions & 41 deletions Marlin/src/lcd/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
);
}
Expand All @@ -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
Expand All @@ -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
}
}
Expand All @@ -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
Loading