Skip to content

Commit

Permalink
Fix mini12864 v2.1 + PSU control + NeoPixel backlight (MarlinFirmware…
Browse files Browse the repository at this point in the history
  • Loading branch information
ellensp authored and zillarob committed Feb 25, 2021
1 parent bd9ec64 commit 42bd5a2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
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
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
2 changes: 1 addition & 1 deletion Marlin/src/lcd/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,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

0 comments on commit 42bd5a2

Please sign in to comment.