diff --git a/Marlin/src/feature/caselight.cpp b/Marlin/src/feature/caselight.cpp index d4cc6b1504..fb0f6e3bee 100644 --- a/Marlin/src/feature/caselight.cpp +++ b/Marlin/src/feature/caselight.cpp @@ -28,10 +28,6 @@ CaseLight caselight; -#if CASE_LIGHT_IS_COLOR_LED - #include "leds/leds.h" -#endif - #if CASELIGHT_USES_BRIGHTNESS && !defined(CASE_LIGHT_DEFAULT_BRIGHTNESS) #define CASE_LIGHT_DEFAULT_BRIGHTNESS 0 // For use on PWM pin as non-PWM just sets a default #endif @@ -43,13 +39,9 @@ CaseLight caselight; bool CaseLight::on = CASE_LIGHT_DEFAULT_ON; #if CASE_LIGHT_IS_COLOR_LED - LEDColor CaseLight::color = - #ifdef CASE_LIGHT_DEFAULT_COLOR - CASE_LIGHT_DEFAULT_COLOR - #else - { 255, 255, 255, 255 } - #endif - ; + #include "leds/leds.h" + constexpr uint8_t init_case_light[] = CASE_LIGHT_DEFAULT_COLOR; + LEDColor CaseLight::color = { init_case_light[0], init_case_light[1], init_case_light[2], TERN_(HAS_WHITE_LED, init_case_light[3]) }; #endif #ifndef INVERT_CASE_LIGHT @@ -73,14 +65,12 @@ void CaseLight::update(const bool sflag) { brightness = brightness_sav; // Restore last brightness for M355 S1 const uint8_t i = on ? brightness : 0, n10ct = INVERT_CASE_LIGHT ? 255 - i : i; + UNUSED(n10ct); #endif #if CASE_LIGHT_IS_COLOR_LED - leds.set_color( - MakeLEDColor(color.r, color.g, color.b, color.w, n10ct), - false - ); + leds.set_color(MakeLEDColor(color.r, color.g, color.b, color.w, n10ct)); #else // !CASE_LIGHT_IS_COLOR_LED diff --git a/Marlin/src/feature/caselight.h b/Marlin/src/feature/caselight.h index 05385ad0cb..b2e82f9b83 100644 --- a/Marlin/src/feature/caselight.h +++ b/Marlin/src/feature/caselight.h @@ -27,7 +27,7 @@ #include "leds/leds.h" // for LEDColor #endif -#if DISABLED(CASE_LIGHT_NO_BRIGHTNESS) || ENABLED(CASE_LIGHT_USE_NEOPIXEL) +#if NONE(CASE_LIGHT_NO_BRIGHTNESS, CASE_LIGHT_IS_COLOR_LED) || ENABLED(CASE_LIGHT_USE_NEOPIXEL) #define CASELIGHT_USES_BRIGHTNESS 1 #endif diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index ef0561a435..8349049a00 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -53,7 +53,7 @@ ); #endif -#if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) +#if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED) LEDColor LEDLights::color; bool LEDLights::lights_on; #endif diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index c34eb57f44..cec95102d7 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -187,7 +187,7 @@ public: static inline LEDColor get_color() { return lights_on ? color : LEDColorOff(); } #endif - #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) + #if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED) static LEDColor color; // last non-off color static bool lights_on; // the last set color was "on" #endif diff --git a/Marlin/src/gcode/feature/caselight/M355.cpp b/Marlin/src/gcode/feature/caselight/M355.cpp index b0d94e7cd8..b3b863f02e 100644 --- a/Marlin/src/gcode/feature/caselight/M355.cpp +++ b/Marlin/src/gcode/feature/caselight/M355.cpp @@ -61,7 +61,7 @@ void GcodeSuite::M355() { SERIAL_ECHOLNPGM(STR_OFF); else { #if CASELIGHT_USES_BRIGHTNESS - if (TERN(CASE_LIGHT_USE_NEOPIXEL, true, PWM_PIN(CASE_LIGHT_PIN))) { + if (TERN(CASE_LIGHT_USE_NEOPIXEL, true, TERN0(NEED_CASE_LIGHT_PIN, PWM_PIN(CASE_LIGHT_PIN)))) { SERIAL_ECHOLN(int(caselight.brightness)); return; }