|
|
|
@ -34,73 +34,81 @@
|
|
|
|
|
#include "../../core/utility.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
Adafruit_NeoPixel pixels(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800);
|
|
|
|
|
Marlin_NeoPixel neo;
|
|
|
|
|
|
|
|
|
|
Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800)
|
|
|
|
|
#if MULTIPLE_NEOPIXEL_TYPES
|
|
|
|
|
, Marlin_NeoPixel::adaneo2(NEOPIXEL_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE + NEO_KHZ800)
|
|
|
|
|
#endif
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
|
|
|
|
void set_neopixel_color_background() {
|
|
|
|
|
|
|
|
|
|
void Marlin_NeoPixel::set_color_background() {
|
|
|
|
|
uint8_t background_color[4] = NEOPIXEL_BKGD_COLOR;
|
|
|
|
|
pixels.setPixelColor(NEOPIXEL_BKGD_LED_INDEX, pixels.Color(background_color[0], background_color[1], background_color[2], background_color[3]));
|
|
|
|
|
set_pixel_color(NEOPIXEL_BKGD_LED_INDEX, adaneo1.Color(background_color[0], background_color[1], background_color[2], background_color[3]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void set_neopixel_color(const uint32_t color) {
|
|
|
|
|
for (uint16_t i = 0; i < pixels.numPixels(); ++i) {
|
|
|
|
|
void Marlin_NeoPixel::set_color(const uint32_t color) {
|
|
|
|
|
for (uint16_t i = 0; i < pixels(); ++i) {
|
|
|
|
|
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
|
|
|
|
if (i == NEOPIXEL_BKGD_LED_INDEX && color != 0x000000) {
|
|
|
|
|
set_neopixel_color_background();
|
|
|
|
|
set_color_background();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
pixels.setPixelColor(i, color);
|
|
|
|
|
set_pixel_color(i, color);
|
|
|
|
|
}
|
|
|
|
|
pixels.show();
|
|
|
|
|
show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_neopixel_color_startup(const uint32_t color) {
|
|
|
|
|
for (uint16_t i = 0; i < pixels.numPixels(); ++i)
|
|
|
|
|
pixels.setPixelColor(i, color);
|
|
|
|
|
pixels.show();
|
|
|
|
|
void Marlin_NeoPixel::set_color_startup(const uint32_t color) {
|
|
|
|
|
for (uint16_t i = 0; i < pixels(); ++i)
|
|
|
|
|
set_pixel_color(i, color);
|
|
|
|
|
show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setup_neopixel() {
|
|
|
|
|
void Marlin_NeoPixel::init() {
|
|
|
|
|
SET_OUTPUT(NEOPIXEL_PIN);
|
|
|
|
|
pixels.setBrightness(NEOPIXEL_BRIGHTNESS); // 0 - 255 range
|
|
|
|
|
pixels.begin();
|
|
|
|
|
pixels.show(); // initialize to all off
|
|
|
|
|
set_brightness(NEOPIXEL_BRIGHTNESS); // 0 - 255 range
|
|
|
|
|
begin();
|
|
|
|
|
show(); // initialize to all off
|
|
|
|
|
|
|
|
|
|
#if ENABLED(NEOPIXEL_STARTUP_TEST)
|
|
|
|
|
safe_delay(1000);
|
|
|
|
|
set_neopixel_color_startup(pixels.Color(255, 0, 0, 0)); // red
|
|
|
|
|
set_color_startup(adaneo1.Color(255, 0, 0, 0)); // red
|
|
|
|
|
safe_delay(1000);
|
|
|
|
|
set_neopixel_color_startup(pixels.Color(0, 255, 0, 0)); // green
|
|
|
|
|
set_color_startup(adaneo1.Color(0, 255, 0, 0)); // green
|
|
|
|
|
safe_delay(1000);
|
|
|
|
|
set_neopixel_color_startup(pixels.Color(0, 0, 255, 0)); // blue
|
|
|
|
|
set_color_startup(adaneo1.Color(0, 0, 255, 0)); // blue
|
|
|
|
|
safe_delay(1000);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
|
|
|
|
set_neopixel_color_background();
|
|
|
|
|
set_color_background();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if ENABLED(LED_USER_PRESET_STARTUP)
|
|
|
|
|
set_neopixel_color(pixels.Color(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE));
|
|
|
|
|
set_color(adaneo1.Color(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE));
|
|
|
|
|
#else
|
|
|
|
|
set_neopixel_color(pixels.Color(0, 0, 0, 0));
|
|
|
|
|
set_color(adaneo1.Color(0, 0, 0, 0));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
bool neopixel_set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p) {
|
|
|
|
|
const uint32_t color = pixels.Color(r, g, b, w);
|
|
|
|
|
pixels.setBrightness(p);
|
|
|
|
|
bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p) {
|
|
|
|
|
const uint32_t color = adaneo1.Color(r, g, b, w);
|
|
|
|
|
set_brightness(p);
|
|
|
|
|
#if DISABLED(NEOPIXEL_IS_SEQUENTIAL)
|
|
|
|
|
set_neopixel_color(color);
|
|
|
|
|
set_color(color);
|
|
|
|
|
return false;
|
|
|
|
|
#else
|
|
|
|
|
static uint16_t nextLed = 0;
|
|
|
|
|
pixels.setPixelColor(nextLed, color);
|
|
|
|
|
pixels.show();
|
|
|
|
|
if (++nextLed >= pixels.numPixels()) nextLed = 0;
|
|
|
|
|
set_pixel_color(nextLed, color);
|
|
|
|
|
show();
|
|
|
|
|
if (++nextLed >= pixels()) nextLed = 0;
|
|
|
|
|
return true;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|