Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Conditional HAS_LED_POWEROFF_TIMEOUT
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jul 6, 2024
1 parent e0dcc61 commit 4af5229
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/feature/leds/leds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void LEDLights::set_color(const LEDColor &incol
void LEDLights::toggle() { if (lights_on) set_off(); else update(); }
#endif

#if LED_POWEROFF_TIMEOUT > 0
#if HAS_LED_POWEROFF_TIMEOUT

millis_t LEDLights::led_off_time; // = 0

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/feature/leds/leds.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ class LEDLights {
#if ENABLED(LED_CONTROL_MENU)
static void toggle(); // swap "off" with color
#endif
#if ANY(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED) || LED_POWEROFF_TIMEOUT > 0
#if ANY(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED, HAS_LED_POWEROFF_TIMEOUT)
static void update() { set_color(color); }
#endif

#if LED_POWEROFF_TIMEOUT > 0
#if HAS_LED_POWEROFF_TIMEOUT
private:
static millis_t led_off_time;
public:
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,10 @@
#define NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_INDEX_FIRST
#endif

#if LED_POWEROFF_TIMEOUT > 0
#define HAS_LED_POWEROFF_TIMEOUT 1
#endif

#if ALL(SPI_FLASH, HAS_MEDIA, MARLIN_DEV_MODE)
#define SPI_FLASH_BACKUP 1
#endif
24 changes: 8 additions & 16 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "../MarlinCore.h" // for printingIsPaused
#include "../gcode/parser.h" // for axis_is_rotational, using_inch_units

#if LED_POWEROFF_TIMEOUT > 0 || ALL(HAS_WIRED_LCD, PRINTER_EVENT_LEDS) || (HAS_BACKLIGHT_TIMEOUT && defined(NEOPIXEL_BKGD_INDEX_FIRST))
#if HAS_LED_POWEROFF_TIMEOUT || ALL(HAS_WIRED_LCD, PRINTER_EVENT_LEDS) || (HAS_BACKLIGHT_TIMEOUT && defined(NEOPIXEL_BKGD_INDEX_FIRST))
#include "../feature/leds/leds.h"
#endif

Expand Down Expand Up @@ -319,7 +319,7 @@ void MarlinUI::init() {
#include "../feature/power_monitor.h"
#endif

#if LED_POWEROFF_TIMEOUT > 0
#if HAS_LED_POWEROFF_TIMEOUT
#include "../feature/power.h"
#endif

Expand Down Expand Up @@ -943,9 +943,7 @@ void MarlinUI::init() {
static uint16_t max_display_update_time = 0;
const millis_t ms = millis();

#if LED_POWEROFF_TIMEOUT > 0
leds.update_timeout(powerManager.psu_on);
#endif
TERN_(HAS_LED_POWEROFF_TIMEOUT, leds.update_timeout(powerManager.psu_on));

#if HAS_MARLINUI_MENU

Expand Down Expand Up @@ -1085,10 +1083,8 @@ void MarlinUI::init() {

refresh(LCDVIEW_REDRAW_NOW);

#if LED_POWEROFF_TIMEOUT > 0
if (!powerManager.psu_on) leds.reset_timeout(ms);
#endif
} // encoder activity
TERN_(HAS_LED_POWEROFF_TIMEOUT, if (!powerManager.psu_on) leds.reset_timeout(ms));
} // encoder or click

#endif // HAS_ENCODER_ACTION

Expand Down Expand Up @@ -1863,14 +1859,10 @@ void MarlinUI::host_notify(const char * const cstr) {

refresh();

#if HAS_WIRED_LCD || LED_POWEROFF_TIMEOUT > 0
#if HAS_WIRED_LCD || HAS_LED_POWEROFF_TIMEOUT
const millis_t ms = millis();
#endif

TERN_(HAS_WIRED_LCD, next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL); // Delay LCD update for SD activity

#if LED_POWEROFF_TIMEOUT > 0
leds.reset_timeout(ms);
TERN_(HAS_WIRED_LCD, next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL); // Delay LCD update for SD activity
TERN_(HAS_LED_POWEROFF_TIMEOUT, leds.reset_timeout(ms));
#endif
}

Expand Down

0 comments on commit 4af5229

Please sign in to comment.