Skip to content

Commit 571783f

Browse files
dbuezasthinkyhead
andauthored
🚸 SD card wake on insert, status screen on remove (#27197)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent 4af5229 commit 571783f

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

Marlin/src/lcd/dogm/marlinui_DOGM.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ void MarlinUI::clear_for_drawing() {
392392
#if HAS_DISPLAY_SLEEP
393393
void MarlinUI::sleep_display(const bool sleep/*=true*/) {
394394
static bool asleep = false;
395-
if (asleep != sleep){
395+
if (asleep != sleep) {
396396
sleep ? u8g.sleepOn() : u8g.sleepOff();
397397
asleep = sleep;
398398
}

Marlin/src/lcd/marlinui.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -1824,13 +1824,14 @@ void MarlinUI::host_notify(const char * const cstr) {
18241824
#endif
18251825

18261826
void MarlinUI::media_changed(const uint8_t old_status, const uint8_t status) {
1827+
TERN_(HAS_DISPLAY_SLEEP, refresh_screen_timeout());
18271828
if (old_status == status) {
18281829
TERN_(EXTENSIBLE_UI, ExtUI::onMediaError()); // Failed to mount/unmount
18291830
return;
18301831
}
18311832

1832-
if (status) {
1833-
if (old_status < 2) {
1833+
if (old_status < 2) { // Skip this section on first boot check
1834+
if (status) { // Media Mounted
18341835
#if ENABLED(EXTENSIBLE_UI)
18351836
ExtUI::onMediaMounted();
18361837
#elif ENABLED(BROWSE_MEDIA_ON_INSERT)
@@ -1841,16 +1842,16 @@ void MarlinUI::host_notify(const char * const cstr) {
18411842
LCD_MESSAGE(MSG_MEDIA_INSERTED);
18421843
#endif
18431844
}
1844-
}
1845-
else {
1846-
if (old_status < 2) {
1845+
else { // Media Removed
18471846
#if ENABLED(EXTENSIBLE_UI)
18481847
ExtUI::onMediaRemoved();
1849-
#elif HAS_SD_DETECT
1848+
#elif HAS_SD_DETECT // Q: Does "Media Removed" need to be shown for manual release too?
18501849
LCD_MESSAGE(MSG_MEDIA_REMOVED);
18511850
#if HAS_MARLINUI_MENU
1852-
if (!defer_return_to_status) return_to_status();
1851+
if (ENABLED(HAS_WIRED_LCD) || !defer_return_to_status) return_to_status();
18531852
#endif
1853+
#elif HAS_WIRED_LCD
1854+
return_to_status();
18541855
#endif
18551856
}
18561857
}

Marlin/src/lcd/marlinui.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ class MarlinUI {
304304
static void refresh_screen_timeout();
305305
#endif
306306

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

@@ -743,7 +744,7 @@ class MarlinUI {
743744

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

746-
#else
747+
#else // !HAS_MARLINUI_MENU
747748

748749
static void return_to_status() {}
749750

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

756-
#endif
757+
#endif // !HAS_MARLINUI_MENU
757758

758759
#if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI)
759760
static bool lcd_clicked;

0 commit comments

Comments
 (0)