Skip to content

Commit

Permalink
🚸 SD card wake on insert, status screen on remove (MarlinFirmware#27197)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
dbuezas and thinkyhead committed Jul 6, 2024
1 parent 4af5229 commit 571783f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/lcd/dogm/marlinui_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ void MarlinUI::clear_for_drawing() {
#if HAS_DISPLAY_SLEEP
void MarlinUI::sleep_display(const bool sleep/*=true*/) {
static bool asleep = false;
if (asleep != sleep){
if (asleep != sleep) {
sleep ? u8g.sleepOn() : u8g.sleepOff();
asleep = sleep;
}
Expand Down
15 changes: 8 additions & 7 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1824,13 +1824,14 @@ void MarlinUI::host_notify(const char * const cstr) {
#endif

void MarlinUI::media_changed(const uint8_t old_status, const uint8_t status) {
TERN_(HAS_DISPLAY_SLEEP, refresh_screen_timeout());
if (old_status == status) {
TERN_(EXTENSIBLE_UI, ExtUI::onMediaError()); // Failed to mount/unmount
return;
}

if (status) {
if (old_status < 2) {
if (old_status < 2) { // Skip this section on first boot check
if (status) { // Media Mounted
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMediaMounted();
#elif ENABLED(BROWSE_MEDIA_ON_INSERT)
Expand All @@ -1841,16 +1842,16 @@ void MarlinUI::host_notify(const char * const cstr) {
LCD_MESSAGE(MSG_MEDIA_INSERTED);
#endif
}
}
else {
if (old_status < 2) {
else { // Media Removed
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMediaRemoved();
#elif HAS_SD_DETECT
#elif HAS_SD_DETECT // Q: Does "Media Removed" need to be shown for manual release too?
LCD_MESSAGE(MSG_MEDIA_REMOVED);
#if HAS_MARLINUI_MENU
if (!defer_return_to_status) return_to_status();
if (ENABLED(HAS_WIRED_LCD) || !defer_return_to_status) return_to_status();
#endif
#elif HAS_WIRED_LCD
return_to_status();
#endif
}
}
Expand Down
5 changes: 3 additions & 2 deletions Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class MarlinUI {
static void refresh_screen_timeout();
#endif

// Sleep or wake the display (e.g., by turning the backlight off/on).
static void sleep_display(const bool=true) IF_DISABLED(HAS_DISPLAY_SLEEP, {});
static void wake_display() { sleep_display(false); }

Expand Down Expand Up @@ -743,7 +744,7 @@ class MarlinUI {

static void draw_select_screen_prompt(FSTR_P const fpre, const char * const string=nullptr, FSTR_P const fsuf=nullptr);

#else
#else // !HAS_MARLINUI_MENU

static void return_to_status() {}

Expand All @@ -753,7 +754,7 @@ class MarlinUI {
FORCE_INLINE static void run_current_screen() { status_screen(); }
#endif

#endif
#endif // !HAS_MARLINUI_MENU

#if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI)
static bool lcd_clicked;
Expand Down

0 comments on commit 571783f

Please sign in to comment.