✨ LCD Backlight Timer (#23768)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
parent
3db2fecaa4
commit
39001bd8d2
|
@ -2820,7 +2820,7 @@
|
|||
#define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens
|
||||
#define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus
|
||||
|
||||
//#define TOUCH_IDLE_SLEEP 300 // (secs) Turn off the TFT backlight if set (5mn)
|
||||
//#define TOUCH_IDLE_SLEEP 300 // (s) Turn off the TFT backlight if set (5mn)
|
||||
|
||||
#define TOUCH_SCREEN_CALIBRATION
|
||||
|
||||
|
|
|
@ -1277,6 +1277,11 @@
|
|||
#define FEEDRATE_CHANGE_BEEP_FREQUENCY 440
|
||||
#endif
|
||||
|
||||
//
|
||||
// LCD Backlight Timeout
|
||||
//
|
||||
//#define LCD_BACKLIGHT_TIMEOUT 30 // (s) Timeout before turning off the backlight
|
||||
|
||||
#if HAS_BED_PROBE && EITHER(HAS_MARLINUI_MENU, HAS_TFT_LVGL_UI)
|
||||
//#define PROBE_OFFSET_WIZARD // Add a Probe Z Offset calibration option to the LCD menu
|
||||
#if ENABLED(PROBE_OFFSET_WIZARD)
|
||||
|
|
|
@ -2857,6 +2857,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if LCD_BACKLIGHT_TIMEOUT
|
||||
#if !HAS_ENCODER_ACTION
|
||||
#error "LCD_BACKLIGHT_TIMEOUT requires an LCD with encoder or keypad."
|
||||
#elif !PIN_EXISTS(LCD_BACKLIGHT)
|
||||
#error "LCD_BACKLIGHT_TIMEOUT requires LCD_BACKLIGHT_PIN."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Some boards forbid the use of -1 Native USB
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -391,6 +391,13 @@ typedef struct SettingsDataStruct {
|
|||
//
|
||||
uint8_t lcd_brightness; // M256 B
|
||||
|
||||
//
|
||||
// LCD_BACKLIGHT_TIMEOUT
|
||||
//
|
||||
#if LCD_BACKLIGHT_TIMEOUT
|
||||
uint16_t lcd_backlight_timeout; // (G-code needed)
|
||||
#endif
|
||||
|
||||
//
|
||||
// Controller fan settings
|
||||
//
|
||||
|
@ -607,6 +614,10 @@ void MarlinSettings::postprocess() {
|
|||
// Moved as last update due to interference with Neopixel init
|
||||
TERN_(HAS_LCD_CONTRAST, ui.refresh_contrast());
|
||||
TERN_(HAS_LCD_BRIGHTNESS, ui.refresh_brightness());
|
||||
|
||||
#if LCD_BACKLIGHT_TIMEOUT
|
||||
ui.refresh_backlight_timeout();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if BOTH(PRINTCOUNTER, EEPROM_SETTINGS)
|
||||
|
@ -1108,6 +1119,13 @@ void MarlinSettings::postprocess() {
|
|||
EEPROM_WRITE(lcd_brightness);
|
||||
}
|
||||
|
||||
//
|
||||
// LCD Backlight Timeout
|
||||
//
|
||||
#if LCD_BACKLIGHT_TIMEOUT
|
||||
EEPROM_WRITE(ui.lcd_backlight_timeout);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Controller Fan
|
||||
//
|
||||
|
@ -2015,6 +2033,13 @@ void MarlinSettings::postprocess() {
|
|||
TERN_(HAS_LCD_BRIGHTNESS, if (!validating) ui.brightness = lcd_brightness);
|
||||
}
|
||||
|
||||
//
|
||||
// LCD Backlight Timeout
|
||||
//
|
||||
#if LCD_BACKLIGHT_TIMEOUT
|
||||
EEPROM_READ(ui.lcd_backlight_timeout);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Controller Fan
|
||||
//
|
||||
|
@ -3040,6 +3065,13 @@ void MarlinSettings::reset() {
|
|||
//
|
||||
TERN_(HAS_LCD_BRIGHTNESS, ui.brightness = LCD_BRIGHTNESS_DEFAULT);
|
||||
|
||||
//
|
||||
// LCD Backlight Timeout
|
||||
//
|
||||
#if LCD_BACKLIGHT_TIMEOUT
|
||||
ui.lcd_backlight_timeout = LCD_BACKLIGHT_TIMEOUT;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Controller Fan
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue