Restore LED light color after pid tuning (#12082)

This commit is contained in:
Giuliano Zaro
2018-11-01 23:44:41 +01:00
committed by Scott Lahteine
parent 9f77df2590
commit 323c088356
4 changed files with 26 additions and 23 deletions

View File

@ -48,7 +48,7 @@
);
#endif
#if ENABLED(LED_CONTROL_MENU)
#if ENABLED(LED_CONTROL_MENU) || ENABLED(PRINTER_EVENT_LEDS)
LEDColor LEDLights::color;
bool LEDLights::lights_on;
#endif
@ -72,7 +72,9 @@ void LEDLights::set_color(const LEDColor &incol
#if ENABLED(NEOPIXEL_LED)
const uint32_t neocolor = pixels.Color(incol.r, incol.g, incol.b, incol.w);
const uint32_t neocolor = LEDColorWhite() == incol
? pixels.Color(NEO_WHITE)
: pixels.Color(incol.r, incol.g, incol.b, incol.w);
static uint16_t nextLed = 0;
pixels.setBrightness(incol.i);
@ -117,22 +119,13 @@ void LEDLights::set_color(const LEDColor &incol
pca9632_set_led_color(incol);
#endif
#if ENABLED(LED_CONTROL_MENU)
#if ENABLED(LED_CONTROL_MENU) || ENABLED(PRINTER_EVENT_LEDS)
// Don't update the color when OFF
lights_on = !incol.is_off();
if (lights_on) color = incol;
#endif
}
void LEDLights::set_white() {
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(BLINKM) || ENABLED(PCA9632)
set_color(LEDColorWhite());
#endif
#if ENABLED(NEOPIXEL_LED)
set_neopixel_color(pixels.Color(NEO_WHITE));
#endif
}
#if ENABLED(LED_CONTROL_MENU)
void LEDLights::toggle() { if (lights_on) set_off(); else update(); }
#endif

View File

@ -115,12 +115,12 @@ typedef struct LEDColor {
* Color helpers and presets
*/
#if HAS_WHITE_LED
#define LEDColorWhite() LEDColor(0, 0, 0, 255)
#if ENABLED(NEOPIXEL_LED)
#define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B, W, I)
#else
#define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B, W)
#endif
#define LEDColorWhite() LEDColor(0, 0, 0, 255)
#else
#define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B)
#define LEDColorWhite() LEDColor(255, 255, 255)
@ -164,9 +164,9 @@ public:
);
}
static void set_white();
FORCE_INLINE static void set_off() { set_color(LEDColorOff()); }
FORCE_INLINE static void set_green() { set_color(LEDColorGreen()); }
FORCE_INLINE static void set_white() { set_color(LEDColorWhite()); }
#if ENABLED(LED_COLOR_PRESETS)
static const LEDColor defaultLEDColor;
@ -179,9 +179,15 @@ public:
FORCE_INLINE static void set_violet() { set_color(LEDColorViolet()); }
#endif
#if ENABLED(LED_CONTROL_MENU)
#if ENABLED(PRINTER_EVENT_LEDS)
FORCE_INLINE static LEDColor get_color() { return lights_on ? color : LEDColorOff(); }
#endif
#if ENABLED(LED_CONTROL_MENU) || ENABLED(PRINTER_EVENT_LEDS)
static LEDColor color; // last non-off color
static bool lights_on; // the last set color was "on"
#endif
#if ENABLED(LED_CONTROL_MENU)
static void toggle(); // swap "off" with color
FORCE_INLINE static void update() { set_color(color); }
#endif

View File

@ -38,18 +38,18 @@ private:
public:
#if HAS_TEMP_HOTEND
FORCE_INLINE static void onHotendHeatingStart() { old_intensity = 0; }
FORCE_INLINE static LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
static void onHotendHeating(const float &start, const float &current, const float &target);
#endif
#if HAS_HEATED_BED
FORCE_INLINE static void onBedHeatingStart() { old_intensity = 127; }
FORCE_INLINE static LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
static void onBedHeating(const float &start, const float &current, const float &target);
#endif
#if HAS_TEMP_HOTEND || HAS_HEATED_BED
FORCE_INLINE static void onHeated() { leds.set_white(); }
FORCE_INLINE static void onHeatersOff() { leds.set_off(); }
FORCE_INLINE static void onHeated() { leds.set_color(LEDColorWhite()); }
FORCE_INLINE static void onPidTuningDone(LEDColor c) { leds.set_color(c); }
#endif
#if ENABLED(SDSUPPORT)