Browse Source

♻️ Display sleep minutes, encoder disable option (#24618)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
EvilGremlin 1 year ago
parent
commit
2f91154cbd
No account linked to committer's email address

+ 4
- 3
Marlin/Configuration.h View File

3156
 //
3156
 //
3157
 //#define TOUCH_SCREEN
3157
 //#define TOUCH_SCREEN
3158
 #if ENABLED(TOUCH_SCREEN)
3158
 #if ENABLED(TOUCH_SCREEN)
3159
-  #define BUTTON_DELAY_EDIT  50 // (ms) Button repeat delay for edit screens
3160
-  #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus
3159
+  #define BUTTON_DELAY_EDIT      50 // (ms) Button repeat delay for edit screens
3160
+  #define BUTTON_DELAY_MENU     250 // (ms) Button repeat delay for menus
3161
 
3161
 
3162
-  //#define TOUCH_IDLE_SLEEP 300 // (s) Turn off the TFT backlight if set (5mn)
3162
+  //#define DISABLE_ENCODER         // Disable the click encoder, if any
3163
+  //#define TOUCH_IDLE_SLEEP_MINS 5 // (minutes) Display Sleep after a period of inactivity. Set with M255 S.
3163
 
3164
 
3164
   #define TOUCH_SCREEN_CALIBRATION
3165
   #define TOUCH_SCREEN_CALIBRATION
3165
 
3166
 

+ 2
- 2
Marlin/Configuration_adv.h View File

1321
 //
1321
 //
1322
 // LCD Backlight Timeout
1322
 // LCD Backlight Timeout
1323
 //
1323
 //
1324
-//#define LCD_BACKLIGHT_TIMEOUT 30 // (s) Timeout before turning off the backlight
1324
+//#define LCD_BACKLIGHT_TIMEOUT_MINS 1  // (minutes) Timeout before turning off the backlight
1325
 
1325
 
1326
 #if HAS_BED_PROBE && EITHER(HAS_MARLINUI_MENU, HAS_TFT_LVGL_UI)
1326
 #if HAS_BED_PROBE && EITHER(HAS_MARLINUI_MENU, HAS_TFT_LVGL_UI)
1327
   //#define PROBE_OFFSET_WIZARD       // Add a Probe Z Offset calibration option to the LCD menu
1327
   //#define PROBE_OFFSET_WIZARD       // Add a Probe Z Offset calibration option to the LCD menu
1739
    * Adds the menu item Configuration > LCD Timeout (m) to set a wait period
1739
    * Adds the menu item Configuration > LCD Timeout (m) to set a wait period
1740
    * from 0 (disabled) to 99 minutes.
1740
    * from 0 (disabled) to 99 minutes.
1741
    */
1741
    */
1742
-  //#define DISPLAY_SLEEP_MINUTES 2  // (minutes) Timeout before turning off the screen
1742
+  //#define DISPLAY_SLEEP_MINUTES 2  // (minutes) Timeout before turning off the screen. Set with M255 S.
1743
 
1743
 
1744
   /**
1744
   /**
1745
    * ST7920-based LCDs can emulate a 16 x 4 character display using
1745
    * ST7920-based LCDs can emulate a 16 x 4 character display using

+ 5
- 9
Marlin/src/gcode/lcd/M255.cpp View File

32
  */
32
  */
33
 void GcodeSuite::M255() {
33
 void GcodeSuite::M255() {
34
   if (parser.seenval('S')) {
34
   if (parser.seenval('S')) {
35
+    const int m = parser.value_int();
35
     #if HAS_DISPLAY_SLEEP
36
     #if HAS_DISPLAY_SLEEP
36
-      const int m = parser.value_int();
37
-      ui.sleep_timeout_minutes = constrain(m, SLEEP_TIMEOUT_MIN, SLEEP_TIMEOUT_MAX);
37
+      ui.sleep_timeout_minutes = constrain(m, ui.sleep_timeout_min, ui.sleep_timeout_max);
38
     #else
38
     #else
39
-      const unsigned int s = parser.value_ushort() * 60;
40
-      ui.lcd_backlight_timeout = constrain(s, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX);
39
+      ui.backlight_timeout_minutes = constrain(m, ui.backlight_timeout_min, ui.backlight_timeout_max);
41
     #endif
40
     #endif
42
   }
41
   }
43
   else
42
   else
47
 void GcodeSuite::M255_report(const bool forReplay/*=true*/) {
46
 void GcodeSuite::M255_report(const bool forReplay/*=true*/) {
48
   report_heading_etc(forReplay, F(STR_DISPLAY_SLEEP));
47
   report_heading_etc(forReplay, F(STR_DISPLAY_SLEEP));
49
   SERIAL_ECHOLNPGM("  M255 S",
48
   SERIAL_ECHOLNPGM("  M255 S",
50
-    #if HAS_DISPLAY_SLEEP
51
-      ui.sleep_timeout_minutes, " ; (minutes)"
52
-    #else
53
-      ui.lcd_backlight_timeout, " ; (seconds)"
54
-    #endif
49
+    TERN(HAS_DISPLAY_SLEEP, ui.sleep_timeout_minutes, ui.backlight_timeout_minutes),
50
+    " ; (minutes)"
55
   );
51
   );
56
 }
52
 }
57
 
53
 

+ 1
- 1
Marlin/src/inc/Conditionals_LCD.h View File

1599
 
1599
 
1600
 // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
1600
 // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
1601
 #if ENABLED(TOUCH_SCREEN)
1601
 #if ENABLED(TOUCH_SCREEN)
1602
-  #if TOUCH_IDLE_SLEEP
1602
+  #if TOUCH_IDLE_SLEEP_MINS
1603
     #define HAS_TOUCH_SLEEP 1
1603
     #define HAS_TOUCH_SLEEP 1
1604
   #endif
1604
   #endif
1605
   #if NONE(TFT_TOUCH_DEVICE_GT911, TFT_TOUCH_DEVICE_XPT2046)
1605
   #if NONE(TFT_TOUCH_DEVICE_GT911, TFT_TOUCH_DEVICE_XPT2046)

+ 2
- 2
Marlin/src/inc/Conditionals_adv.h View File

647
 #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT)
647
 #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT)
648
   #define HAS_LEDS_OFF_FLAG 1
648
   #define HAS_LEDS_OFF_FLAG 1
649
 #endif
649
 #endif
650
-#ifdef DISPLAY_SLEEP_MINUTES
650
+#ifdef DISPLAY_SLEEP_MINUTES || TOUCH_IDLE_SLEEP_MINS
651
   #define HAS_DISPLAY_SLEEP 1
651
   #define HAS_DISPLAY_SLEEP 1
652
 #endif
652
 #endif
653
-#if HAS_DISPLAY_SLEEP || LCD_BACKLIGHT_TIMEOUT
653
+#if HAS_DISPLAY_SLEEP || LCD_BACKLIGHT_TIMEOUT_MINS
654
   #define HAS_GCODE_M255 1
654
   #define HAS_GCODE_M255 1
655
 #endif
655
 #endif
656
 
656
 

+ 4
- 0
Marlin/src/inc/Conditionals_post.h View File

3761
   #define HAS_ROTARY_ENCODER 1
3761
   #define HAS_ROTARY_ENCODER 1
3762
 #endif
3762
 #endif
3763
 
3763
 
3764
+#if DISABLED(DISABLE_ENCODER) && ANY(HAS_ROTARY_ENCODER, HAS_ADC_BUTTONS) && ANY(TFT_CLASSIC_UI, TFT_COLOR_UI)
3765
+  #define HAS_BACK_ITEM 1
3766
+#endif
3767
+
3764
 #if PIN_EXISTS(SAFE_POWER) && DISABLED(DISABLE_DRIVER_SAFE_POWER_PROTECT)
3768
 #if PIN_EXISTS(SAFE_POWER) && DISABLED(DISABLE_DRIVER_SAFE_POWER_PROTECT)
3765
   #define HAS_DRIVER_SAFE_POWER_PROTECT 1
3769
   #define HAS_DRIVER_SAFE_POWER_PROTECT 1
3766
 #endif
3770
 #endif

+ 7
- 3
Marlin/src/inc/SanityCheck.h View File

642
   #error "LEVEL_CORNERS_* settings have been renamed BED_TRAMMING_*."
642
   #error "LEVEL_CORNERS_* settings have been renamed BED_TRAMMING_*."
643
 #elif defined(LEVEL_CENTER_TOO)
643
 #elif defined(LEVEL_CENTER_TOO)
644
   #error "LEVEL_CENTER_TOO is now BED_TRAMMING_INCLUDE_CENTER."
644
   #error "LEVEL_CENTER_TOO is now BED_TRAMMING_INCLUDE_CENTER."
645
+#elif defined(TOUCH_IDLE_SLEEP)
646
+  #error "TOUCH_IDLE_SLEEP (seconds) is now TOUCH_IDLE_SLEEP_MINS (minutes)."
647
+#elif defined(LCD_BACKLIGHT_TIMEOUT)
648
+  #error "LCD_BACKLIGHT_TIMEOUT (seconds) is now LCD_BACKLIGHT_TIMEOUT_MINS (minutes)."
645
 #endif
649
 #endif
646
 
650
 
647
 // L64xx stepper drivers have been removed
651
 // L64xx stepper drivers have been removed
3030
   #endif
3034
   #endif
3031
 #endif
3035
 #endif
3032
 
3036
 
3033
-#if LCD_BACKLIGHT_TIMEOUT
3037
+#if LCD_BACKLIGHT_TIMEOUT_MINS
3034
   #if !HAS_ENCODER_ACTION
3038
   #if !HAS_ENCODER_ACTION
3035
-    #error "LCD_BACKLIGHT_TIMEOUT requires an LCD with encoder or keypad."
3039
+    #error "LCD_BACKLIGHT_TIMEOUT_MINS requires an LCD with encoder or keypad."
3036
   #elif !PIN_EXISTS(LCD_BACKLIGHT)
3040
   #elif !PIN_EXISTS(LCD_BACKLIGHT)
3037
-    #error "LCD_BACKLIGHT_TIMEOUT requires LCD_BACKLIGHT_PIN."
3041
+    #error "LCD_BACKLIGHT_TIMEOUT_MINS requires LCD_BACKLIGHT_PIN."
3038
   #endif
3042
   #endif
3039
 #endif
3043
 #endif
3040
 
3044
 

+ 1
- 2
Marlin/src/lcd/dogm/marlinui_DOGM.cpp View File

343
 void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
343
 void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
344
 
344
 
345
 #if HAS_DISPLAY_SLEEP
345
 #if HAS_DISPLAY_SLEEP
346
-  void MarlinUI::sleep_on()  { u8g.sleepOn(); }
347
-  void MarlinUI::sleep_off() { u8g.sleepOff(); }
346
+  void MarlinUI::sleep_display(const bool sleep)  { sleep ? u8g.sleepOn() : u8g.sleepOff(); }
348
 #endif
347
 #endif
349
 
348
 
350
 #if HAS_LCD_BRIGHTNESS
349
 #if HAS_LCD_BRIGHTNESS

+ 0
- 1
Marlin/src/lcd/language/language_de.h View File

407
   LSTR MSG_ADVANCE_K_E                    = _UxGT("Vorschubfaktor *");
407
   LSTR MSG_ADVANCE_K_E                    = _UxGT("Vorschubfaktor *");
408
   LSTR MSG_CONTRAST                       = _UxGT("LCD-Kontrast");
408
   LSTR MSG_CONTRAST                       = _UxGT("LCD-Kontrast");
409
   LSTR MSG_BRIGHTNESS                     = _UxGT("LCD-Helligkeit");
409
   LSTR MSG_BRIGHTNESS                     = _UxGT("LCD-Helligkeit");
410
-  LSTR MSG_LCD_TIMEOUT_SEC                = _UxGT("LCD-Ruhezustand (s)");
411
   LSTR MSG_SCREEN_TIMEOUT                 = _UxGT("LCD Timeout (m)");
410
   LSTR MSG_SCREEN_TIMEOUT                 = _UxGT("LCD Timeout (m)");
412
   LSTR MSG_BRIGHTNESS_OFF                 = _UxGT("LCD ausschalten");
411
   LSTR MSG_BRIGHTNESS_OFF                 = _UxGT("LCD ausschalten");
413
   LSTR MSG_STORE_EEPROM                   = _UxGT("Konfig. speichern");
412
   LSTR MSG_STORE_EEPROM                   = _UxGT("Konfig. speichern");

+ 0
- 1
Marlin/src/lcd/language/language_en.h View File

422
   LSTR MSG_ADVANCE_K_E                    = _UxGT("Advance K *");
422
   LSTR MSG_ADVANCE_K_E                    = _UxGT("Advance K *");
423
   LSTR MSG_CONTRAST                       = _UxGT("LCD Contrast");
423
   LSTR MSG_CONTRAST                       = _UxGT("LCD Contrast");
424
   LSTR MSG_BRIGHTNESS                     = _UxGT("LCD Brightness");
424
   LSTR MSG_BRIGHTNESS                     = _UxGT("LCD Brightness");
425
-  LSTR MSG_LCD_TIMEOUT_SEC                = _UxGT("LCD Timeout (s)");
426
   LSTR MSG_SCREEN_TIMEOUT                 = _UxGT("LCD Timeout (m)");
425
   LSTR MSG_SCREEN_TIMEOUT                 = _UxGT("LCD Timeout (m)");
427
   LSTR MSG_BRIGHTNESS_OFF                 = _UxGT("Backlight Off");
426
   LSTR MSG_BRIGHTNESS_OFF                 = _UxGT("Backlight Off");
428
   LSTR MSG_STORE_EEPROM                   = _UxGT("Store Settings");
427
   LSTR MSG_STORE_EEPROM                   = _UxGT("Store Settings");

+ 1
- 1
Marlin/src/lcd/language/language_fr.h View File

321
   LSTR MSG_ADVANCE_K_E                    = _UxGT("Avance K *");
321
   LSTR MSG_ADVANCE_K_E                    = _UxGT("Avance K *");
322
   LSTR MSG_BRIGHTNESS                     = _UxGT("Luminosité LCD");
322
   LSTR MSG_BRIGHTNESS                     = _UxGT("Luminosité LCD");
323
   LSTR MSG_CONTRAST                       = _UxGT("Contraste LCD");
323
   LSTR MSG_CONTRAST                       = _UxGT("Contraste LCD");
324
-  LSTR MSG_LCD_TIMEOUT_SEC                = _UxGT("Veille LCD (s)");
324
+  LSTR MSG_SCREEN_TIMEOUT                 = _UxGT("Veille LCD (m)");
325
   LSTR MSG_BRIGHTNESS_OFF                 = _UxGT("Éteindre l'écran LCD");
325
   LSTR MSG_BRIGHTNESS_OFF                 = _UxGT("Éteindre l'écran LCD");
326
   LSTR MSG_STORE_EEPROM                   = _UxGT("Enregistrer config.");
326
   LSTR MSG_STORE_EEPROM                   = _UxGT("Enregistrer config.");
327
   LSTR MSG_LOAD_EEPROM                    = _UxGT("Charger config.");
327
   LSTR MSG_LOAD_EEPROM                    = _UxGT("Charger config.");

+ 0
- 1
Marlin/src/lcd/language/language_it.h View File

418
   LSTR MSG_ADVANCE_K_E                    = _UxGT("K Avanzamento *");
418
   LSTR MSG_ADVANCE_K_E                    = _UxGT("K Avanzamento *");
419
   LSTR MSG_CONTRAST                       = _UxGT("Contrasto LCD");
419
   LSTR MSG_CONTRAST                       = _UxGT("Contrasto LCD");
420
   LSTR MSG_BRIGHTNESS                     = _UxGT("Luminosità LCD");
420
   LSTR MSG_BRIGHTNESS                     = _UxGT("Luminosità LCD");
421
-  LSTR MSG_LCD_TIMEOUT_SEC                = _UxGT("Timeout LCD (s)");
422
   LSTR MSG_SCREEN_TIMEOUT                 = _UxGT("Timeout LCD (m)");
421
   LSTR MSG_SCREEN_TIMEOUT                 = _UxGT("Timeout LCD (m)");
423
   LSTR MSG_BRIGHTNESS_OFF                 = _UxGT("Spegni Retroillum.");
422
   LSTR MSG_BRIGHTNESS_OFF                 = _UxGT("Spegni Retroillum.");
424
   LSTR MSG_STORE_EEPROM                   = _UxGT("Salva impostazioni");
423
   LSTR MSG_STORE_EEPROM                   = _UxGT("Salva impostazioni");

+ 0
- 1
Marlin/src/lcd/language/language_sk.h View File

419
   LSTR MSG_ADVANCE_K_E                    = _UxGT("K pre posun *");
419
   LSTR MSG_ADVANCE_K_E                    = _UxGT("K pre posun *");
420
   LSTR MSG_CONTRAST                       = _UxGT("Kontrast LCD");
420
   LSTR MSG_CONTRAST                       = _UxGT("Kontrast LCD");
421
   LSTR MSG_BRIGHTNESS                     = _UxGT("Jas LCD");
421
   LSTR MSG_BRIGHTNESS                     = _UxGT("Jas LCD");
422
-  LSTR MSG_LCD_TIMEOUT_SEC                = _UxGT("Čas. limit LCD (s)");
423
   LSTR MSG_SCREEN_TIMEOUT                 = _UxGT("Čas. limit LCD (m)");
422
   LSTR MSG_SCREEN_TIMEOUT                 = _UxGT("Čas. limit LCD (m)");
424
   LSTR MSG_BRIGHTNESS_OFF                 = _UxGT("Podsviet. vyp.");
423
   LSTR MSG_BRIGHTNESS_OFF                 = _UxGT("Podsviet. vyp.");
425
   LSTR MSG_STORE_EEPROM                   = _UxGT("Uložiť nastavenie");
424
   LSTR MSG_STORE_EEPROM                   = _UxGT("Uložiť nastavenie");

+ 1
- 1
Marlin/src/lcd/language/language_uk.h View File

455
     LSTR MSG_CONTRAST                       = _UxGT("Контраст");
455
     LSTR MSG_CONTRAST                       = _UxGT("Контраст");
456
     LSTR MSG_BRIGHTNESS                     = _UxGT("Яскравість");
456
     LSTR MSG_BRIGHTNESS                     = _UxGT("Яскравість");
457
   #endif
457
   #endif
458
-  LSTR MSG_LCD_TIMEOUT_SEC                  = _UxGT("LCD Таймаут, с");
458
+  LSTR MSG_SCREEN_TIMEOUT                   = _UxGT("LCD Таймаут, x");
459
   LSTR MSG_BRIGHTNESS_OFF                   = _UxGT("Підсвітка вимк.");
459
   LSTR MSG_BRIGHTNESS_OFF                   = _UxGT("Підсвітка вимк.");
460
   LSTR MSG_STORE_EEPROM                     = _UxGT("Зберегти в EEPROM");
460
   LSTR MSG_STORE_EEPROM                     = _UxGT("Зберегти в EEPROM");
461
   LSTR MSG_LOAD_EEPROM                      = _UxGT("Зчитати з EEPROM");
461
   LSTR MSG_LOAD_EEPROM                      = _UxGT("Зчитати з EEPROM");

+ 11
- 7
Marlin/src/lcd/marlinui.cpp View File

174
   volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update
174
   volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update
175
 #endif
175
 #endif
176
 
176
 
177
-#if LCD_BACKLIGHT_TIMEOUT
177
+#if LCD_BACKLIGHT_TIMEOUT_MINS
178
 
178
 
179
-  uint16_t MarlinUI::lcd_backlight_timeout; // Initialized by settings.load()
179
+  constexpr uint8_t MarlinUI::backlight_timeout_min, MarlinUI::backlight_timeout_max;
180
+
181
+  uint8_t MarlinUI::backlight_timeout_minutes; // Initialized by settings.load()
180
   millis_t MarlinUI::backlight_off_ms = 0;
182
   millis_t MarlinUI::backlight_off_ms = 0;
181
   void MarlinUI::refresh_backlight_timeout() {
183
   void MarlinUI::refresh_backlight_timeout() {
182
-    backlight_off_ms = lcd_backlight_timeout ? millis() + lcd_backlight_timeout * 1000UL : 0;
184
+    backlight_off_ms = backlight_timeout_minutes ? millis() + backlight_timeout_minutes * 60UL * 1000UL : 0;
183
     WRITE(LCD_BACKLIGHT_PIN, HIGH);
185
     WRITE(LCD_BACKLIGHT_PIN, HIGH);
184
   }
186
   }
185
 
187
 
186
 #elif HAS_DISPLAY_SLEEP
188
 #elif HAS_DISPLAY_SLEEP
187
 
189
 
190
+  constexpr uint8_t MarlinUI::sleep_timeout_min, MarlinUI::sleep_timeout_max;
191
+
188
   uint8_t MarlinUI::sleep_timeout_minutes; // Initialized by settings.load()
192
   uint8_t MarlinUI::sleep_timeout_minutes; // Initialized by settings.load()
189
   millis_t MarlinUI::screen_timeout_millis = 0;
193
   millis_t MarlinUI::screen_timeout_millis = 0;
190
   void MarlinUI::refresh_screen_timeout() {
194
   void MarlinUI::refresh_screen_timeout() {
191
     screen_timeout_millis = sleep_timeout_minutes ? millis() + sleep_timeout_minutes * 60UL * 1000UL : 0;
195
     screen_timeout_millis = sleep_timeout_minutes ? millis() + sleep_timeout_minutes * 60UL * 1000UL : 0;
192
-    sleep_off();
196
+    sleep_display(false);
193
   }
197
   }
194
 
198
 
195
 #endif
199
 #endif
1059
 
1063
 
1060
           reset_status_timeout(ms);
1064
           reset_status_timeout(ms);
1061
 
1065
 
1062
-          #if LCD_BACKLIGHT_TIMEOUT
1066
+          #if LCD_BACKLIGHT_TIMEOUT_MINS
1063
             refresh_backlight_timeout();
1067
             refresh_backlight_timeout();
1064
           #elif HAS_DISPLAY_SLEEP
1068
           #elif HAS_DISPLAY_SLEEP
1065
             refresh_screen_timeout();
1069
             refresh_screen_timeout();
1169
           return_to_status();
1173
           return_to_status();
1170
       #endif
1174
       #endif
1171
 
1175
 
1172
-      #if LCD_BACKLIGHT_TIMEOUT
1176
+      #if LCD_BACKLIGHT_TIMEOUT_MINS
1173
         if (backlight_off_ms && ELAPSED(ms, backlight_off_ms)) {
1177
         if (backlight_off_ms && ELAPSED(ms, backlight_off_ms)) {
1174
           WRITE(LCD_BACKLIGHT_PIN, LOW); // Backlight off
1178
           WRITE(LCD_BACKLIGHT_PIN, LOW); // Backlight off
1175
           backlight_off_ms = 0;
1179
           backlight_off_ms = 0;
1176
         }
1180
         }
1177
       #elif HAS_DISPLAY_SLEEP
1181
       #elif HAS_DISPLAY_SLEEP
1178
         if (screen_timeout_millis && ELAPSED(ms, screen_timeout_millis))
1182
         if (screen_timeout_millis && ELAPSED(ms, screen_timeout_millis))
1179
-          sleep_on();
1183
+          sleep_display();
1180
       #endif
1184
       #endif
1181
 
1185
 
1182
       // Change state of drawing flag between screen updates
1186
       // Change state of drawing flag between screen updates

+ 7
- 8
Marlin/src/lcd/marlinui.h View File

270
     FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); }
270
     FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); }
271
   #endif
271
   #endif
272
 
272
 
273
-  #if LCD_BACKLIGHT_TIMEOUT
274
-    #define LCD_BKL_TIMEOUT_MIN 1u
275
-    #define LCD_BKL_TIMEOUT_MAX UINT16_MAX // Slightly more than 18 hours
276
-    static uint16_t lcd_backlight_timeout;
273
+  #if LCD_BACKLIGHT_TIMEOUT_MINS
274
+    static constexpr uint8_t backlight_timeout_min = 0;
275
+    static constexpr uint8_t backlight_timeout_max = 99;
276
+    static uint8_t backlight_timeout_minutes;
277
     static millis_t backlight_off_ms;
277
     static millis_t backlight_off_ms;
278
     static void refresh_backlight_timeout();
278
     static void refresh_backlight_timeout();
279
   #elif HAS_DISPLAY_SLEEP
279
   #elif HAS_DISPLAY_SLEEP
280
-    #define SLEEP_TIMEOUT_MIN 0
281
-    #define SLEEP_TIMEOUT_MAX 99
280
+    static constexpr uint8_t sleep_timeout_min = 0;
281
+    static constexpr uint8_t sleep_timeout_max = 99;
282
     static uint8_t sleep_timeout_minutes;
282
     static uint8_t sleep_timeout_minutes;
283
     static millis_t screen_timeout_millis;
283
     static millis_t screen_timeout_millis;
284
     static void refresh_screen_timeout();
284
     static void refresh_screen_timeout();
285
-    static void sleep_on();
286
-    static void sleep_off();
285
+    static void sleep_display(const bool sleep=true);
287
   #endif
286
   #endif
288
 
287
 
289
   #if HAS_DWIN_E3V2_BASIC
288
   #if HAS_DWIN_E3V2_BASIC

+ 3
- 3
Marlin/src/lcd/menu/menu_configuration.cpp View File

547
   //
547
   //
548
   // Set display backlight / sleep timeout
548
   // Set display backlight / sleep timeout
549
   //
549
   //
550
-  #if LCD_BACKLIGHT_TIMEOUT && LCD_BKL_TIMEOUT_MIN < LCD_BKL_TIMEOUT_MAX
551
-    EDIT_ITEM(uint16_4, MSG_LCD_TIMEOUT_SEC, &ui.lcd_backlight_timeout, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX, ui.refresh_backlight_timeout);
550
+  #if LCD_BACKLIGHT_TIMEOUT_MINS
551
+    EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.backlight_timeout_minutes, ui.backlight_timeout_min, ui.backlight_timeout_max, ui.refresh_backlight_timeout);
552
   #elif HAS_DISPLAY_SLEEP
552
   #elif HAS_DISPLAY_SLEEP
553
-    EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.sleep_timeout_minutes, SLEEP_TIMEOUT_MIN, SLEEP_TIMEOUT_MAX, ui.refresh_screen_timeout);
553
+    EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.sleep_timeout_minutes, ui.sleep_timeout_min, ui.sleep_timeout_max, ui.refresh_screen_timeout);
554
   #endif
554
   #endif
555
 
555
 
556
   #if ENABLED(FWRETRACT)
556
   #if ENABLED(FWRETRACT)

+ 7
- 2
Marlin/src/lcd/menu/menu_item.h View File

402
 
402
 
403
 // Predefined menu item types //
403
 // Predefined menu item types //
404
 
404
 
405
-#define BACK_ITEM_F(FLABEL)                              MENU_ITEM_F(back, FLABEL)
406
-#define BACK_ITEM(LABEL)                                   MENU_ITEM(back, LABEL)
405
+#if HAS_BACK_ITEM
406
+  #define BACK_ITEM_F(FLABEL)                            MENU_ITEM_F(back, FLABEL)
407
+  #define BACK_ITEM(LABEL)                                 MENU_ITEM(back, LABEL)
408
+#else
409
+  #define BACK_ITEM_F(FLABEL) NOOP
410
+  #define BACK_ITEM(LABEL)    NOOP
411
+#endif
407
 
412
 
408
 #define ACTION_ITEM_N_S_F(N, S, FLABEL, ACTION)      MENU_ITEM_N_S_F(function, N, S, FLABEL, ACTION)
413
 #define ACTION_ITEM_N_S_F(N, S, FLABEL, ACTION)      MENU_ITEM_N_S_F(function, N, S, FLABEL, ACTION)
409
 #define ACTION_ITEM_N_S(N, S, LABEL, ACTION)       ACTION_ITEM_N_S_F(N, S, GET_TEXT_F(LABEL), ACTION)
414
 #define ACTION_ITEM_N_S(N, S, LABEL, ACTION)       ACTION_ITEM_N_S_F(N, S, GET_TEXT_F(LABEL), ACTION)

+ 11
- 11
Marlin/src/lcd/menu/menu_main.cpp View File

325
     SUBMENU(MSG_TEMPERATURE, menu_temperature);
325
     SUBMENU(MSG_TEMPERATURE, menu_temperature);
326
   #endif
326
   #endif
327
 
327
 
328
+  #if ENABLED(ADVANCED_PAUSE_FEATURE)
329
+    #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES)
330
+      YESNO_ITEM(MSG_FILAMENTCHANGE,
331
+        menu_change_filament, nullptr,
332
+        GET_TEXT_F(MSG_FILAMENTCHANGE), (const char *)nullptr, F("?")
333
+      );
334
+    #else
335
+      SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament);
336
+    #endif
337
+  #endif
338
+
328
   #if HAS_POWER_MONITOR
339
   #if HAS_POWER_MONITOR
329
     SUBMENU(MSG_POWER_MONITOR, menu_power_monitor);
340
     SUBMENU(MSG_POWER_MONITOR, menu_power_monitor);
330
   #endif
341
   #endif
349
     }
360
     }
350
   #endif
361
   #endif
351
 
362
 
352
-  #if ENABLED(ADVANCED_PAUSE_FEATURE)
353
-    #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES)
354
-      YESNO_ITEM(MSG_FILAMENTCHANGE,
355
-        menu_change_filament, nullptr,
356
-        GET_TEXT_F(MSG_FILAMENTCHANGE), (const char *)nullptr, F("?")
357
-      );
358
-    #else
359
-      SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament);
360
-    #endif
361
-  #endif
362
-
363
   #if ENABLED(LCD_INFO_MENU)
363
   #if ENABLED(LCD_INFO_MENU)
364
     SUBMENU(MSG_INFO_MENU, menu_info);
364
     SUBMENU(MSG_INFO_MENU, menu_info);
365
   #endif
365
   #endif

+ 1
- 1
Marlin/src/lcd/tft/touch.cpp View File

302
         WRITE(TFT_BACKLIGHT_PIN, HIGH);
302
         WRITE(TFT_BACKLIGHT_PIN, HIGH);
303
       #endif
303
       #endif
304
     }
304
     }
305
-    next_sleep_ms = millis() + SEC_TO_MS(TOUCH_IDLE_SLEEP);
305
+    next_sleep_ms = millis() + SEC_TO_MS(ui.sleep_timeout_minutes * 60);
306
   }
306
   }
307
 
307
 
308
 #endif // HAS_TOUCH_SLEEP
308
 #endif // HAS_TOUCH_SLEEP

+ 2
- 2
Marlin/src/lcd/touch/touch_buttons.cpp View File

61
 
61
 
62
 void TouchButtons::init() {
62
 void TouchButtons::init() {
63
   touchIO.Init();
63
   touchIO.Init();
64
-  TERN_(HAS_TOUCH_SLEEP, next_sleep_ms = millis() + SEC_TO_MS(TOUCH_IDLE_SLEEP));
64
+  TERN_(HAS_TOUCH_SLEEP, next_sleep_ms = millis() + SEC_TO_MS(ui.sleep_timeout_minutes * 60));
65
 }
65
 }
66
 
66
 
67
 uint8_t TouchButtons::read_buttons() {
67
 uint8_t TouchButtons::read_buttons() {
135
         WRITE(TFT_BACKLIGHT_PIN, HIGH);
135
         WRITE(TFT_BACKLIGHT_PIN, HIGH);
136
       #endif
136
       #endif
137
     }
137
     }
138
-    next_sleep_ms = millis() + SEC_TO_MS(TOUCH_IDLE_SLEEP);
138
+    next_sleep_ms = millis() + SEC_TO_MS(ui.sleep_timeout_minutes * 60);
139
   }
139
   }
140
 
140
 
141
 #endif // HAS_TOUCH_SLEEP
141
 #endif // HAS_TOUCH_SLEEP

+ 9
- 9
Marlin/src/module/settings.cpp View File

402
   //
402
   //
403
   // Display Sleep
403
   // Display Sleep
404
   //
404
   //
405
-  #if LCD_BACKLIGHT_TIMEOUT
406
-    uint16_t lcd_backlight_timeout;                     // M255 S
405
+  #if LCD_BACKLIGHT_TIMEOUT_MINS
406
+    uint8_t backlight_timeout_minutes;                  // M255 S
407
   #elif HAS_DISPLAY_SLEEP
407
   #elif HAS_DISPLAY_SLEEP
408
     uint8_t sleep_timeout_minutes;                      // M255 S
408
     uint8_t sleep_timeout_minutes;                      // M255 S
409
   #endif
409
   #endif
640
   TERN_(HAS_LCD_CONTRAST, ui.refresh_contrast());
640
   TERN_(HAS_LCD_CONTRAST, ui.refresh_contrast());
641
   TERN_(HAS_LCD_BRIGHTNESS, ui.refresh_brightness());
641
   TERN_(HAS_LCD_BRIGHTNESS, ui.refresh_brightness());
642
 
642
 
643
-  #if LCD_BACKLIGHT_TIMEOUT
643
+  #if LCD_BACKLIGHT_TIMEOUT_MINS
644
     ui.refresh_backlight_timeout();
644
     ui.refresh_backlight_timeout();
645
   #elif HAS_DISPLAY_SLEEP
645
   #elif HAS_DISPLAY_SLEEP
646
     ui.refresh_screen_timeout();
646
     ui.refresh_screen_timeout();
1157
     //
1157
     //
1158
     // LCD Backlight / Sleep Timeout
1158
     // LCD Backlight / Sleep Timeout
1159
     //
1159
     //
1160
-    #if LCD_BACKLIGHT_TIMEOUT
1161
-      EEPROM_WRITE(ui.lcd_backlight_timeout);
1160
+    #if LCD_BACKLIGHT_TIMEOUT_MINS
1161
+      EEPROM_WRITE(ui.backlight_timeout_minutes);
1162
     #elif HAS_DISPLAY_SLEEP
1162
     #elif HAS_DISPLAY_SLEEP
1163
       EEPROM_WRITE(ui.sleep_timeout_minutes);
1163
       EEPROM_WRITE(ui.sleep_timeout_minutes);
1164
     #endif
1164
     #endif
2108
       //
2108
       //
2109
       // LCD Backlight / Sleep Timeout
2109
       // LCD Backlight / Sleep Timeout
2110
       //
2110
       //
2111
-      #if LCD_BACKLIGHT_TIMEOUT
2112
-        EEPROM_READ(ui.lcd_backlight_timeout);
2111
+      #if LCD_BACKLIGHT_TIMEOUT_MINS
2112
+        EEPROM_READ(ui.backlight_timeout_minutes);
2113
       #elif HAS_DISPLAY_SLEEP
2113
       #elif HAS_DISPLAY_SLEEP
2114
         EEPROM_READ(ui.sleep_timeout_minutes);
2114
         EEPROM_READ(ui.sleep_timeout_minutes);
2115
       #endif
2115
       #endif
3198
   //
3198
   //
3199
   // LCD Backlight / Sleep Timeout
3199
   // LCD Backlight / Sleep Timeout
3200
   //
3200
   //
3201
-  #if LCD_BACKLIGHT_TIMEOUT
3202
-    ui.lcd_backlight_timeout = LCD_BACKLIGHT_TIMEOUT;
3201
+  #if LCD_BACKLIGHT_TIMEOUT_MINS
3202
+    ui.backlight_timeout_minutes = LCD_BACKLIGHT_TIMEOUT_MINS;
3203
   #elif HAS_DISPLAY_SLEEP
3203
   #elif HAS_DISPLAY_SLEEP
3204
     ui.sleep_timeout_minutes = DISPLAY_SLEEP_MINUTES;
3204
     ui.sleep_timeout_minutes = DISPLAY_SLEEP_MINUTES;
3205
   #endif
3205
   #endif

+ 1
- 1
buildroot/tests/mega2560 View File

213
         TEMP_SENSOR_0 -2 TEMP_SENSOR_REDUNDANT -2 \
213
         TEMP_SENSOR_0 -2 TEMP_SENSOR_REDUNDANT -2 \
214
         TEMP_SENSOR_REDUNDANT_SOURCE E1 TEMP_SENSOR_REDUNDANT_TARGET E0 \
214
         TEMP_SENSOR_REDUNDANT_SOURCE E1 TEMP_SENSOR_REDUNDANT_TARGET E0 \
215
         TEMP_0_CS_PIN 11 TEMP_1_CS_PIN 12 \
215
         TEMP_0_CS_PIN 11 TEMP_1_CS_PIN 12 \
216
-        LCD_BACKLIGHT_TIMEOUT 30
216
+        LCD_BACKLIGHT_TIMEOUT_MINS 2
217
 opt_enable MPCTEMP MINIPANEL
217
 opt_enable MPCTEMP MINIPANEL
218
 opt_disable PIDTEMP
218
 opt_disable PIDTEMP
219
 exec_test $1 $2 "MEGA2560 RAMPS | Redundant temperature sensor | 2x MAX6675 | BL Timeout" "$3"
219
 exec_test $1 $2 "MEGA2560 RAMPS | Redundant temperature sensor | 2x MAX6675 | BL Timeout" "$3"

Loading…
Cancel
Save