Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mini12864 v2.1 + psu control + neopixel backlight #21021

Merged
merged 4 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Marlin/src/feature/leds/leds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ void LEDLights::set_color(const LEDColor &incol
millis_t LEDLights::led_off_time; // = 0

void LEDLights::update_timeout(const bool power_on) {
const millis_t ms = millis();
if (power_on)
reset_timeout(ms);
else if (ELAPSED(ms, led_off_time))
set_off();
if (lights_on) {
const millis_t ms = millis();
if (power_on)
reset_timeout(ms);
else if (ELAPSED(ms, led_off_time))
set_off();
}
}

#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/leds/leds.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class LEDLights {
public:
static inline void reset_timeout(const millis_t &ms) {
led_off_time = ms + LED_BACKLIGHT_TIMEOUT;
if (!lights_on) set_default();
if (!lights_on) update();
}
static void update_timeout(const bool power_on);
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ void MarlinUI::update() {
refresh(LCDVIEW_REDRAW_NOW);

#ifdef LED_BACKLIGHT_TIMEOUT
leds.reset_timeout(ms);
if (!powersupply_on) leds.reset_timeout(ms);
#endif
}

Expand Down
13 changes: 11 additions & 2 deletions Marlin/src/lcd/menu/menu_led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,20 @@ void menu_led() {
BACK_ITEM(MSG_MAIN);

#if ENABLED(LED_CONTROL_MENU)
editable.state = leds.lights_on;
EDIT_ITEM(bool, MSG_LEDS, &editable.state, leds.toggle);
#if ENABLED(PSU_CONTROL)
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)
ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default);
#endif

#if ENABLED(NEOPIXEL2_SEPARATE)
editable.state = leds2.lights_on;
EDIT_ITEM(bool, MSG_LEDS2, &editable.state, leds2.toggle);
Expand Down