DOGM Display Sleep (#23992)

Co-authored-by: borland1 <barryorlando@hotmail.com>
This commit is contained in:
Scott Lahteine
2022-04-04 15:57:03 -05:00
committed by Scott Lahteine
parent 4ae54a6229
commit dbd00d9927
13 changed files with 141 additions and 2 deletions

View File

@@ -342,6 +342,11 @@ void MarlinUI::draw_kill_screen() {
void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
#if HAS_DISPLAY_SLEEP
void MarlinUI::sleep_on() { u8g.sleepOn(); }
void MarlinUI::sleep_off() { u8g.sleepOff(); }
#endif
#if HAS_LCD_BRIGHTNESS
void MarlinUI::_set_brightness() {

View File

@@ -442,6 +442,7 @@ namespace Language_en {
LSTR MSG_CONTRAST = _UxGT("LCD Contrast");
LSTR MSG_BRIGHTNESS = _UxGT("LCD Brightness");
LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("LCD Timeout (s)");
LSTR MSG_SCREEN_TIMEOUT = _UxGT("LCD Timeout (m)");
LSTR MSG_BRIGHTNESS_OFF = _UxGT("Backlight Off");
LSTR MSG_STORE_EEPROM = _UxGT("Store Settings");
LSTR MSG_LOAD_EEPROM = _UxGT("Load Settings");

View File

@@ -191,6 +191,15 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
WRITE(LCD_BACKLIGHT_PIN, HIGH);
}
#elif HAS_DISPLAY_SLEEP
uint8_t MarlinUI::sleep_timeout_minutes; // Initialized by settings.load()
millis_t MarlinUI::screen_timeout_millis = 0;
void MarlinUI::refresh_screen_timeout() {
screen_timeout_millis = sleep_timeout_minutes ? millis() + sleep_timeout_minutes * 60UL * 1000UL : 0;
sleep_off();
}
#endif
void MarlinUI::init() {
@@ -1060,6 +1069,8 @@ void MarlinUI::init() {
#if LCD_BACKLIGHT_TIMEOUT
refresh_backlight_timeout();
#elif HAS_DISPLAY_SLEEP
refresh_screen_timeout();
#endif
refresh(LCDVIEW_REDRAW_NOW);
@@ -1171,6 +1182,9 @@ void MarlinUI::init() {
WRITE(LCD_BACKLIGHT_PIN, LOW); // Backlight off
backlight_off_ms = 0;
}
#elif HAS_DISPLAY_SLEEP
if (screen_timeout_millis && ELAPSED(ms, screen_timeout_millis))
sleep_on();
#endif
// Change state of drawing flag between screen updates

View File

@@ -279,6 +279,14 @@ public:
static uint16_t lcd_backlight_timeout;
static millis_t backlight_off_ms;
static void refresh_backlight_timeout();
#elif HAS_DISPLAY_SLEEP
#define SLEEP_TIMEOUT_MIN 0
#define SLEEP_TIMEOUT_MAX 99
static uint8_t sleep_timeout_minutes;
static millis_t screen_timeout_millis;
static void refresh_screen_timeout();
static void sleep_on();
static void sleep_off();
#endif
#if HAS_DWIN_E3V2_BASIC

View File

@@ -549,6 +549,8 @@ void menu_configuration() {
//
#if LCD_BACKLIGHT_TIMEOUT && LCD_BKL_TIMEOUT_MIN < LCD_BKL_TIMEOUT_MAX
EDIT_ITEM(uint16_4, MSG_LCD_TIMEOUT_SEC, &ui.lcd_backlight_timeout, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX, ui.refresh_backlight_timeout);
#elif HAS_DISPLAY_SLEEP
EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.sleep_timeout_minutes, SLEEP_TIMEOUT_MIN, SLEEP_TIMEOUT_MAX, ui.refresh_screen_timeout);
#endif
#if ENABLED(FWRETRACT)