RGB Caselight (#20341)

This commit is contained in:
LinFor
2021-02-28 01:06:48 +03:00
committed by GitHub
parent ee7701c15b
commit e0aa9ce372
14 changed files with 86 additions and 41 deletions

View File

@ -42,6 +42,10 @@
#include "pca9533.h"
#endif
#if ENABLED(CASE_LIGHT_USE_RGB_LED)
#include "../../feature/caselight.h"
#endif
#if ENABLED(LED_COLOR_PRESETS)
const LEDColor LEDLights::defaultLEDColor = MakeLEDColor(
LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE,
@ -85,8 +89,11 @@ void LEDLights::set_color(const LEDColor &incol
#ifdef NEOPIXEL_BKGD_LED_INDEX
if (NEOPIXEL_BKGD_LED_INDEX == nextLed) {
if (++nextLed >= neo.pixels()) nextLed = 0;
return;
neo.set_color_background();
if (++nextLed >= neo.pixels()) {
nextLed = 0;
return;
}
}
#endif
@ -114,12 +121,13 @@ void LEDLights::set_color(const LEDColor &incol
// This variant uses 3-4 separate pins for the RGB(W) components.
// If the pins can do PWM then their intensity will be set.
#define UPDATE_RGBW(C,c) do { \
if (PWM_PIN(RGB_LED_##C##_PIN)) \
analogWrite(pin_t(RGB_LED_##C##_PIN), incol.c); \
else \
WRITE(RGB_LED_##C##_PIN, incol.c ? HIGH : LOW); \
#define _UPDATE_RGBW(C,c) do { \
if (PWM_PIN(RGB_LED_##C##_PIN)) \
analogWrite(pin_t(RGB_LED_##C##_PIN), c); \
else \
WRITE(RGB_LED_##C##_PIN, c ? HIGH : LOW); \
}while(0)
#define UPDATE_RGBW(C,c) _UPDATE_RGBW(C, TERN1(CASE_LIGHT_USE_RGB_LED, caselight.on) ? incol.c : 0)
UPDATE_RGBW(R,r); UPDATE_RGBW(G,g); UPDATE_RGBW(B,b);
#if ENABLED(RGBW_LED)
UPDATE_RGBW(W,w);

View File

@ -194,6 +194,8 @@ public:
#if ENABLED(LED_CONTROL_MENU)
static void toggle(); // swap "off" with color
#endif
#if EITHER(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED)
static inline void update() { set_color(color); }
#endif

View File

@ -60,7 +60,7 @@ void Marlin_NeoPixel::set_color(const uint32_t color) {
else {
for (uint16_t i = 0; i < pixels(); ++i) {
#ifdef NEOPIXEL_BKGD_LED_INDEX
if (i == NEOPIXEL_BKGD_LED_INDEX && color != 0x000000) {
if (i == NEOPIXEL_BKGD_LED_INDEX && TERN(ENABLED(NEOPIXEL_BKGD_ALWAYS_ON), true, color != 0x000000)) {
set_color_background();
continue;
}