|
@ -38,10 +38,14 @@ |
|
|
// Defines
|
|
|
// Defines
|
|
|
// ------------------------
|
|
|
// ------------------------
|
|
|
|
|
|
|
|
|
#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE |
|
|
#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE && DISABLED(NEOPIXEL2_SEPARATE) |
|
|
#define MULTIPLE_NEOPIXEL_TYPES 1 |
|
|
#define MULTIPLE_NEOPIXEL_TYPES 1 |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) |
|
|
|
|
|
#define CONJOINED_NEOPIXEL 1 |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
#if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR |
|
|
#if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR |
|
|
#define NEOPIXEL_IS_RGB 1 |
|
|
#define NEOPIXEL_IS_RGB 1 |
|
|
#else |
|
|
#else |
|
@ -61,7 +65,7 @@ |
|
|
class Marlin_NeoPixel { |
|
|
class Marlin_NeoPixel { |
|
|
private: |
|
|
private: |
|
|
static Adafruit_NeoPixel adaneo1 |
|
|
static Adafruit_NeoPixel adaneo1 |
|
|
#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) |
|
|
#if CONJOINED_NEOPIXEL |
|
|
, adaneo2 |
|
|
, adaneo2 |
|
|
#endif |
|
|
#endif |
|
|
; |
|
|
; |
|
@ -80,11 +84,7 @@ public: |
|
|
|
|
|
|
|
|
static inline void begin() { |
|
|
static inline void begin() { |
|
|
adaneo1.begin(); |
|
|
adaneo1.begin(); |
|
|
#if ENABLED(NEOPIXEL2_INSERIES) |
|
|
TERN_(CONJOINED_NEOPIXEL, adaneo2.begin()); |
|
|
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) { |
|
@ -93,23 +93,21 @@ public: |
|
|
else adaneo1.setPixelColor(n, c); |
|
|
else adaneo1.setPixelColor(n, c); |
|
|
#else |
|
|
#else |
|
|
adaneo1.setPixelColor(n, c); |
|
|
adaneo1.setPixelColor(n, c); |
|
|
TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c)); |
|
|
#if MULTIPLE_NEOPIXEL_TYPES |
|
|
|
|
|
adaneo2.setPixelColor(n, c); |
|
|
|
|
|
#endif |
|
|
#endif |
|
|
#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); |
|
|
#if ENABLED(NEOPIXEL2_INSERIES) |
|
|
TERN_(CONJOINED_NEOPIXEL, adaneo2.setBrightness(b)); |
|
|
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 EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) |
|
|
#if CONJOINED_NEOPIXEL |
|
|
adaneo2.show(); |
|
|
adaneo2.show(); |
|
|
#else |
|
|
#else |
|
|
adaneo1.setPin(NEOPIXEL2_PIN); |
|
|
adaneo1.setPin(NEOPIXEL2_PIN); |
|
@ -132,3 +130,47 @@ public: |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
extern Marlin_NeoPixel neo; |
|
|
extern Marlin_NeoPixel neo; |
|
|
|
|
|
|
|
|
|
|
|
// Neo pixel channel 2
|
|
|
|
|
|
#if ENABLED(NEOPIXEL2_SEPARATE) |
|
|
|
|
|
|
|
|
|
|
|
#if NEOPIXEL2_TYPE == NEO_RGB || NEOPIXEL2_TYPE == NEO_RBG || NEOPIXEL2_TYPE == NEO_GRB || NEOPIXEL2_TYPE == NEO_GBR || NEOPIXEL2_TYPE == NEO_BRG || NEOPIXEL2_TYPE == NEO_BGR |
|
|
|
|
|
#define NEOPIXEL2_IS_RGB 1 |
|
|
|
|
|
#else |
|
|
|
|
|
#define NEOPIXEL2_IS_RGBW 1 |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#if NEOPIXEL2_IS_RGB |
|
|
|
|
|
#define NEO2_WHITE 255, 255, 255, 0 |
|
|
|
|
|
#else |
|
|
|
|
|
#define NEO2_WHITE 0, 0, 0, 255 |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
class Marlin_NeoPixel2 { |
|
|
|
|
|
private: |
|
|
|
|
|
static Adafruit_NeoPixel adaneo; |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
|
static int8_t neoindex; |
|
|
|
|
|
|
|
|
|
|
|
static void init(); |
|
|
|
|
|
static void set_color_startup(const uint32_t c); |
|
|
|
|
|
|
|
|
|
|
|
static void set_color(const uint32_t c); |
|
|
|
|
|
|
|
|
|
|
|
static inline void begin() { adaneo.begin(); } |
|
|
|
|
|
static inline void set_pixel_color(const uint16_t n, const uint32_t c) { adaneo.setPixelColor(n, c); } |
|
|
|
|
|
static inline void set_brightness(const uint8_t b) { adaneo.setBrightness(b); } |
|
|
|
|
|
static inline void show() { adaneo.show(); } |
|
|
|
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
|
|
static inline uint16_t pixels() { return adaneo.numPixels();} |
|
|
|
|
|
static inline uint8_t brightness() { return adaneo.getBrightness(); } |
|
|
|
|
|
static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { |
|
|
|
|
|
return adaneo.Color(r, g, b, w); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
extern Marlin_NeoPixel2 neo2; |
|
|
|
|
|
|
|
|
|
|
|
#endif // NEOPIXEL2_SEPARATE
|
|
|