Browse Source

Patches for CASE_LIGHT_USE_RGB_LED (#21811)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
sanek88lbl 3 years ago
parent
commit
9485d44903
No account linked to committer's email address

+ 5
- 15
Marlin/src/feature/caselight.cpp View File

@@ -28,10 +28,6 @@
28 28
 
29 29
 CaseLight caselight;
30 30
 
31
-#if CASE_LIGHT_IS_COLOR_LED
32
-  #include "leds/leds.h"
33
-#endif
34
-
35 31
 #if CASELIGHT_USES_BRIGHTNESS && !defined(CASE_LIGHT_DEFAULT_BRIGHTNESS)
36 32
   #define CASE_LIGHT_DEFAULT_BRIGHTNESS 0 // For use on PWM pin as non-PWM just sets a default
37 33
 #endif
@@ -43,13 +39,9 @@ CaseLight caselight;
43 39
 bool CaseLight::on = CASE_LIGHT_DEFAULT_ON;
44 40
 
45 41
 #if CASE_LIGHT_IS_COLOR_LED
46
-  LEDColor CaseLight::color =
47
-    #ifdef CASE_LIGHT_DEFAULT_COLOR
48
-      CASE_LIGHT_DEFAULT_COLOR
49
-    #else
50
-      { 255, 255, 255, 255 }
51
-    #endif
52
-  ;
42
+  #include "leds/leds.h"
43
+  constexpr uint8_t init_case_light[] = CASE_LIGHT_DEFAULT_COLOR;
44
+  LEDColor CaseLight::color = { init_case_light[0], init_case_light[1], init_case_light[2], TERN_(HAS_WHITE_LED, init_case_light[3]) };
53 45
 #endif
54 46
 
55 47
 #ifndef INVERT_CASE_LIGHT
@@ -73,14 +65,12 @@ void CaseLight::update(const bool sflag) {
73 65
       brightness = brightness_sav;  // Restore last brightness for M355 S1
74 66
 
75 67
     const uint8_t i = on ? brightness : 0, n10ct = INVERT_CASE_LIGHT ? 255 - i : i;
68
+    UNUSED(n10ct);
76 69
   #endif
77 70
 
78 71
   #if CASE_LIGHT_IS_COLOR_LED
79 72
 
80
-    leds.set_color(
81
-      MakeLEDColor(color.r, color.g, color.b, color.w, n10ct),
82
-      false
83
-    );
73
+    leds.set_color(MakeLEDColor(color.r, color.g, color.b, color.w, n10ct));
84 74
 
85 75
   #else // !CASE_LIGHT_IS_COLOR_LED
86 76
 

+ 1
- 1
Marlin/src/feature/caselight.h View File

@@ -27,7 +27,7 @@
27 27
   #include "leds/leds.h" // for LEDColor
28 28
 #endif
29 29
 
30
-#if DISABLED(CASE_LIGHT_NO_BRIGHTNESS) || ENABLED(CASE_LIGHT_USE_NEOPIXEL)
30
+#if NONE(CASE_LIGHT_NO_BRIGHTNESS, CASE_LIGHT_IS_COLOR_LED) || ENABLED(CASE_LIGHT_USE_NEOPIXEL)
31 31
   #define CASELIGHT_USES_BRIGHTNESS 1
32 32
 #endif
33 33
 

+ 1
- 1
Marlin/src/feature/leds/leds.cpp View File

@@ -53,7 +53,7 @@
53 53
   );
54 54
 #endif
55 55
 
56
-#if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS)
56
+#if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED)
57 57
   LEDColor LEDLights::color;
58 58
   bool LEDLights::lights_on;
59 59
 #endif

+ 1
- 1
Marlin/src/feature/leds/leds.h View File

@@ -187,7 +187,7 @@ public:
187 187
     static inline LEDColor get_color() { return lights_on ? color : LEDColorOff(); }
188 188
   #endif
189 189
 
190
-  #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS)
190
+  #if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED)
191 191
     static LEDColor color; // last non-off color
192 192
     static bool lights_on; // the last set color was "on"
193 193
   #endif

+ 1
- 1
Marlin/src/gcode/feature/caselight/M355.cpp View File

@@ -61,7 +61,7 @@ void GcodeSuite::M355() {
61 61
     SERIAL_ECHOLNPGM(STR_OFF);
62 62
   else {
63 63
     #if CASELIGHT_USES_BRIGHTNESS
64
-      if (TERN(CASE_LIGHT_USE_NEOPIXEL, true, PWM_PIN(CASE_LIGHT_PIN))) {
64
+      if (TERN(CASE_LIGHT_USE_NEOPIXEL, true, TERN0(NEED_CASE_LIGHT_PIN, PWM_PIN(CASE_LIGHT_PIN)))) {
65 65
         SERIAL_ECHOLN(int(caselight.brightness));
66 66
         return;
67 67
       }

Loading…
Cancel
Save