|
|
@ -34,73 +34,81 @@
|
|
|
|
#include "../../core/utility.h"
|
|
|
|
#include "../../core/utility.h"
|
|
|
|
#endif
|
|
|
|
#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
|
|
|
|
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
|
|
|
void set_neopixel_color_background() {
|
|
|
|
|
|
|
|
|
|
|
|
void Marlin_NeoPixel::set_color_background() {
|
|
|
|
uint8_t background_color[4] = NEOPIXEL_BKGD_COLOR;
|
|
|
|
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
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
void set_neopixel_color(const uint32_t color) {
|
|
|
|
void Marlin_NeoPixel::set_color(const uint32_t color) {
|
|
|
|
for (uint16_t i = 0; i < pixels.numPixels(); ++i) {
|
|
|
|
for (uint16_t i = 0; i < pixels(); ++i) {
|
|
|
|
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
|
|
|
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
|
|
|
if (i == NEOPIXEL_BKGD_LED_INDEX && color != 0x000000) {
|
|
|
|
if (i == NEOPIXEL_BKGD_LED_INDEX && color != 0x000000) {
|
|
|
|
set_neopixel_color_background();
|
|
|
|
set_color_background();
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
pixels.setPixelColor(i, color);
|
|
|
|
set_pixel_color(i, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pixels.show();
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void set_neopixel_color_startup(const uint32_t color) {
|
|
|
|
void Marlin_NeoPixel::set_color_startup(const uint32_t color) {
|
|
|
|
for (uint16_t i = 0; i < pixels.numPixels(); ++i)
|
|
|
|
for (uint16_t i = 0; i < pixels(); ++i)
|
|
|
|
pixels.setPixelColor(i, color);
|
|
|
|
set_pixel_color(i, color);
|
|
|
|
pixels.show();
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void setup_neopixel() {
|
|
|
|
void Marlin_NeoPixel::init() {
|
|
|
|
SET_OUTPUT(NEOPIXEL_PIN);
|
|
|
|
SET_OUTPUT(NEOPIXEL_PIN);
|
|
|
|
pixels.setBrightness(NEOPIXEL_BRIGHTNESS); // 0 - 255 range
|
|
|
|
set_brightness(NEOPIXEL_BRIGHTNESS); // 0 - 255 range
|
|
|
|
pixels.begin();
|
|
|
|
begin();
|
|
|
|
pixels.show(); // initialize to all off
|
|
|
|
show(); // initialize to all off
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(NEOPIXEL_STARTUP_TEST)
|
|
|
|
#if ENABLED(NEOPIXEL_STARTUP_TEST)
|
|
|
|
safe_delay(1000);
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
safe_delay(1000);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
|
|
|
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
|
|
|
set_neopixel_color_background();
|
|
|
|
set_color_background();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(LED_USER_PRESET_STARTUP)
|
|
|
|
#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
|
|
|
|
#else
|
|
|
|
set_neopixel_color(pixels.Color(0, 0, 0, 0));
|
|
|
|
set_color(adaneo1.Color(0, 0, 0, 0));
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#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) {
|
|
|
|
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 = pixels.Color(r, g, b, w);
|
|
|
|
const uint32_t color = adaneo1.Color(r, g, b, w);
|
|
|
|
pixels.setBrightness(p);
|
|
|
|
set_brightness(p);
|
|
|
|
#if DISABLED(NEOPIXEL_IS_SEQUENTIAL)
|
|
|
|
#if DISABLED(NEOPIXEL_IS_SEQUENTIAL)
|
|
|
|
set_neopixel_color(color);
|
|
|
|
set_color(color);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
static uint16_t nextLed = 0;
|
|
|
|
static uint16_t nextLed = 0;
|
|
|
|
pixels.setPixelColor(nextLed, color);
|
|
|
|
set_pixel_color(nextLed, color);
|
|
|
|
pixels.show();
|
|
|
|
show();
|
|
|
|
if (++nextLed >= pixels.numPixels()) nextLed = 0;
|
|
|
|
if (++nextLed >= pixels()) nextLed = 0;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|