Add option to arrange Neopixel sets in series (#18992)
This commit is contained in:
parent
492f49c06a
commit
a99c844296
@ -2354,6 +2354,7 @@
|
|||||||
#define NEOPIXEL_PIN 4 // LED driving pin
|
#define NEOPIXEL_PIN 4 // LED driving pin
|
||||||
//#define NEOPIXEL2_TYPE NEOPIXEL_TYPE
|
//#define NEOPIXEL2_TYPE NEOPIXEL_TYPE
|
||||||
//#define NEOPIXEL2_PIN 5
|
//#define NEOPIXEL2_PIN 5
|
||||||
|
#define NEOPIXEL2_INSERIES false // The default behaviour is 'false' with neopixel2 in parallel
|
||||||
#define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used
|
#define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used
|
||||||
#define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once.
|
#define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once.
|
||||||
#define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255)
|
#define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255)
|
||||||
|
@ -38,7 +38,7 @@ Marlin_NeoPixel neo;
|
|||||||
int8_t Marlin_NeoPixel::neoindex;
|
int8_t Marlin_NeoPixel::neoindex;
|
||||||
|
|
||||||
Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800)
|
Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800)
|
||||||
#if MULTIPLE_NEOPIXEL_TYPES
|
#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES)
|
||||||
, Marlin_NeoPixel::adaneo2(NEOPIXEL_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE + NEO_KHZ800)
|
, Marlin_NeoPixel::adaneo2(NEOPIXEL_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE + NEO_KHZ800)
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
class Marlin_NeoPixel {
|
class Marlin_NeoPixel {
|
||||||
private:
|
private:
|
||||||
static Adafruit_NeoPixel adaneo1
|
static Adafruit_NeoPixel adaneo1
|
||||||
#if MULTIPLE_NEOPIXEL_TYPES
|
#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES)
|
||||||
, adaneo2
|
, adaneo2
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
@ -82,23 +82,36 @@ public:
|
|||||||
|
|
||||||
static inline void begin() {
|
static inline void begin() {
|
||||||
adaneo1.begin();
|
adaneo1.begin();
|
||||||
TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.begin());
|
#if ENABLED(NEOPIXEL2_INSERIES)
|
||||||
|
adaneo2.begin();
|
||||||
|
#else
|
||||||
|
TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.begin());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void set_pixel_color(const uint16_t n, const uint32_t c) {
|
static inline void set_pixel_color(const uint16_t n, const uint32_t c) {
|
||||||
adaneo1.setPixelColor(n, c);
|
#if ENABLED(NEOPIXEL2_INSERIES)
|
||||||
TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c));
|
if (n >= NEOPIXEL_PIXELS) adaneo2.setPixelColor(n - (NEOPIXEL_PIXELS), c);
|
||||||
|
else adaneo1.setPixelColor(n, c);
|
||||||
|
#else
|
||||||
|
adaneo1.setPixelColor(n, c);
|
||||||
|
TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void set_brightness(const uint8_t b) {
|
static inline void set_brightness(const uint8_t b) {
|
||||||
adaneo1.setBrightness(b);
|
adaneo1.setBrightness(b);
|
||||||
TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setBrightness(b));
|
#if ENABLED(NEOPIXEL2_INSERIES)
|
||||||
|
adaneo2.setBrightness(b);
|
||||||
|
#else
|
||||||
|
TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setBrightness(b));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void show() {
|
static inline void show() {
|
||||||
adaneo1.show();
|
adaneo1.show();
|
||||||
#if PIN_EXISTS(NEOPIXEL2)
|
#if PIN_EXISTS(NEOPIXEL2)
|
||||||
#if MULTIPLE_NEOPIXEL_TYPES
|
#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES)
|
||||||
adaneo2.show();
|
adaneo2.show();
|
||||||
#else
|
#else
|
||||||
adaneo1.setPin(NEOPIXEL2_PIN);
|
adaneo1.setPin(NEOPIXEL2_PIN);
|
||||||
@ -113,7 +126,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
static inline uint16_t pixels() { return adaneo1.numPixels(); }
|
static inline uint16_t pixels() { TERN(NEOPIXEL2_INSERIES, return adaneo1.numPixels() * 2, return adaneo1.numPixels()); }
|
||||||
static inline uint8_t brightness() { return adaneo1.getBrightness(); }
|
static inline uint8_t brightness() { return adaneo1.getBrightness(); }
|
||||||
static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
|
static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
|
||||||
return adaneo1.Color(r, g, b, w);
|
return adaneo1.Color(r, g, b, w);
|
||||||
|
Loading…
Reference in New Issue
Block a user