Fix mini12864 v2.1 + PSU control + NeoPixel backlight (#21021)

This commit is contained in:
ellensp 2021-02-08 15:36:04 +13:00 committed by Scott Lahteine
parent 1bf469411a
commit 1aae6395c6
4 changed files with 20 additions and 9 deletions

View File

@ -147,11 +147,13 @@ void LEDLights::set_color(const LEDColor &incol
millis_t LEDLights::led_off_time; // = 0 millis_t LEDLights::led_off_time; // = 0
void LEDLights::update_timeout(const bool power_on) { void LEDLights::update_timeout(const bool power_on) {
const millis_t ms = millis(); if (lights_on) {
if (power_on) const millis_t ms = millis();
reset_timeout(ms); if (power_on)
else if (ELAPSED(ms, led_off_time)) reset_timeout(ms);
set_off(); else if (ELAPSED(ms, led_off_time))
set_off();
}
} }
#endif #endif

View File

@ -203,7 +203,7 @@ public:
public: public:
static inline void reset_timeout(const millis_t &ms) { static inline void reset_timeout(const millis_t &ms) {
led_off_time = ms + LED_BACKLIGHT_TIMEOUT; led_off_time = ms + LED_BACKLIGHT_TIMEOUT;
if (!lights_on) set_default(); if (!lights_on) update();
} }
static void update_timeout(const bool power_on); static void update_timeout(const bool power_on);
#endif #endif

View File

@ -994,7 +994,7 @@ void MarlinUI::update() {
refresh(LCDVIEW_REDRAW_NOW); refresh(LCDVIEW_REDRAW_NOW);
#ifdef LED_BACKLIGHT_TIMEOUT #ifdef LED_BACKLIGHT_TIMEOUT
leds.reset_timeout(ms); if (!powersupply_on) leds.reset_timeout(ms);
#endif #endif
} }

View File

@ -121,11 +121,20 @@ void menu_led() {
BACK_ITEM(MSG_MAIN); BACK_ITEM(MSG_MAIN);
#if ENABLED(LED_CONTROL_MENU) #if ENABLED(LED_CONTROL_MENU)
editable.state = leds.lights_on; #if ENABLED(PSU_CONTROL)
EDIT_ITEM(bool, MSG_LEDS, &editable.state, leds.toggle); extern bool powersupply_on;
#else
constexpr bool powersupply_on = true;
#endif
if (powersupply_on) {
editable.state = leds.lights_on;
EDIT_ITEM(bool, MSG_LEDS, &editable.state, leds.toggle);
}
#if ENABLED(LED_COLOR_PRESETS) #if ENABLED(LED_COLOR_PRESETS)
ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default); ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default);
#endif #endif
#if ENABLED(NEOPIXEL2_SEPARATE) #if ENABLED(NEOPIXEL2_SEPARATE)
editable.state = leds2.lights_on; editable.state = leds2.lights_on;
EDIT_ITEM(bool, MSG_LEDS2, &editable.state, leds2.toggle); EDIT_ITEM(bool, MSG_LEDS2, &editable.state, leds2.toggle);