Browse Source

🔧 TOUCH_IDLE_SLEEP_MINS => DISPLAY_SLEEP_MINUTES

Follow up to #26517
Scott Lahteine 1 year ago
parent
commit
1dee4d92c6

+ 0 - 1
Marlin/Configuration.h

@@ -3414,7 +3414,6 @@
   #define BUTTON_DELAY_MENU     250 // (ms) Button repeat delay for menus
   #define BUTTON_DELAY_MENU     250 // (ms) Button repeat delay for menus
 
 
   //#define DISABLE_ENCODER         // Disable the click encoder, if any
   //#define DISABLE_ENCODER         // Disable the click encoder, if any
-  //#define TOUCH_IDLE_SLEEP_MINS 5 // (minutes) Display Sleep after a period of inactivity. Set with M255 S.
 
 
   #define TOUCH_SCREEN_CALIBRATION
   #define TOUCH_SCREEN_CALIBRATION
 
 

+ 12 - 16
Marlin/Configuration_adv.h

@@ -1970,17 +1970,6 @@
   // Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese.
   // Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese.
   //#define USE_SMALL_INFOFONT
   //#define USE_SMALL_INFOFONT
 
 
-  /**
-   * Graphical Display Sleep
-   *
-   * The U8G library provides sleep / wake functions for SH1106, SSD1306,
-   * SSD1309, and some other DOGM displays.
-   * Enable this option to save energy and prevent OLED pixel burn-in.
-   * Adds the menu item Configuration > LCD Timeout (m) to set a wait period
-   * from 0 (disabled) to 99 minutes.
-   */
-  //#define DISPLAY_SLEEP_MINUTES 2  // (minutes) Timeout before turning off the screen. Set with M255 S.
-
   /**
   /**
    * ST7920-based LCDs can emulate a 16 x 4 character display using
    * ST7920-based LCDs can emulate a 16 x 4 character display using
    * the ST7920 character-generator for very fast screen updates.
    * the ST7920 character-generator for very fast screen updates.
@@ -2229,13 +2218,20 @@
   //#define TFT_BTOKMENU_COLOR 0x145F // 00010 100010 11111 Cyan
   //#define TFT_BTOKMENU_COLOR 0x145F // 00010 100010 11111 Cyan
 #endif
 #endif
 
 
-//
-// LCD Backlight Timeout
-// Requires a display with a controllable backlight
-//
+/**
+ * Display Sleep
+ * Enable this option to save energy and prevent OLED pixel burn-in.
+ */
+//#define DISPLAY_SLEEP_MINUTES 2       // (minutes) Timeout before turning off the screen
+
+/**
+ * LCD Backlight Timeout
+ * Requires a display with a controllable backlight
+ */
 //#define LCD_BACKLIGHT_TIMEOUT_MINS 1  // (minutes) Timeout before turning off the backlight
 //#define LCD_BACKLIGHT_TIMEOUT_MINS 1  // (minutes) Timeout before turning off the backlight
+
 #if defined(DISPLAY_SLEEP_MINUTES) || defined(LCD_BACKLIGHT_TIMEOUT_MINS)
 #if defined(DISPLAY_SLEEP_MINUTES) || defined(LCD_BACKLIGHT_TIMEOUT_MINS)
-  #define EDITABLE_DISPLAY_TIMEOUT      // Edit timeout with M255 S<minutes> and a menu item
+  #define EDITABLE_DISPLAY_TIMEOUT      // Edit sleep / backlight timeout with M255 S<minutes> and a menu item
 #endif
 #endif
 
 
 //
 //

+ 3 - 1
Marlin/src/inc/Changes.h

@@ -600,7 +600,9 @@
 #elif defined(LEVEL_CENTER_TOO)
 #elif defined(LEVEL_CENTER_TOO)
   #error "LEVEL_CENTER_TOO is now BED_TRAMMING_INCLUDE_CENTER."
   #error "LEVEL_CENTER_TOO is now BED_TRAMMING_INCLUDE_CENTER."
 #elif defined(TOUCH_IDLE_SLEEP)
 #elif defined(TOUCH_IDLE_SLEEP)
-  #error "TOUCH_IDLE_SLEEP (seconds) is now TOUCH_IDLE_SLEEP_MINS (minutes)."
+  #error "TOUCH_IDLE_SLEEP (seconds) is now DISPLAY_SLEEP_MINUTES (minutes)."
+#elif defined(TOUCH_IDLE_SLEEP_MINS)
+  #error "TOUCH_IDLE_SLEEP_MINS is now DISPLAY_SLEEP_MINUTES."
 #elif defined(LCD_BACKLIGHT_TIMEOUT)
 #elif defined(LCD_BACKLIGHT_TIMEOUT)
   #error "LCD_BACKLIGHT_TIMEOUT (seconds) is now LCD_BACKLIGHT_TIMEOUT_MINS (minutes)."
   #error "LCD_BACKLIGHT_TIMEOUT (seconds) is now LCD_BACKLIGHT_TIMEOUT_MINS (minutes)."
 #elif defined(LCD_SET_PROGRESS_MANUALLY)
 #elif defined(LCD_SET_PROGRESS_MANUALLY)

+ 0 - 3
Marlin/src/inc/Conditionals_LCD.h

@@ -1850,9 +1850,6 @@
 
 
 // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
 // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
 #if ENABLED(TOUCH_SCREEN)
 #if ENABLED(TOUCH_SCREEN)
-  #if TOUCH_IDLE_SLEEP_MINS
-    #define HAS_TOUCH_SLEEP 1
-  #endif
   #if NONE(TFT_TOUCH_DEVICE_GT911, TFT_TOUCH_DEVICE_XPT2046)
   #if NONE(TFT_TOUCH_DEVICE_GT911, TFT_TOUCH_DEVICE_XPT2046)
     #define TFT_TOUCH_DEVICE_XPT2046          // ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8
     #define TFT_TOUCH_DEVICE_XPT2046          // ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8
   #endif
   #endif

+ 1 - 1
Marlin/src/inc/Conditionals_adv.h

@@ -912,7 +912,7 @@
 #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, HAS_MEDIA)
 #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, HAS_MEDIA)
   #define HAS_LEDS_OFF_FLAG 1
   #define HAS_LEDS_OFF_FLAG 1
 #endif
 #endif
-#if defined(DISPLAY_SLEEP_MINUTES) || defined(TOUCH_IDLE_SLEEP_MINS)
+#ifdef DISPLAY_SLEEP_MINUTES
   #define HAS_DISPLAY_SLEEP 1
   #define HAS_DISPLAY_SLEEP 1
 #endif
 #endif
 #ifdef LCD_BACKLIGHT_TIMEOUT_MINS
 #ifdef LCD_BACKLIGHT_TIMEOUT_MINS

+ 11 - 11
Marlin/src/inc/SanityCheck.h

@@ -2785,6 +2785,8 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
 #if HAS_BACKLIGHT_TIMEOUT
 #if HAS_BACKLIGHT_TIMEOUT
   #if !HAS_ENCODER_ACTION && DISABLED(HAS_DWIN_E3V2)
   #if !HAS_ENCODER_ACTION && DISABLED(HAS_DWIN_E3V2)
     #error "LCD_BACKLIGHT_TIMEOUT_MINS requires an LCD with encoder or keypad."
     #error "LCD_BACKLIGHT_TIMEOUT_MINS requires an LCD with encoder or keypad."
+  #elif HAS_DISPLAY_SLEEP
+    #error "LCD_BACKLIGHT_TIMEOUT_MINS and DISPLAY_SLEEP_MINUTES are not currently supported at the same time."
   #elif ENABLED(NEOPIXEL_BKGD_INDEX_FIRST)
   #elif ENABLED(NEOPIXEL_BKGD_INDEX_FIRST)
     #if PIN_EXISTS(LCD_BACKLIGHT)
     #if PIN_EXISTS(LCD_BACKLIGHT)
       #error "LCD_BACKLIGHT_PIN and NEOPIXEL_BKGD_INDEX_FIRST are not supported at the same time."
       #error "LCD_BACKLIGHT_PIN and NEOPIXEL_BKGD_INDEX_FIRST are not supported at the same time."
@@ -2794,6 +2796,15 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
   #elif !PIN_EXISTS(LCD_BACKLIGHT) && DISABLED(HAS_DWIN_E3V2)
   #elif !PIN_EXISTS(LCD_BACKLIGHT) && DISABLED(HAS_DWIN_E3V2)
     #error "LCD_BACKLIGHT_TIMEOUT_MINS requires LCD_BACKLIGHT_PIN, NEOPIXEL_BKGD_INDEX_FIRST, or an Ender-3 V2 DWIN LCD."
     #error "LCD_BACKLIGHT_TIMEOUT_MINS requires LCD_BACKLIGHT_PIN, NEOPIXEL_BKGD_INDEX_FIRST, or an Ender-3 V2 DWIN LCD."
   #endif
   #endif
+#elif HAS_DISPLAY_SLEEP
+  #if NONE(TOUCH_SCREEN, HAS_MARLINUI_U8GLIB) || ANY(IS_U8GLIB_LM6059_AF, IS_U8GLIB_ST7565_64128, REPRAPWORLD_GRAPHICAL_LCD, FYSETC_MINI_12864, CR10_STOCKDISPLAY, MINIPANEL)
+    #error "DISPLAY_SLEEP_MINUTES is not supported by your display."
+    #undef HAS_DISPLAY_SLEEP
+  #elif !WITHIN(DISPLAY_SLEEP_MINUTES, 0, 255)
+    #error "DISPLAY_SLEEP_MINUTES must be between 0 and 255."
+  #elif DISABLED(EDITABLE_DISPLAY_TIMEOUT) && DISPLAY_SLEEP_MINUTES == 0
+    #error "DISPLAY_SLEEP_MINUTES must be greater than 0 with EDITABLE_DISPLAY_TIMEOUT disabled."
+  #endif
 #endif
 #endif
 
 
 // Startup Tune requirements
 // Startup Tune requirements
@@ -2806,17 +2817,6 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
   #endif
   #endif
 #endif
 #endif
 
 
-/**
- * Display Sleep is not supported by these common displays
- */
-#if HAS_DISPLAY_SLEEP
-  #if ANY(IS_U8GLIB_LM6059_AF, IS_U8GLIB_ST7565_64128, REPRAPWORLD_GRAPHICAL_LCD, FYSETC_MINI_12864, CR10_STOCKDISPLAY, MINIPANEL)
-    #error "DISPLAY_SLEEP_MINUTES is not supported by your display."
-  #elif !WITHIN(DISPLAY_SLEEP_MINUTES, 0, 255)
-    #error "DISPLAY_SLEEP_MINUTES must be between 0 and 255."
-  #endif
-#endif
-
 /**
 /**
  * Some boards forbid the use of -1 Native USB
  * Some boards forbid the use of -1 Native USB
  */
  */

+ 1 - 1
Marlin/src/lcd/dogm/marlinui_DOGM.cpp

@@ -377,7 +377,7 @@ void MarlinUI::draw_kill_screen() {
 void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
 void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
 
 
 #if HAS_DISPLAY_SLEEP
 #if HAS_DISPLAY_SLEEP
-  void MarlinUI::sleep_display(const bool sleep)  { sleep ? u8g.sleepOn() : u8g.sleepOff(); }
+  void MarlinUI::sleep_display(const bool sleep/*=true*/) { sleep ? u8g.sleepOn() : u8g.sleepOff(); }
 #endif
 #endif
 
 
 #if HAS_LCD_BRIGHTNESS
 #if HAS_LCD_BRIGHTNESS

+ 17 - 17
Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp

@@ -78,10 +78,6 @@ TFT_IO tftio;
   #include "../marlinui.h"
   #include "../marlinui.h"
 #endif
 #endif
 
 
-#if HAS_TOUCH_BUTTONS && HAS_TOUCH_SLEEP
-  #define HAS_TOUCH_BUTTONS_SLEEP 1
-#endif
-
 #include "../touch/touch_buttons.h"
 #include "../touch/touch_buttons.h"
 #include "../scaled_tft.h"
 #include "../scaled_tft.h"
 
 
@@ -389,25 +385,29 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
 
 
     case U8G_DEV_MSG_PAGE_FIRST: {
     case U8G_DEV_MSG_PAGE_FIRST: {
       page = 0;
       page = 0;
-      #if HAS_TOUCH_BUTTONS_SLEEP
-        static bool sleepCleared;
-        if (touchBt.isSleeping()) {
-          if (!sleepCleared) {
-            sleepCleared = true;
-            u8g_upscale_clear_lcd(u8g, dev, buffer);
-            TERN_(HAS_TOUCH_BUTTONS, redrawTouchButtons = true);
+      #if HAS_TOUCH_BUTTONS
+        #if HAS_DISPLAY_SLEEP
+          static bool sleepCleared;
+          if (touchBt.isSleeping()) {
+            if (!sleepCleared) {
+              sleepCleared = true;
+              u8g_upscale_clear_lcd(u8g, dev, buffer);
+              redrawTouchButtons = true;
+            }
+            break;
           }
           }
-          break;
-        }
-        else
-          sleepCleared = false;
+          else
+            sleepCleared = false;
+        #endif
+        drawTouchButtons(u8g, dev);
       #endif
       #endif
-      TERN_(HAS_TOUCH_BUTTONS, drawTouchButtons(u8g, dev));
       setWindow(u8g, dev, TFT_PIXEL_OFFSET_X, TFT_PIXEL_OFFSET_Y, X_HI, Y_HI);
       setWindow(u8g, dev, TFT_PIXEL_OFFSET_X, TFT_PIXEL_OFFSET_Y, X_HI, Y_HI);
     } break;
     } break;
 
 
     case U8G_DEV_MSG_PAGE_NEXT:
     case U8G_DEV_MSG_PAGE_NEXT:
-      if (TERN0(HAS_TOUCH_BUTTONS_SLEEP, touchBt.isSleeping())) break;
+      #if HAS_TOUCH_BUTTONS && HAS_DISPLAY_SLEEP
+        if (touchBt.isSleeping()) break;
+      #endif
       if (++page > (HEIGHT / PAGE_HEIGHT)) return 1;
       if (++page > (HEIGHT / PAGE_HEIGHT)) return 1;
 
 
       for (uint8_t y = 0; y < PAGE_HEIGHT; ++y) {
       for (uint8_t y = 0; y < PAGE_HEIGHT; ++y) {

+ 14 - 33
Marlin/src/lcd/marlinui.cpp

@@ -214,14 +214,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
 
 
   millis_t MarlinUI::screen_timeout_ms = 0;
   millis_t MarlinUI::screen_timeout_ms = 0;
   void MarlinUI::refresh_screen_timeout() {
   void MarlinUI::refresh_screen_timeout() {
-    screen_timeout_ms = sleep_timeout_minutes ? millis() + sleep_timeout_minutes * 60UL * 1000UL : 0;
-    sleep_display(false);
+    screen_timeout_ms = sleep_timeout_minutes ? millis() + MIN_TO_MS(sleep_timeout_minutes) : 0;
+    wake_display();
   }
   }
 
 
-  #if !HAS_TOUCH_SLEEP && !HAS_MARLINUI_U8GLIB // without DOGM (COLOR_UI)
-    void MarlinUI::sleep_display(const bool sleep) {} // if unimplemented
-  #endif
-
 #endif
 #endif
 
 
 void MarlinUI::init() {
 void MarlinUI::init() {
@@ -766,25 +762,9 @@ void MarlinUI::init() {
     draw_kill_screen();
     draw_kill_screen();
   }
   }
 
 
-  #if HAS_TOUCH_SLEEP
-    #if HAS_TOUCH_BUTTONS
-      #include "touch/touch_buttons.h"
-    #else
-      #include "tft/touch.h"
-    #endif
-    // Wake up a sleeping TFT
-    void MarlinUI::wakeup_screen() {
-      TERN(HAS_TOUCH_BUTTONS, touchBt.wakeUp(), touch.wakeUp());
-    }
-    #if HAS_DISPLAY_SLEEP && !HAS_MARLINUI_U8GLIB // without DOGM (COLOR_UI)
-      void MarlinUI::sleep_display(const bool sleep) {
-        if (!sleep) wakeup_screen(); // relay extra wake up events
-      }
-    #endif
-  #endif
-
   void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) {
   void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) {
-    TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up the TFT with most buttons
+    wake_display(); // Wake the screen for any click sound
+
     TERN_(HAS_MARLINUI_MENU, refresh());
     TERN_(HAS_MARLINUI_MENU, refresh());
 
 
     #if HAS_ENCODER_ACTION
     #if HAS_ENCODER_ACTION
@@ -1063,7 +1043,7 @@ void MarlinUI::init() {
             abs_diff = epps;                                            // Treat as a full step size
             abs_diff = epps;                                            // Treat as a full step size
             encoderDiff = (encoderDiff < 0 ? -1 : 1) * abs_diff;        // ...in the spin direction.
             encoderDiff = (encoderDiff < 0 ? -1 : 1) * abs_diff;        // ...in the spin direction.
           }
           }
-          TERN_(HAS_TOUCH_SLEEP, if (lastEncoderDiff != encoderDiff) wakeup_screen());
+          if (lastEncoderDiff != encoderDiff) wake_display();
           lastEncoderDiff = encoderDiff;
           lastEncoderDiff = encoderDiff;
         #endif
         #endif
 
 
@@ -1448,14 +1428,14 @@ void MarlinUI::init() {
 
 
   #endif // HAS_ENCODER_ACTION
   #endif // HAS_ENCODER_ACTION
 
 
+#endif // HAS_WIRED_LCD
+
+void MarlinUI::completion_feedback(const bool good/*=true*/) {
+  wake_display(); // Wake the screen for all audio feedback
   #if HAS_SOUND
   #if HAS_SOUND
-    void MarlinUI::completion_feedback(const bool good/*=true*/) {
-      TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click...
-      if (good) OKAY_BUZZ(); else ERR_BUZZ();
-    }
+    if (good) OKAY_BUZZ(); else ERR_BUZZ();
   #endif
   #endif
-
-#endif // HAS_WIRED_LCD
+}
 
 
 void MarlinUI::host_notify_P(PGM_P const pstr) {
 void MarlinUI::host_notify_P(PGM_P const pstr) {
   TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify_P(pstr));
   TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify_P(pstr));
@@ -1574,7 +1554,7 @@ void MarlinUI::host_notify(const char * const cstr) {
    */
    */
   void MarlinUI::_set_alert(const char * const ustr, const int8_t level, const bool pgm) {
   void MarlinUI::_set_alert(const char * const ustr, const int8_t level, const bool pgm) {
     pgm ? set_status_and_level_P(ustr, level) : set_status_and_level(ustr, level);
     pgm ? set_status_and_level_P(ustr, level) : set_status_and_level(ustr, level);
-    TERN_(HAS_TOUCH_SLEEP, wakeup_screen());
+    wake_display();
     TERN_(HAS_MARLINUI_MENU, return_to_status());
     TERN_(HAS_MARLINUI_MENU, return_to_status());
   }
   }
 
 
@@ -1722,7 +1702,8 @@ void MarlinUI::host_notify(const char * const cstr) {
       defer_status_screen();
       defer_status_screen();
     #endif
     #endif
 
 
-    TERN_(HAS_TOUCH_SLEEP, wakeup_screen());
+    wake_display();
+
     TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_PAUSE_RESUME, F("UI Pause"), F("Resume")));
     TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_PAUSE_RESUME, F("UI Pause"), F("Resume")));
 
 
     LCD_MESSAGE(MSG_PRINT_PAUSED);
     LCD_MESSAGE(MSG_PRINT_PAUSED);

+ 6 - 12
Marlin/src/lcd/marlinui.h

@@ -292,9 +292,11 @@ public:
     static constexpr uint8_t sleep_timeout_max = 99;
     static constexpr uint8_t sleep_timeout_max = 99;
     static millis_t screen_timeout_ms;
     static millis_t screen_timeout_ms;
     static void refresh_screen_timeout();
     static void refresh_screen_timeout();
-    static void sleep_display(const bool sleep=true);
   #endif
   #endif
 
 
+  static void sleep_display(const bool=true) IF_DISABLED(HAS_DISPLAY_SLEEP, {});
+  static void wake_display() { sleep_display(false); }
+
   #if HAS_DWIN_E3V2_BASIC
   #if HAS_DWIN_E3V2_BASIC
     static void refresh();
     static void refresh();
   #else
   #else
@@ -582,16 +584,7 @@ public:
         static void pause_filament_display(const millis_t ms=millis()) { next_filament_display = ms + 5000UL; }
         static void pause_filament_display(const millis_t ms=millis()) { next_filament_display = ms + 5000UL; }
       #endif
       #endif
 
 
-      #if HAS_TOUCH_SLEEP
-        static void wakeup_screen();
-      #endif
-
       static void quick_feedback(const bool clear_buttons=true);
       static void quick_feedback(const bool clear_buttons=true);
-      #if HAS_SOUND
-        static void completion_feedback(const bool good=true);
-      #else
-        static void completion_feedback(const bool=true) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); }
-      #endif
 
 
       #if ENABLED(ADVANCED_PAUSE_FEATURE)
       #if ENABLED(ADVANCED_PAUSE_FEATURE)
         static void draw_hotend_status(const uint8_t row, const uint8_t extruder);
         static void draw_hotend_status(const uint8_t row, const uint8_t extruder);
@@ -604,7 +597,7 @@ public:
 
 
       static void status_screen();
       static void status_screen();
 
 
-    #endif
+    #endif // HAS_WIRED_LCD
 
 
     #if HAS_MARLINUI_U8GLIB
     #if HAS_MARLINUI_U8GLIB
       static bool drawing_screen, first_page;
       static bool drawing_screen, first_page;
@@ -635,9 +628,10 @@ public:
 
 
   #if !HAS_WIRED_LCD
   #if !HAS_WIRED_LCD
     static void quick_feedback(const bool=true) {}
     static void quick_feedback(const bool=true) {}
-    static void completion_feedback(const bool=true) {}
   #endif
   #endif
 
 
+  static void completion_feedback(const bool good=true);
+
   #if HAS_MEDIA
   #if HAS_MEDIA
     #if ALL(SCROLL_LONG_FILENAMES, HAS_MARLINUI_MENU)
     #if ALL(SCROLL_LONG_FILENAMES, HAS_MARLINUI_MENU)
       #define MARLINUI_SCROLL_NAME 1
       #define MARLINUI_SCROLL_NAME 1

Some files were not shown because too many files changed in this diff