✨ LCD Backlight Timer (#23768)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
committed by
Scott Lahteine
parent
3db2fecaa4
commit
39001bd8d2
@ -402,6 +402,7 @@ namespace Language_en {
|
||||
LSTR MSG_ADVANCE_K_E = _UxGT("Advance K *");
|
||||
LSTR MSG_CONTRAST = _UxGT("LCD Contrast");
|
||||
LSTR MSG_BRIGHTNESS = _UxGT("LCD Brightness");
|
||||
LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("LCD Sleep (s)");
|
||||
LSTR MSG_STORE_EEPROM = _UxGT("Store Settings");
|
||||
LSTR MSG_LOAD_EEPROM = _UxGT("Load Settings");
|
||||
LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restore Defaults");
|
||||
|
@ -335,6 +335,7 @@ namespace Language_fr {
|
||||
LSTR MSG_ADVANCE_K_E = _UxGT("Avance K *");
|
||||
LSTR MSG_BRIGHTNESS = _UxGT("Luminosité LCD");
|
||||
LSTR MSG_CONTRAST = _UxGT("Contraste LCD");
|
||||
LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("Veille LCD (s)");
|
||||
LSTR MSG_STORE_EEPROM = _UxGT("Enregistrer config.");
|
||||
LSTR MSG_LOAD_EEPROM = _UxGT("Charger config.");
|
||||
LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restaurer défauts");
|
||||
|
@ -180,6 +180,15 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
|
||||
volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update
|
||||
#endif
|
||||
|
||||
#if LCD_BACKLIGHT_TIMEOUT
|
||||
uint16_t MarlinUI::lcd_backlight_timeout; // Initialized by settings.load()
|
||||
millis_t MarlinUI::backlight_off_ms = 0;
|
||||
void MarlinUI::refresh_backlight_timeout() {
|
||||
backlight_off_ms = lcd_backlight_timeout ? millis() + lcd_backlight_timeout * 1000UL : 0;
|
||||
WRITE(LCD_BACKLIGHT_PIN, HIGH);
|
||||
}
|
||||
#endif
|
||||
|
||||
void MarlinUI::init() {
|
||||
|
||||
init_lcd();
|
||||
@ -1033,14 +1042,18 @@ void MarlinUI::init() {
|
||||
|
||||
reset_status_timeout(ms);
|
||||
|
||||
#if LCD_BACKLIGHT_TIMEOUT
|
||||
refresh_backlight_timeout();
|
||||
#endif
|
||||
|
||||
refresh(LCDVIEW_REDRAW_NOW);
|
||||
|
||||
#if LED_POWEROFF_TIMEOUT > 0
|
||||
if (!powerManager.psu_on) leds.reset_timeout(ms);
|
||||
#endif
|
||||
}
|
||||
} // encoder activity
|
||||
|
||||
#endif
|
||||
#endif // HAS_ENCODER_ACTION
|
||||
|
||||
// This runs every ~100ms when idling often enough.
|
||||
// Instead of tracking changes just redraw the Status Screen once per second.
|
||||
@ -1137,6 +1150,13 @@ void MarlinUI::init() {
|
||||
return_to_status();
|
||||
#endif
|
||||
|
||||
#if LCD_BACKLIGHT_TIMEOUT
|
||||
if (backlight_off_ms && ELAPSED(ms, backlight_off_ms)) {
|
||||
WRITE(LCD_BACKLIGHT_PIN, LOW); // Backlight off
|
||||
backlight_off_ms = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Change state of drawing flag between screen updates
|
||||
if (!drawing_screen) switch (lcdDrawUpdate) {
|
||||
case LCDVIEW_CLEAR_CALL_REDRAW:
|
||||
|
@ -275,6 +275,14 @@ public:
|
||||
FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); }
|
||||
#endif
|
||||
|
||||
#if LCD_BACKLIGHT_TIMEOUT
|
||||
#define LCD_BKL_TIMEOUT_MIN 1
|
||||
#define LCD_BKL_TIMEOUT_MAX (60*60*18) // 18 hours max within uint16_t
|
||||
static uint16_t lcd_backlight_timeout;
|
||||
static millis_t backlight_off_ms;
|
||||
static void refresh_backlight_timeout();
|
||||
#endif
|
||||
|
||||
#if HAS_DWIN_E3V2_BASIC
|
||||
static void refresh();
|
||||
#else
|
||||
|
@ -541,6 +541,10 @@ void menu_configuration() {
|
||||
#if HAS_LCD_CONTRAST && LCD_CONTRAST_MIN < LCD_CONTRAST_MAX
|
||||
EDIT_ITEM_FAST(uint8, MSG_CONTRAST, &ui.contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, ui.refresh_contrast, true);
|
||||
#endif
|
||||
#if LCD_BACKLIGHT_TIMEOUT && LCD_BKL_TIMEOUT_MIN < LCD_BKL_TIMEOUT_MAX
|
||||
EDIT_ITEM(uint16_4, MSG_LCD_BKL_TIMEOUT, &ui.lcd_backlight_timeout, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX, ui.refresh_backlight_timeout);
|
||||
#endif
|
||||
|
||||
#if ENABLED(FWRETRACT)
|
||||
SUBMENU(MSG_RETRACT, menu_config_retract);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user