✨ LCD Backlight Timer (#23768)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
@@ -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:
|
||||
|
Reference in New Issue
Block a user