0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-01-22 17:52:57 +00:00

🚸 SD card wake on insert, status screen on remove (#27197)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
David Buezas 2024-07-06 23:41:02 +01:00 committed by GitHub
parent 4af5229cee
commit 571783fc04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 10 deletions

View file

@ -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;
}

View file

@ -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)
@ -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
}
}

View file

@ -304,6 +304,7 @@ public:
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); }
@ -743,7 +744,7 @@ public:
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() {}
@ -753,7 +754,7 @@ public:
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;