|
@@ -31,11 +31,13 @@
|
31
|
31
|
* M150: Set Status LED Color - Use R-U-B-W for R-G-B-W
|
32
|
32
|
* and Brightness - Use P (for NEOPIXEL only)
|
33
|
33
|
*
|
34
|
|
- * Always sets all 3 or 4 components. If a component is left out, set to 0.
|
35
|
|
- * If brightness is left out, no value changed
|
|
34
|
+ * Always sets all 3 or 4 components unless the K flag is specified.
|
|
35
|
+ * If a component is left out, set to 0.
|
|
36
|
+ * If brightness is left out, no value changed.
|
36
|
37
|
*
|
37
|
38
|
* With NEOPIXEL_LED:
|
38
|
39
|
* I<index> Set the NeoPixel index to affect. Default: All
|
|
40
|
+ * K Keep all unspecified values unchanged instead of setting to 0.
|
39
|
41
|
*
|
40
|
42
|
* With NEOPIXEL2_SEPARATE:
|
41
|
43
|
* S<index> The NeoPixel strip to set. Default: All.
|
|
@@ -51,16 +53,19 @@
|
51
|
53
|
* M150 P ; Set LED full brightness
|
52
|
54
|
* M150 I1 R ; Set NEOPIXEL index 1 to red
|
53
|
55
|
* M150 S1 I1 R ; Set SEPARATE index 1 to red
|
|
56
|
+ * M150 K R127 ; Set LED red to 50% without changing blue or green
|
54
|
57
|
*/
|
55
|
58
|
void GcodeSuite::M150() {
|
|
59
|
+ int32_t old_color = 0;
|
|
60
|
+
|
56
|
61
|
#if ENABLED(NEOPIXEL_LED)
|
57
|
62
|
const pixel_index_t index = parser.intval('I', -1);
|
58
|
63
|
#if ENABLED(NEOPIXEL2_SEPARATE)
|
59
|
64
|
int8_t brightness = neo.brightness(), unit = parser.intval('S', -1);
|
60
|
65
|
switch (unit) {
|
61
|
66
|
case -1: neo2.neoindex = index; // fall-thru
|
62
|
|
- case 0: neo.neoindex = index; break;
|
63
|
|
- case 1: neo2.neoindex = index; brightness = neo2.brightness(); break;
|
|
67
|
+ case 0: neo.neoindex = index; old_color = parser.seen('K') ? neo.pixel_color(index >= 0 ? index : 0) : 0; break;
|
|
68
|
+ case 1: neo2.neoindex = index; brightness = neo2.brightness(); old_color = parser.seen('K') ? neo2.pixel_color(index >= 0 ? index : 0) : 0; break;
|
64
|
69
|
}
|
65
|
70
|
#else
|
66
|
71
|
const uint8_t brightness = neo.brightness();
|
|
@@ -69,10 +74,10 @@ void GcodeSuite::M150() {
|
69
|
74
|
#endif
|
70
|
75
|
|
71
|
76
|
const LEDColor color = LEDColor(
|
72
|
|
- parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
|
73
|
|
- parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
|
74
|
|
- parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0
|
75
|
|
- OPTARG(HAS_WHITE_LED, parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0)
|
|
77
|
+ parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : (old_color >> 16) & 0xFF,
|
|
78
|
+ parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : (old_color >> 8) & 0xFF,
|
|
79
|
+ parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : old_color & 0xFF
|
|
80
|
+ OPTARG(HAS_WHITE_LED, parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : (old_color >> 24) & 0xFF)
|
76
|
81
|
OPTARG(NEOPIXEL_LED, parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : brightness)
|
77
|
82
|
);
|
78
|
83
|
|