From 06710e54de8c83af77a4f57d458f6463fbfcad93 Mon Sep 17 00:00:00 2001 From: Andrew <18502096+classicrocker883@users.noreply.github.com> Date: Wed, 13 Dec 2023 00:33:03 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20EDITABLE=5FDISPLAY=5FTIMEOUT=20(#26?= =?UTF-8?q?517)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 14 +++--- Marlin/src/core/types.h | 4 +- Marlin/src/feature/bedlevel/bdl/bdl.cpp | 2 +- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 3 +- Marlin/src/gcode/calibrate/G76_M871.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/gcode/lcd/M255.cpp | 4 +- Marlin/src/inc/Conditionals_adv.h | 6 +-- Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/lcd/e3v2/common/encoder.cpp | 8 +--- Marlin/src/lcd/e3v2/proui/dwin.cpp | 8 ++-- Marlin/src/lcd/e3v2/proui/plot.cpp | 4 +- Marlin/src/lcd/marlinui.cpp | 27 ++++++----- Marlin/src/lcd/marlinui.h | 16 +++++-- Marlin/src/lcd/menu/menu_configuration.cpp | 10 +++-- Marlin/src/lcd/tft/touch.cpp | 2 +- Marlin/src/lcd/touch/touch_buttons.cpp | 2 +- Marlin/src/module/settings.cpp | 50 +++++++++++---------- Marlin/src/module/temperature.h | 14 +++--- ini/features.ini | 2 +- 21 files changed, 102 insertions(+), 82 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index e4f85a8d87..8b4fa1ab7c 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1471,11 +1471,6 @@ #define FEEDRATE_CHANGE_BEEP_FREQUENCY 440 #endif -// -// LCD Backlight Timeout -// -//#define LCD_BACKLIGHT_TIMEOUT_MINS 1 // (minutes) Timeout before turning off the backlight - #if HAS_BED_PROBE && ANY(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) @@ -2206,6 +2201,15 @@ //#define TFT_BTOKMENU_COLOR 0x145F // 00010 100010 11111 Cyan #endif +// +// LCD Backlight Timeout +// Requires a display with a controllable backlight +// +//#define LCD_BACKLIGHT_TIMEOUT_MINS 1 // (minutes) Timeout before turning off the backlight +#if defined(DISPLAY_SLEEP_MINUTES) || defined(LCD_BACKLIGHT_TIMEOUT_MINS) + #define EDITABLE_DISPLAY_TIMEOUT // Edit timeout with M255 S and a menu item +#endif + // // ADC Button Debounce // diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index d92dbde8b7..bcbf2f07aa 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -198,7 +198,7 @@ typedef Flags<8> flags_8_t; typedef Flags<16> flags_16_t; // Flags for some axis states, with per-axis aliases xyzijkuvwe -typedef struct AxisFlags { +typedef struct { union { struct Flags flags; struct { bool LOGICAL_AXIS_LIST(e:1, x:1, y:1, z:1, i:1, j:1, k:1, u:1, v:1, w:1); }; @@ -212,7 +212,7 @@ typedef struct AxisFlags { FI bool operator[](const int n) const { return flags[n]; } FI int size() const { return sizeof(flags); } FI operator bool() const { return flags; } -} axis_flags_t; +} AxisFlags; // // Enumerated axis indices diff --git a/Marlin/src/feature/bedlevel/bdl/bdl.cpp b/Marlin/src/feature/bedlevel/bdl/bdl.cpp index 5345bb78c5..d469bb0c06 100644 --- a/Marlin/src/feature/bedlevel/bdl/bdl.cpp +++ b/Marlin/src/feature/bedlevel/bdl/bdl.cpp @@ -195,7 +195,7 @@ void BDS_Leveling::process() { safe_delay(10); if (config_state == BDS_CALIBRATE_START) { config_state = BDS_CALIBRATING; - REMEMBER(gsit, gcode.stepper_inactive_time, SEC_TO_MS(60 * 5)); + REMEMBER(gsit, gcode.stepper_inactive_time, MIN_TO_MS(5)); SERIAL_ECHOLNPGM("c_z0:", planner.get_axis_position_mm(Z_AXIS), "-", pos_zero_offset); // Move the z axis instead of enabling the Z axis with M17 diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index d136f0000d..3d0013b6d2 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -772,7 +772,8 @@ void unified_bed_leveling::shift_mesh_height() { const grid_count_t point_num = (GRID_MAX_POINTS - count) + 1; SERIAL_ECHOLNPGM("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, "."); TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), point_num, int(GRID_MAX_POINTS))); - TERN_(LCD_BACKLIGHT_TIMEOUT_MINS, ui.refresh_backlight_timeout()); + TERN_(HAS_BACKLIGHT_TIMEOUT, ui.refresh_backlight_timeout()); + TERN_(DWIN_LCD_PROUI, dwinRedrawScreen()); #if HAS_MARLINUI_MENU if (ui.button_pressed()) { diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index 6fe3dd89cf..bb69b75d50 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -256,7 +256,7 @@ say_waiting_for_probe_heating(); SERIAL_ECHOLNPGM(" Bed:", target_bed, " Probe:", target_probe); - const millis_t probe_timeout_ms = millis() + SEC_TO_MS(900UL); + const millis_t probe_timeout_ms = millis() + MIN_TO_MS(15); while (thermalManager.degProbe() < target_probe) { if (report_temps(next_temp_report, probe_timeout_ms)) { SERIAL_ECHOLNPGM("!Probe heating timed out."); diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index d519bd4e29..6a0e8cb171 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -793,7 +793,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 250: M250(); break; // M250: Set LCD contrast #endif - #if HAS_GCODE_M255 + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) case 255: M255(); break; // M255: Set LCD Sleep/Backlight Timeout (Minutes) #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 61ff0b047c..fffd0d714b 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -909,7 +909,7 @@ private: static void M250_report(const bool forReplay=true); #endif - #if HAS_GCODE_M255 + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) static void M255(); static void M255_report(const bool forReplay=true); #endif diff --git a/Marlin/src/gcode/lcd/M255.cpp b/Marlin/src/gcode/lcd/M255.cpp index 8dc8099de1..2b982ee5d9 100644 --- a/Marlin/src/gcode/lcd/M255.cpp +++ b/Marlin/src/gcode/lcd/M255.cpp @@ -21,7 +21,7 @@ */ #include "../../inc/MarlinConfig.h" -#if HAS_GCODE_M255 +#if ENABLED(EDITABLE_DISPLAY_TIMEOUT) #include "../gcode.h" #include "../../lcd/marlinui.h" @@ -51,4 +51,4 @@ void GcodeSuite::M255_report(const bool forReplay/*=true*/) { ); } -#endif // HAS_GCODE_M255 +#endif // EDITABLE_DISPLAY_TIMEOUT diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index ba074e2560..755b251b18 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -893,11 +893,11 @@ #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, HAS_MEDIA) #define HAS_LEDS_OFF_FLAG 1 #endif -#if DISPLAY_SLEEP_MINUTES || TOUCH_IDLE_SLEEP_MINS +#if defined(DISPLAY_SLEEP_MINUTES) || defined(TOUCH_IDLE_SLEEP_MINS) #define HAS_DISPLAY_SLEEP 1 #endif -#if HAS_DISPLAY_SLEEP || LCD_BACKLIGHT_TIMEOUT_MINS - #define HAS_GCODE_M255 1 +#ifdef LCD_BACKLIGHT_TIMEOUT_MINS + #define HAS_BACKLIGHT_TIMEOUT 1 #endif #if ANY(DIGIPOT_MCP4018, DIGIPOT_MCP4451) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 70eba0d60c..2e1149e668 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2762,7 +2762,7 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #endif #endif -#if LCD_BACKLIGHT_TIMEOUT_MINS +#if HAS_BACKLIGHT_TIMEOUT #if !HAS_ENCODER_ACTION && DISABLED(HAS_DWIN_E3V2) #error "LCD_BACKLIGHT_TIMEOUT_MINS requires an LCD with encoder or keypad." #elif ENABLED(NEOPIXEL_BKGD_INDEX_FIRST) diff --git a/Marlin/src/lcd/e3v2/common/encoder.cpp b/Marlin/src/lcd/e3v2/common/encoder.cpp index eb064950ec..cb14596849 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.cpp +++ b/Marlin/src/lcd/e3v2/common/encoder.cpp @@ -87,9 +87,7 @@ EncoderState encoderReceiveAnalyze() { #if PIN_EXISTS(LCD_LED) //LED_Action(); #endif - #if LCD_BACKLIGHT_TIMEOUT_MINS - ui.refresh_backlight_timeout(); - #endif + TERN_(HAS_BACKLIGHT_TIMEOUT, ui.refresh_backlight_timeout()); if (!ui.backlight) { ui.refresh_brightness(); return ENCODER_DIFF_NO; @@ -161,9 +159,7 @@ EncoderState encoderReceiveAnalyze() { temp_diff = 0; } if (temp_diffState != ENCODER_DIFF_NO) { - #if LCD_BACKLIGHT_TIMEOUT_MINS - ui.refresh_backlight_timeout(); - #endif + TERN_(HAS_BACKLIGHT_TIMEOUT, ui.refresh_backlight_timeout()); if (!ui.backlight) ui.refresh_brightness(); } return temp_diffState; diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 8d4aa9106b..7c68c60f81 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -1249,7 +1249,7 @@ void eachMomentUpdate() { static millis_t next_var_update_ms = 0, next_rts_update_ms = 0, next_status_update_ms = 0; const millis_t ms = millis(); - #if LCD_BACKLIGHT_TIMEOUT_MINS + #if HAS_BACKLIGHT_TIMEOUT if (ui.backlight_off_ms && ELAPSED(ms, ui.backlight_off_ms)) { turnOffBacklight(); // Backlight off ui.backlight_off_ms = 0; @@ -2235,7 +2235,7 @@ void setMoveZ() { hmiValue.axis = Z_AXIS; setPFloatOnClick(Z_MIN_POS, Z_MAX_POS, #endif -#if LCD_BACKLIGHT_TIMEOUT_MINS +#if ENABLED(EDITABLE_DISPLAY_TIMEOUT) void applyTimer() { ui.backlight_timeout_minutes = menuData.value; } void setTimer() { setIntOnClick(ui.backlight_timeout_min, ui.backlight_timeout_max, ui.backlight_timeout_minutes, applyTimer); } #endif @@ -3123,7 +3123,7 @@ void drawAdvancedSettingsMenu() { #if HAS_LOCKSCREEN MENU_ITEM(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, dwinLockScreen); #endif - #if LCD_BACKLIGHT_TIMEOUT_MINS + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) EDIT_ITEM(ICON_Brightness, MSG_SCREEN_TIMEOUT, onDrawPIntMenu, setTimer, &ui.backlight_timeout_minutes); #endif #if ENABLED(SOUND_MENU_ITEM) @@ -3347,7 +3347,7 @@ void drawTuneMenu() { EDIT_ITEM(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, setBrightness, &ui.brightness); MENU_ITEM(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, turnOffBacklight); #endif - #if LCD_BACKLIGHT_TIMEOUT_MINS + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) EDIT_ITEM(ICON_Brightness, MSG_SCREEN_TIMEOUT, onDrawPIntMenu, setTimer, &ui.backlight_timeout_minutes); #endif #if ENABLED(CASE_LIGHT_MENU) diff --git a/Marlin/src/lcd/e3v2/proui/plot.cpp b/Marlin/src/lcd/e3v2/proui/plot.cpp index 92c6c94717..84c58389a6 100644 --- a/Marlin/src/lcd/e3v2/proui/plot.cpp +++ b/Marlin/src/lcd/e3v2/proui/plot.cpp @@ -73,9 +73,7 @@ void Plot::update(const_float_t value) { dwinDrawPoint(COLOR_YELLOW, 1, 1, x2 - 1, y); } graphpoints++; - #if LCD_BACKLIGHT_TIMEOUT_MINS - ui.refresh_backlight_timeout(); - #endif + TERN_(HAS_BACKLIGHT_TIMEOUT, ui.refresh_backlight_timeout()); } #endif // PROUI_TUNING_GRAPH diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 4eb58f52ae..60fb298dfc 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -24,7 +24,7 @@ #include "../MarlinCore.h" // for printingIsPaused -#if LED_POWEROFF_TIMEOUT > 0 || ALL(HAS_WIRED_LCD, PRINTER_EVENT_LEDS) || (defined(LCD_BACKLIGHT_TIMEOUT_MINS) && defined(NEOPIXEL_BKGD_INDEX_FIRST)) +#if LED_POWEROFF_TIMEOUT > 0 || ALL(HAS_WIRED_LCD, PRINTER_EVENT_LEDS) || (HAS_BACKLIGHT_TIMEOUT && defined(NEOPIXEL_BKGD_INDEX_FIRST)) #include "../feature/leds/leds.h" #endif @@ -185,10 +185,14 @@ 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_MINS +#if HAS_BACKLIGHT_TIMEOUT + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) + uint8_t MarlinUI::backlight_timeout_minutes; // Initialized by settings.load() + #else + constexpr uint8_t MarlinUI::backlight_timeout_minutes; + #endif constexpr uint8_t MarlinUI::backlight_timeout_min, MarlinUI::backlight_timeout_max; - uint8_t MarlinUI::backlight_timeout_minutes; // Initialized by settings.load() millis_t MarlinUI::backlight_off_ms = 0; void MarlinUI::refresh_backlight_timeout() { @@ -203,12 +207,16 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #elif HAS_DISPLAY_SLEEP + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) + uint8_t MarlinUI::sleep_timeout_minutes; // Initialized by settings.load() + #else + constexpr uint8_t MarlinUI::sleep_timeout_minutes; + #endif constexpr uint8_t MarlinUI::sleep_timeout_min, MarlinUI::sleep_timeout_max; - uint8_t MarlinUI::sleep_timeout_minutes; // Initialized by settings.load() - millis_t MarlinUI::screen_timeout_millis = 0; + millis_t MarlinUI::screen_timeout_ms = 0; void MarlinUI::refresh_screen_timeout() { - screen_timeout_millis = sleep_timeout_minutes ? millis() + sleep_timeout_minutes * 60UL * 1000UL : 0; + screen_timeout_ms = sleep_timeout_minutes ? millis() + sleep_timeout_minutes * 60UL * 1000UL : 0; sleep_display(false); } @@ -1092,7 +1100,7 @@ void MarlinUI::init() { if (encoderPastThreshold || lcd_clicked) { reset_status_timeout(ms); - #if LCD_BACKLIGHT_TIMEOUT_MINS + #if HAS_BACKLIGHT_TIMEOUT refresh_backlight_timeout(); #elif HAS_DISPLAY_SLEEP refresh_screen_timeout(); @@ -1202,8 +1210,7 @@ void MarlinUI::init() { return_to_status(); #endif - #if LCD_BACKLIGHT_TIMEOUT_MINS - + #if HAS_BACKLIGHT_TIMEOUT if (backlight_off_ms && ELAPSED(ms, backlight_off_ms)) { #ifdef NEOPIXEL_BKGD_INDEX_FIRST neo.set_background_off(); @@ -1214,7 +1221,7 @@ void MarlinUI::init() { backlight_off_ms = 0; } #elif HAS_DISPLAY_SLEEP - if (screen_timeout_millis && ELAPSED(ms, screen_timeout_millis)) + if (screen_timeout_ms && ELAPSED(ms, screen_timeout_ms)) sleep_display(); #endif diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 595b89b6e0..a463701f56 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -272,17 +272,25 @@ public: FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); } #endif - #if LCD_BACKLIGHT_TIMEOUT_MINS + #if HAS_BACKLIGHT_TIMEOUT + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) + static uint8_t backlight_timeout_minutes; + #else + static constexpr uint8_t backlight_timeout_minutes = LCD_BACKLIGHT_TIMEOUT_MINS; + #endif static constexpr uint8_t backlight_timeout_min = 0; static constexpr uint8_t backlight_timeout_max = 99; - static uint8_t backlight_timeout_minutes; static millis_t backlight_off_ms; static void refresh_backlight_timeout(); #elif HAS_DISPLAY_SLEEP + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) + static uint8_t sleep_timeout_minutes; + #else + static constexpr uint8_t sleep_timeout_minutes = DISPLAY_SLEEP_MINUTES; + #endif static constexpr uint8_t sleep_timeout_min = 0; static constexpr uint8_t sleep_timeout_max = 99; - static uint8_t sleep_timeout_minutes; - static millis_t screen_timeout_millis; + static millis_t screen_timeout_ms; static void refresh_screen_timeout(); static void sleep_display(const bool sleep=true); #endif diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 52123d101b..7347f219e0 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -618,10 +618,12 @@ void menu_configuration() { // // Set display backlight / sleep timeout // - #if LCD_BACKLIGHT_TIMEOUT_MINS - EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.backlight_timeout_minutes, ui.backlight_timeout_min, ui.backlight_timeout_max, ui.refresh_backlight_timeout); - #elif HAS_DISPLAY_SLEEP - EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.sleep_timeout_minutes, ui.sleep_timeout_min, ui.sleep_timeout_max, ui.refresh_screen_timeout); + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) + #if HAS_BACKLIGHT_TIMEOUT + EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.backlight_timeout_minutes, ui.backlight_timeout_min, ui.backlight_timeout_max, ui.refresh_backlight_timeout); + #elif HAS_DISPLAY_SLEEP + EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.sleep_timeout_minutes, ui.sleep_timeout_min, ui.sleep_timeout_max, ui.refresh_screen_timeout); + #endif #endif #if ENABLED(FWRETRACT) diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index 3c0b21ba8f..d325355002 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -308,7 +308,7 @@ bool Touch::get_point(int16_t * const x, int16_t * const y) { next_touch_ms = millis() + 100; safe_delay(20); } - next_sleep_ms = millis() + SEC_TO_MS(ui.sleep_timeout_minutes * 60); + next_sleep_ms = millis() + MIN_TO_MS(ui.sleep_timeout_minutes); } #endif // HAS_TOUCH_SLEEP diff --git a/Marlin/src/lcd/touch/touch_buttons.cpp b/Marlin/src/lcd/touch/touch_buttons.cpp index 7d31b21c04..652a043714 100644 --- a/Marlin/src/lcd/touch/touch_buttons.cpp +++ b/Marlin/src/lcd/touch/touch_buttons.cpp @@ -147,7 +147,7 @@ uint8_t TouchButtons::read_buttons() { WRITE(TFT_BACKLIGHT_PIN, HIGH); #endif } - next_sleep_ms = millis() + SEC_TO_MS(ui.sleep_timeout_minutes * 60); + next_sleep_ms = millis() + MIN_TO_MS(ui.sleep_timeout_minutes); } #endif // HAS_TOUCH_SLEEP diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index f636b985e1..b99ae8ddcd 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -431,10 +431,12 @@ typedef struct SettingsDataStruct { // // Display Sleep // - #if LCD_BACKLIGHT_TIMEOUT_MINS - uint8_t backlight_timeout_minutes; // M255 S - #elif HAS_DISPLAY_SLEEP - uint8_t sleep_timeout_minutes; // M255 S + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) + #if HAS_BACKLIGHT_TIMEOUT + uint8_t backlight_timeout_minutes; // M255 S + #elif HAS_DISPLAY_SLEEP + uint8_t sleep_timeout_minutes; // M255 S + #endif #endif // @@ -704,12 +706,8 @@ 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_MINS - ui.refresh_backlight_timeout(); - #elif HAS_DISPLAY_SLEEP - ui.refresh_screen_timeout(); - #endif + TERN_(HAS_BACKLIGHT_TIMEOUT, ui.refresh_backlight_timeout()); + TERN_(HAS_DISPLAY_SLEEP, ui.refresh_screen_timeout()); } #if ALL(PRINTCOUNTER, EEPROM_SETTINGS) @@ -1249,10 +1247,12 @@ void MarlinSettings::postprocess() { // // LCD Backlight / Sleep Timeout // - #if LCD_BACKLIGHT_TIMEOUT_MINS - EEPROM_WRITE(ui.backlight_timeout_minutes); - #elif HAS_DISPLAY_SLEEP - EEPROM_WRITE(ui.sleep_timeout_minutes); + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) + #if HAS_BACKLIGHT_TIMEOUT + EEPROM_WRITE(ui.backlight_timeout_minutes); + #elif HAS_DISPLAY_SLEEP + EEPROM_WRITE(ui.sleep_timeout_minutes); + #endif #endif // @@ -2294,10 +2294,12 @@ void MarlinSettings::postprocess() { // // LCD Backlight / Sleep Timeout // - #if LCD_BACKLIGHT_TIMEOUT_MINS - EEPROM_READ(ui.backlight_timeout_minutes); - #elif HAS_DISPLAY_SLEEP - EEPROM_READ(ui.sleep_timeout_minutes); + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) + #if HAS_BACKLIGHT_TIMEOUT + EEPROM_READ(ui.backlight_timeout_minutes); + #elif HAS_DISPLAY_SLEEP + EEPROM_READ(ui.sleep_timeout_minutes); + #endif #endif // @@ -3451,10 +3453,12 @@ void MarlinSettings::reset() { // // LCD Backlight / Sleep Timeout // - #if LCD_BACKLIGHT_TIMEOUT_MINS - ui.backlight_timeout_minutes = LCD_BACKLIGHT_TIMEOUT_MINS; - #elif HAS_DISPLAY_SLEEP - ui.sleep_timeout_minutes = TERN(TOUCH_SCREEN, TOUCH_IDLE_SLEEP_MINS, DISPLAY_SLEEP_MINUTES); + #if ENABLED(EDITABLE_DISPLAY_TIMEOUT) + #if HAS_BACKLIGHT_TIMEOUT + ui.backlight_timeout_minutes = LCD_BACKLIGHT_TIMEOUT_MINS; + #elif HAS_DISPLAY_SLEEP + ui.sleep_timeout_minutes = TERN(TOUCH_SCREEN, TOUCH_IDLE_SLEEP_MINS, DISPLAY_SLEEP_MINUTES); + #endif #endif // @@ -3827,7 +3831,7 @@ void MarlinSettings::reset() { // // Display Sleep // - TERN_(HAS_GCODE_M255, gcode.M255_report(forReplay)); + TERN_(EDITABLE_DISPLAY_TIMEOUT, gcode.M255_report(forReplay)); // // LCD Brightness diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index d174bfd11d..2acc1205b7 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -699,7 +699,7 @@ class Temperature { // Convert the given heater_id_t to idle array index static IdleIndex idle_index_for_id(const int8_t heater_id) { - TERN_(HAS_HEATED_BED, if (heater_id == H_BED) return IDLE_INDEX_BED); + OPTCODE(HAS_HEATED_BED, if (heater_id == H_BED) return IDLE_INDEX_BED) return (IdleIndex)_MAX(heater_id, 0); } @@ -1052,7 +1052,7 @@ class Temperature { } // Start watching the Bed to make sure it's really heating up - static void start_watching_bed() { TERN_(WATCH_BED, watch_bed.restart(degBed(), degTargetBed())); } + static void start_watching_bed() { OPTCODE(WATCH_BED, watch_bed.restart(degBed(), degTargetBed())) } static void setTargetBed(const celsius_t celsius) { #if PREHEAT_TIME_BED_MS > 0 @@ -1108,7 +1108,7 @@ class Temperature { start_watching_chamber(); } // Start watching the Chamber to make sure it's really heating up - static void start_watching_chamber() { TERN_(WATCH_CHAMBER, watch_chamber.restart(degChamber(), degTargetChamber())); } + static void start_watching_chamber() { OPTCODE(WATCH_CHAMBER, watch_chamber.restart(degChamber(), degTargetChamber())) } #endif #if HAS_TEMP_COOLER @@ -1158,7 +1158,7 @@ class Temperature { start_watching_cooler(); } // Start watching the Cooler to make sure it's really cooling down - static void start_watching_cooler() { TERN_(WATCH_COOLER, watch_cooler.restart(degCooler(), degTargetCooler())); } + static void start_watching_cooler() { OPTCODE(WATCH_COOLER, watch_cooler.restart(degCooler(), degTargetCooler())) } #endif /** @@ -1391,9 +1391,9 @@ class Temperature { // Convert the given heater_id_t to runaway state array index static RunawayIndex runaway_index_for_id(const int8_t heater_id) { - TERN_(THERMAL_PROTECTION_CHAMBER, if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER); - TERN_(THERMAL_PROTECTION_COOLER, if (heater_id == H_COOLER) return RUNAWAY_IND_COOLER); - TERN_(THERMAL_PROTECTION_BED, if (heater_id == H_BED) return RUNAWAY_IND_BED); + OPTCODE(THERMAL_PROTECTION_CHAMBER, if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER) + OPTCODE(THERMAL_PROTECTION_COOLER, if (heater_id == H_COOLER) return RUNAWAY_IND_COOLER) + OPTCODE(THERMAL_PROTECTION_BED, if (heater_id == H_BED) return RUNAWAY_IND_BED) return (RunawayIndex)_MAX(heater_id, 0); } diff --git a/ini/features.ini b/ini/features.ini index 3e50b19bc0..ed755f9ac0 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -330,7 +330,7 @@ SET_PROGRESS_MANUALLY = build_src_filter=+ HAS_PREHEAT = build_src_filter=+ HAS_LCD_CONTRAST = build_src_filter=+ -HAS_GCODE_M255 = build_src_filter=+ +EDITABLE_DISPLAY_TIMEOUT = build_src_filter=+ HAS_LCD_BRIGHTNESS = build_src_filter=+ HAS_SOUND = build_src_filter=+ HAS_MULTI_LANGUAGE = build_src_filter=+