Browse Source

🧑‍💻 Option allowing > 127 Neopixels (#23322)

GHGiampy 3 years ago
parent
commit
ba32391454
No account linked to committer's email address

+ 2
- 2
Marlin/src/feature/leds/neopixel.cpp View File

35
 #endif
35
 #endif
36
 
36
 
37
 Marlin_NeoPixel neo;
37
 Marlin_NeoPixel neo;
38
-int8_t Marlin_NeoPixel::neoindex;
38
+pixel_index_t Marlin_NeoPixel::neoindex;
39
 
39
 
40
 Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800);
40
 Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800);
41
 #if CONJOINED_NEOPIXEL
41
 #if CONJOINED_NEOPIXEL
116
 
116
 
117
   Marlin_NeoPixel2 neo2;
117
   Marlin_NeoPixel2 neo2;
118
 
118
 
119
-  int8_t Marlin_NeoPixel2::neoindex;
119
+  pixel_index_t Marlin_NeoPixel2::neoindex;
120
   Adafruit_NeoPixel Marlin_NeoPixel2::adaneo(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE);
120
   Adafruit_NeoPixel Marlin_NeoPixel2::adaneo(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE);
121
 
121
 
122
   void Marlin_NeoPixel2::set_color(const uint32_t color) {
122
   void Marlin_NeoPixel2::set_color(const uint32_t color) {

+ 11
- 3
Marlin/src/feature/leds/neopixel.h View File

25
  * NeoPixel support
25
  * NeoPixel support
26
  */
26
  */
27
 
27
 
28
+#define MAX_NEOPIXELS 127
29
+
28
 #ifndef _NEOPIXEL_INCLUDE_
30
 #ifndef _NEOPIXEL_INCLUDE_
29
   #error "Always include 'leds.h' and not 'neopixel.h' directly."
31
   #error "Always include 'leds.h' and not 'neopixel.h' directly."
30
 #endif
32
 #endif
63
 #endif
65
 #endif
64
 
66
 
65
 // ------------------------
67
 // ------------------------
66
-// Function prototypes
68
+// Types
69
+// ------------------------
70
+
71
+typedef IF<(MAX_NEOPIXELS > 127), int16_t, int8_t>::type pixel_index_t;
72
+
73
+// ------------------------
74
+// Classes
67
 // ------------------------
75
 // ------------------------
68
 
76
 
69
 class Marlin_NeoPixel {
77
 class Marlin_NeoPixel {
74
   #endif
82
   #endif
75
 
83
 
76
 public:
84
 public:
77
-  static int8_t neoindex;
85
+  static pixel_index_t neoindex;
78
 
86
 
79
   static void init();
87
   static void init();
80
   static void set_color_startup(const uint32_t c);
88
   static void set_color_startup(const uint32_t c);
150
     static Adafruit_NeoPixel adaneo;
158
     static Adafruit_NeoPixel adaneo;
151
 
159
 
152
   public:
160
   public:
153
-    static int8_t neoindex;
161
+    static pixel_index_t neoindex;
154
 
162
 
155
     static void init();
163
     static void init();
156
     static void set_color_startup(const uint32_t c);
164
     static void set_color_startup(const uint32_t c);

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

54
  */
54
  */
55
 void GcodeSuite::M150() {
55
 void GcodeSuite::M150() {
56
   #if ENABLED(NEOPIXEL_LED)
56
   #if ENABLED(NEOPIXEL_LED)
57
-    const int8_t index = parser.intval('I', -1);
57
+    const pixel_index_t index = parser.intval('I', -1);
58
     #if ENABLED(NEOPIXEL2_SEPARATE)
58
     #if ENABLED(NEOPIXEL2_SEPARATE)
59
       int8_t brightness = neo.brightness(), unit = parser.intval('S', -1);
59
       int8_t brightness = neo.brightness(), unit = parser.intval('S', -1);
60
       switch (unit) {
60
       switch (unit) {

Loading…
Cancel
Save