♻️ LEDs refactor and extend (#21962)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
parent
a9fd2769f3
commit
3fcf3f69ca
@ -2685,7 +2685,7 @@
|
|||||||
//#define NEOPIXEL_LED
|
//#define NEOPIXEL_LED
|
||||||
#if ENABLED(NEOPIXEL_LED)
|
#if ENABLED(NEOPIXEL_LED)
|
||||||
#define NEOPIXEL_TYPE NEO_GRBW // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h)
|
#define NEOPIXEL_TYPE NEO_GRBW // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h)
|
||||||
#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 NEOPIXEL_PIXELS 30 // Number of LEDs in the strip. (Longest strip when NEOPIXEL2_SEPARATE is disabled.)
|
#define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip. (Longest strip when NEOPIXEL2_SEPARATE is disabled.)
|
||||||
@ -2703,10 +2703,11 @@
|
|||||||
//#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel
|
//#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Use a single NeoPixel LED for static (background) lighting
|
// Use some of the NeoPixel LEDs for static (background) lighting
|
||||||
//#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use
|
//#define NEOPIXEL_BKGD_INDEX_FIRST 0 // Index of the first background LED
|
||||||
//#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W
|
//#define NEOPIXEL_BKGD_INDEX_LAST 5 // Index of the last background LED
|
||||||
//#define NEOPIXEL_BKGD_ALWAYS_ON // Keep the backlight on when other NeoPixels are off
|
//#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W
|
||||||
|
//#define NEOPIXEL_BKGD_ALWAYS_ON // Keep the backlight on when other NeoPixels are off
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,9 +65,7 @@ void CaseLight::update(const bool sflag) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CASE_LIGHT_IS_COLOR_LED
|
#if CASE_LIGHT_IS_COLOR_LED
|
||||||
|
leds.set_color(LEDColor(color.r, color.g, color.b OPTARG(HAS_WHITE_LED, color.w), n10ct));
|
||||||
leds.set_color(MakeLEDColor(color.r, color.g, color.b, color.w, n10ct));
|
|
||||||
|
|
||||||
#else // !CASE_LIGHT_IS_COLOR_LED
|
#else // !CASE_LIGHT_IS_COLOR_LED
|
||||||
|
|
||||||
#if CASELIGHT_USES_BRIGHTNESS
|
#if CASELIGHT_USES_BRIGHTNESS
|
||||||
|
@ -47,9 +47,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(LED_COLOR_PRESETS)
|
#if ENABLED(LED_COLOR_PRESETS)
|
||||||
const LEDColor LEDLights::defaultLEDColor = MakeLEDColor(
|
const LEDColor LEDLights::defaultLEDColor = LEDColor(
|
||||||
LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE,
|
LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE
|
||||||
LED_USER_PRESET_WHITE, LED_USER_PRESET_BRIGHTNESS
|
OPTARG(HAS_WHITE_LED, LED_USER_PRESET_WHITE)
|
||||||
|
OPTARG(NEOPIXEL_LED, LED_USER_PRESET_BRIGHTNESS)
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -75,34 +76,35 @@ void LEDLights::setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LEDLights::set_color(const LEDColor &incol
|
void LEDLights::set_color(const LEDColor &incol
|
||||||
OPTARG(NEOPIXEL_LED, bool isSequence/*=false*/)
|
OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence/*=false*/)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
#if ENABLED(NEOPIXEL_LED)
|
#if ENABLED(NEOPIXEL_LED)
|
||||||
|
|
||||||
const uint32_t neocolor = LEDColorWhite() == incol
|
const uint32_t neocolor = LEDColorWhite() == incol
|
||||||
? neo.Color(NEO_WHITE)
|
? neo.Color(NEO_WHITE)
|
||||||
: neo.Color(incol.r, incol.g, incol.b, incol.w);
|
: neo.Color(incol.r, incol.g, incol.b OPTARG(HAS_WHITE_LED, incol.w));
|
||||||
static uint16_t nextLed = 0;
|
|
||||||
|
|
||||||
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
#if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
|
||||||
if (NEOPIXEL_BKGD_LED_INDEX == nextLed) {
|
static uint16_t nextLed = 0;
|
||||||
neo.set_color_background();
|
#ifdef NEOPIXEL_BKGD_INDEX_FIRST
|
||||||
if (++nextLed >= neo.pixels()) {
|
while (WITHIN(nextLed, NEOPIXEL_BKGD_INDEX_FIRST, NEOPIXEL_BKGD_INDEX_LAST)) {
|
||||||
nextLed = 0;
|
neo.reset_background_color();
|
||||||
return;
|
if (++nextLed >= neo.pixels()) { nextLed = 0; return; }
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
neo.set_brightness(incol.i);
|
neo.set_brightness(incol.i);
|
||||||
|
|
||||||
if (isSequence) {
|
#if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
|
||||||
neo.set_pixel_color(nextLed, neocolor);
|
if (isSequence) {
|
||||||
neo.show();
|
neo.set_pixel_color(nextLed, neocolor);
|
||||||
if (++nextLed >= neo.pixels()) nextLed = 0;
|
neo.show();
|
||||||
return;
|
if (++nextLed >= neo.pixels()) nextLed = 0;
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
neo.set_color(neocolor);
|
neo.set_color(neocolor);
|
||||||
|
|
||||||
@ -167,9 +169,10 @@ void LEDLights::set_color(const LEDColor &incol
|
|||||||
#if ENABLED(NEOPIXEL2_SEPARATE)
|
#if ENABLED(NEOPIXEL2_SEPARATE)
|
||||||
|
|
||||||
#if ENABLED(NEO2_COLOR_PRESETS)
|
#if ENABLED(NEO2_COLOR_PRESETS)
|
||||||
const LEDColor LEDLights2::defaultLEDColor = MakeLEDColor(
|
const LEDColor LEDLights2::defaultLEDColor = LEDColor(
|
||||||
NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE,
|
LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE
|
||||||
NEO2_USER_PRESET_WHITE, NEO2_USER_PRESET_BRIGHTNESS
|
OPTARG(HAS_WHITE_LED2, LED_USER_PRESET_WHITE)
|
||||||
|
OPTARG(NEOPIXEL_LED, LED_USER_PRESET_BRIGHTNESS)
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -188,7 +191,7 @@ void LEDLights::set_color(const LEDColor &incol
|
|||||||
void LEDLights2::set_color(const LEDColor &incol) {
|
void LEDLights2::set_color(const LEDColor &incol) {
|
||||||
const uint32_t neocolor = LEDColorWhite() == incol
|
const uint32_t neocolor = LEDColorWhite() == incol
|
||||||
? neo2.Color(NEO2_WHITE)
|
? neo2.Color(NEO2_WHITE)
|
||||||
: neo2.Color(incol.r, incol.g, incol.b, incol.w);
|
: neo2.Color(incol.r, incol.g, incol.b OPTARG(HAS_WHITE_LED2, incol.w));
|
||||||
neo2.set_brightness(incol.i);
|
neo2.set_brightness(incol.i);
|
||||||
neo2.set_color(neocolor);
|
neo2.set_color(neocolor);
|
||||||
|
|
||||||
|
@ -29,13 +29,15 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if ENABLED(NEOPIXEL_LED)
|
// A white component can be passed
|
||||||
#include "neopixel.h"
|
#if EITHER(RGBW_LED, PCA9632_RGBW)
|
||||||
|
#define HAS_WHITE_LED 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// A white component can be passed
|
#if ENABLED(NEOPIXEL_LED)
|
||||||
#if ANY(RGBW_LED, NEOPIXEL_LED, PCA9632_RGBW)
|
#define _NEOPIXEL_INCLUDE_
|
||||||
#define HAS_WHITE_LED 1
|
#include "neopixel.h"
|
||||||
|
#undef _NEOPIXEL_INCLUDE_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,9 +86,8 @@ typedef struct LEDColor {
|
|||||||
} LEDColor;
|
} LEDColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color helpers and presets
|
* Color presets
|
||||||
*/
|
*/
|
||||||
#define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B OPTARG(HAS_WHITE_LED, W) OPTARG(NEOPIXEL_LED, I))
|
|
||||||
|
|
||||||
#define LEDColorOff() LEDColor( 0, 0, 0)
|
#define LEDColorOff() LEDColor( 0, 0, 0)
|
||||||
#define LEDColorRed() LEDColor(255, 0, 0)
|
#define LEDColorRed() LEDColor(255, 0, 0)
|
||||||
@ -114,15 +115,15 @@ public:
|
|||||||
static void setup(); // init()
|
static void setup(); // init()
|
||||||
|
|
||||||
static void set_color(const LEDColor &color
|
static void set_color(const LEDColor &color
|
||||||
OPTARG(NEOPIXEL_LED, bool isSequence=false)
|
OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false)
|
||||||
);
|
);
|
||||||
|
|
||||||
static inline void set_color(uint8_t r, uint8_t g, uint8_t b
|
static inline void set_color(uint8_t r, uint8_t g, uint8_t b
|
||||||
OPTARG(HAS_WHITE_LED, uint8_t w=0)
|
OPTARG(HAS_WHITE_LED, uint8_t w=0)
|
||||||
OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS)
|
OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS)
|
||||||
OPTARG(NEOPIXEL_LED, bool isSequence=false)
|
OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false)
|
||||||
) {
|
) {
|
||||||
set_color(MakeLEDColor(r, g, b, w, i) OPTARG(NEOPIXEL_LED, isSequence));
|
set_color(LEDColor(r, g, b OPTARG(HAS_WHITE_LED, w) OPTARG(NEOPIXEL_LED, i)) OPTARG(NEOPIXEL_IS_SEQUENTIAL, isSequence));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void set_off() { set_color(LEDColorOff()); }
|
static inline void set_off() { set_color(LEDColorOff()); }
|
||||||
@ -180,8 +181,14 @@ extern LEDLights leds;
|
|||||||
|
|
||||||
static void set_color(const LEDColor &color);
|
static void set_color(const LEDColor &color);
|
||||||
|
|
||||||
inline void set_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w=0, uint8_t i=NEOPIXEL2_BRIGHTNESS) {
|
static inline void set_color(uint8_t r, uint8_t g, uint8_t b
|
||||||
set_color(MakeLEDColor(r, g, b, w, i));
|
OPTARG(HAS_WHITE_LED, uint8_t w=0)
|
||||||
|
OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS)
|
||||||
|
) {
|
||||||
|
set_color(LEDColor(r, g, b
|
||||||
|
OPTARG(HAS_WHITE_LED, w)
|
||||||
|
OPTARG(NEOPIXEL_LED, i)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void set_off() { set_color(LEDColorOff()); }
|
static inline void set_off() { set_color(LEDColorOff()); }
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#if ENABLED(NEOPIXEL_LED)
|
#if ENABLED(NEOPIXEL_LED)
|
||||||
|
|
||||||
#include "neopixel.h"
|
#include "leds.h"
|
||||||
|
|
||||||
#if EITHER(NEOPIXEL_STARTUP_TEST, NEOPIXEL2_STARTUP_TEST)
|
#if EITHER(NEOPIXEL_STARTUP_TEST, NEOPIXEL2_STARTUP_TEST)
|
||||||
#include "../../core/utility.h"
|
#include "../../core/utility.h"
|
||||||
@ -37,17 +37,21 @@
|
|||||||
Marlin_NeoPixel neo;
|
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 CONJOINED_NEOPIXEL
|
#if CONJOINED_NEOPIXEL
|
||||||
, Marlin_NeoPixel::adaneo2(NEOPIXEL_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE + NEO_KHZ800)
|
Adafruit_NeoPixel Marlin_NeoPixel::adaneo2(NEOPIXEL_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE + NEO_KHZ800);
|
||||||
#endif
|
#endif
|
||||||
;
|
|
||||||
|
|
||||||
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
#ifdef NEOPIXEL_BKGD_INDEX_FIRST
|
||||||
|
|
||||||
void Marlin_NeoPixel::set_color_background() {
|
void Marlin_NeoPixel::set_background_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
|
||||||
uint8_t background_color[4] = NEOPIXEL_BKGD_COLOR;
|
for (int background_led = NEOPIXEL_BKGD_INDEX_FIRST; background_led <= NEOPIXEL_BKGD_INDEX_LAST; background_led++)
|
||||||
set_pixel_color(NEOPIXEL_BKGD_LED_INDEX, adaneo1.Color(background_color[0], background_color[1], background_color[2], background_color[3]));
|
set_pixel_color(background_led, adaneo1.Color(r, g, b, w));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Marlin_NeoPixel::reset_background_color() {
|
||||||
|
constexpr uint8_t background_color[4] = NEOPIXEL_BKGD_COLOR;
|
||||||
|
set_background_color(background_color[0], background_color[1], background_color[2], background_color[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -59,9 +63,10 @@ void Marlin_NeoPixel::set_color(const uint32_t color) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (uint16_t i = 0; i < pixels(); ++i) {
|
for (uint16_t i = 0; i < pixels(); ++i) {
|
||||||
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
#ifdef NEOPIXEL_BKGD_INDEX_FIRST
|
||||||
if (i == NEOPIXEL_BKGD_LED_INDEX && TERN(NEOPIXEL_BKGD_ALWAYS_ON, true, color != 0x000000)) {
|
if (i == NEOPIXEL_BKGD_INDEX_FIRST && TERN(NEOPIXEL_BKGD_ALWAYS_ON, true, color != 0x000000)) {
|
||||||
set_color_background();
|
reset_background_color();
|
||||||
|
i += NEOPIXEL_BKGD_INDEX_LAST - (NEOPIXEL_BKGD_INDEX_FIRST);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -90,36 +95,23 @@ void Marlin_NeoPixel::init() {
|
|||||||
safe_delay(500);
|
safe_delay(500);
|
||||||
set_color_startup(adaneo1.Color(0, 0, 255, 0)); // blue
|
set_color_startup(adaneo1.Color(0, 0, 255, 0)); // blue
|
||||||
safe_delay(500);
|
safe_delay(500);
|
||||||
|
#if HAS_WHITE_LED
|
||||||
|
set_color_startup(adaneo1.Color(0, 0, 0, 255)); // white
|
||||||
|
safe_delay(500);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
#ifdef NEOPIXEL_BKGD_INDEX_FIRST
|
||||||
set_color_background();
|
reset_background_color();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(LED_USER_PRESET_STARTUP)
|
set_color(adaneo1.Color
|
||||||
set_color(adaneo1.Color(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE));
|
TERN(LED_USER_PRESET_STARTUP,
|
||||||
#else
|
(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE),
|
||||||
set_color(adaneo1.Color(0, 0, 0, 0));
|
(0, 0, 0, 0))
|
||||||
#endif
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
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_color(color);
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
static uint16_t nextLed = 0;
|
|
||||||
set_pixel_color(nextLed, color);
|
|
||||||
show();
|
|
||||||
if (++nextLed >= pixels()) nextLed = 0;
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(NEOPIXEL2_SEPARATE)
|
#if ENABLED(NEOPIXEL2_SEPARATE)
|
||||||
|
|
||||||
Marlin_NeoPixel2 neo2;
|
Marlin_NeoPixel2 neo2;
|
||||||
@ -158,13 +150,17 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint
|
|||||||
safe_delay(500);
|
safe_delay(500);
|
||||||
set_color_startup(adaneo.Color(0, 0, 255, 0)); // blue
|
set_color_startup(adaneo.Color(0, 0, 255, 0)); // blue
|
||||||
safe_delay(500);
|
safe_delay(500);
|
||||||
|
#if HAS_WHITE_LED2
|
||||||
|
set_color_startup(adaneo.Color(0, 0, 0, 255)); // white
|
||||||
|
safe_delay(500);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(NEO2_USER_PRESET_STARTUP)
|
set_color(adaneo.Color
|
||||||
set_color(adaneo.Color(NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, NEO2_USER_PRESET_WHITE));
|
TERN(NEO2_USER_PRESET_STARTUP,
|
||||||
#else
|
(NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, NEO2_USER_PRESET_WHITE),
|
||||||
set_color(adaneo.Color(0, 0, 0, 0));
|
(0, 0, 0, 0))
|
||||||
#endif
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // NEOPIXEL2_SEPARATE
|
#endif // NEOPIXEL2_SEPARATE
|
||||||
|
@ -25,6 +25,10 @@
|
|||||||
* NeoPixel support
|
* NeoPixel support
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _NEOPIXEL_INCLUDE_
|
||||||
|
#error "Always include 'leds.h' and not 'neopixel.h' directly."
|
||||||
|
#endif
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
// Includes
|
// Includes
|
||||||
// ------------------------
|
// ------------------------
|
||||||
@ -38,6 +42,18 @@
|
|||||||
// Defines
|
// Defines
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
|
#define _NEO_IS_RGB(N) (N == NEO_RGB || N == NEO_RBG || N == NEO_GRB || N == NEO_GBR || N == NEO_BRG || N == NEO_BGR)
|
||||||
|
|
||||||
|
#if !_NEO_IS_RGB(NEOPIXEL_TYPE)
|
||||||
|
#define HAS_WHITE_LED 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAS_WHITE_LED
|
||||||
|
#define NEO_WHITE 0, 0, 0, 255
|
||||||
|
#else
|
||||||
|
#define NEO_WHITE 255, 255, 255
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE && DISABLED(NEOPIXEL2_SEPARATE)
|
#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE && DISABLED(NEOPIXEL2_SEPARATE)
|
||||||
#define MULTIPLE_NEOPIXEL_TYPES 1
|
#define MULTIPLE_NEOPIXEL_TYPES 1
|
||||||
#endif
|
#endif
|
||||||
@ -46,29 +62,16 @@
|
|||||||
#define CONJOINED_NEOPIXEL 1
|
#define CONJOINED_NEOPIXEL 1
|
||||||
#endif
|
#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
|
|
||||||
#define NEOPIXEL_IS_RGB 1
|
|
||||||
#else
|
|
||||||
#define NEOPIXEL_IS_RGBW 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if NEOPIXEL_IS_RGB
|
|
||||||
#define NEO_WHITE 255, 255, 255, 0
|
|
||||||
#else
|
|
||||||
#define NEO_WHITE 0, 0, 0, 255
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
class Marlin_NeoPixel {
|
class Marlin_NeoPixel {
|
||||||
private:
|
private:
|
||||||
static Adafruit_NeoPixel adaneo1
|
static Adafruit_NeoPixel adaneo1;
|
||||||
#if CONJOINED_NEOPIXEL
|
#if CONJOINED_NEOPIXEL
|
||||||
, adaneo2
|
static Adafruit_NeoPixel adaneo2;
|
||||||
#endif
|
#endif
|
||||||
;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static int8_t neoindex;
|
static int8_t neoindex;
|
||||||
@ -78,8 +81,9 @@ public:
|
|||||||
|
|
||||||
static void set_color(const uint32_t c);
|
static void set_color(const uint32_t c);
|
||||||
|
|
||||||
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
#ifdef NEOPIXEL_BKGD_INDEX_FIRST
|
||||||
static void set_color_background();
|
static void set_background_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w);
|
||||||
|
static void reset_background_color();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void begin() {
|
static inline void begin() {
|
||||||
@ -93,9 +97,7 @@ public:
|
|||||||
else adaneo1.setPixelColor(n, c);
|
else adaneo1.setPixelColor(n, c);
|
||||||
#else
|
#else
|
||||||
adaneo1.setPixelColor(n, c);
|
adaneo1.setPixelColor(n, c);
|
||||||
#if MULTIPLE_NEOPIXEL_TYPES
|
TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c));
|
||||||
adaneo2.setPixelColor(n, c);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,15 +122,13 @@ public:
|
|||||||
TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
|
TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
bool set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
static inline uint16_t pixels() { TERN(NEOPIXEL2_INSERIES, return adaneo1.numPixels() * 2, return adaneo1.numPixels()); }
|
static inline uint16_t pixels() { return adaneo1.numPixels() * TERN1(NEOPIXEL2_INSERIES, 2); }
|
||||||
|
|
||||||
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) {
|
|
||||||
return adaneo1.Color(r, g, b, w);
|
static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w)) {
|
||||||
|
return adaneo1.Color(r, g, b OPTARG(HAS_WHITE_LED, w));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -137,15 +137,12 @@ extern Marlin_NeoPixel neo;
|
|||||||
// Neo pixel channel 2
|
// Neo pixel channel 2
|
||||||
#if ENABLED(NEOPIXEL2_SEPARATE)
|
#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
|
#if _NEO_IS_RGB(NEOPIXEL2_TYPE)
|
||||||
#define NEOPIXEL2_IS_RGB 1
|
#define NEOPIXEL2_IS_RGB 1
|
||||||
|
#define NEO2_WHITE 255, 255, 255
|
||||||
#else
|
#else
|
||||||
#define NEOPIXEL2_IS_RGBW 1
|
#define NEOPIXEL2_IS_RGBW 1
|
||||||
#endif
|
#define HAS_WHITE_LED2 1 // A white component can be passed for NEOPIXEL2
|
||||||
|
|
||||||
#if NEOPIXEL2_IS_RGB
|
|
||||||
#define NEO2_WHITE 255, 255, 255, 0
|
|
||||||
#else
|
|
||||||
#define NEO2_WHITE 0, 0, 0, 255
|
#define NEO2_WHITE 0, 0, 0, 255
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -172,11 +169,13 @@ extern Marlin_NeoPixel neo;
|
|||||||
// Accessors
|
// Accessors
|
||||||
static inline uint16_t pixels() { return adaneo.numPixels();}
|
static inline uint16_t pixels() { return adaneo.numPixels();}
|
||||||
static inline uint8_t brightness() { return adaneo.getBrightness(); }
|
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) {
|
static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED2, uint8_t w)) {
|
||||||
return adaneo.Color(r, g, b, w);
|
return adaneo.Color(r, g, b OPTARG(HAS_WHITE_LED2, w));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Marlin_NeoPixel2 neo2;
|
extern Marlin_NeoPixel2 neo2;
|
||||||
|
|
||||||
#endif // NEOPIXEL2_SEPARATE
|
#endif // NEOPIXEL2_SEPARATE
|
||||||
|
|
||||||
|
#undef _NEO_IS_RGB
|
||||||
|
@ -45,12 +45,10 @@ PrinterEventLEDs printerEventLEDs;
|
|||||||
return (uint8_t)map(constrain(current, start, target), start, target, 0, 255);
|
return (uint8_t)map(constrain(current, start, target), start, target, 0, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void pel_set_rgb(const uint8_t r, const uint8_t g, const uint8_t b) {
|
inline void pel_set_rgb(const uint8_t r, const uint8_t g, const uint8_t b OPTARG(HAS_WHITE_LED, const uint8_t w=0)) {
|
||||||
leds.set_color(
|
leds.set_color(
|
||||||
MakeLEDColor(r, g, b, 0, neo.brightness())
|
LEDColor(r, g, b OPTARG(HAS_WHITE_LED, w) OPTARG(NEOPIXEL_LED, neo.brightness()))
|
||||||
#if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
|
OPTARG(NEOPIXEL_IS_SEQUENTIAL, true)
|
||||||
, true
|
|
||||||
#endif
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,12 +66,12 @@ void GcodeSuite::M150() {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const LEDColor color = MakeLEDColor(
|
const LEDColor color = LEDColor(
|
||||||
parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
|
parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
|
||||||
parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
|
parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
|
||||||
parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
|
parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0
|
||||||
parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0,
|
OPTARG(HAS_WHITE_LED, parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0)
|
||||||
parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : brightness
|
OPTARG(NEOPIXEL_LED, parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : brightness)
|
||||||
);
|
);
|
||||||
|
|
||||||
#if ENABLED(NEOPIXEL2_SEPARATE)
|
#if ENABLED(NEOPIXEL2_SEPARATE)
|
||||||
|
@ -1303,3 +1303,10 @@
|
|||||||
#else
|
#else
|
||||||
#define COORDINATE_OKAY(N,L,H) true
|
#define COORDINATE_OKAY(N,L,H) true
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LED Backlight INDEX END
|
||||||
|
*/
|
||||||
|
#if defined(NEOPIXEL_BKGD_INDEX_FIRST) && !defined(NEOPIXEL_BKGD_INDEX_LAST)
|
||||||
|
#define NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_INDEX_FIRST
|
||||||
|
#endif
|
||||||
|
@ -562,6 +562,8 @@
|
|||||||
#error "CUSTOM_USER_MENUS has been replaced by CUSTOM_MENU_MAIN and CUSTOM_MENU_CONFIG."
|
#error "CUSTOM_USER_MENUS has been replaced by CUSTOM_MENU_MAIN and CUSTOM_MENU_CONFIG."
|
||||||
#elif defined(MKS_LCD12864)
|
#elif defined(MKS_LCD12864)
|
||||||
#error "MKS_LCD12864 is now MKS_LCD12864A or MKS_LCD12864B."
|
#error "MKS_LCD12864 is now MKS_LCD12864A or MKS_LCD12864B."
|
||||||
|
#elif defined(NEOPIXEL_BKGD_LED_INDEX)
|
||||||
|
#error "NEOPIXEL_BKGD_LED_INDEX is now NEOPIXEL_BKGD_INDEX_FIRST."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -636,8 +636,8 @@ void MarlinUI::kill_screen(PGM_P lcd_error, PGM_P lcd_component) {
|
|||||||
// RED ALERT. RED ALERT.
|
// RED ALERT. RED ALERT.
|
||||||
#ifdef LED_BACKLIGHT_TIMEOUT
|
#ifdef LED_BACKLIGHT_TIMEOUT
|
||||||
leds.set_color(LEDColorRed());
|
leds.set_color(LEDColorRed());
|
||||||
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
#ifdef NEOPIXEL_BKGD_INDEX_FIRST
|
||||||
neo.set_pixel_color(NEOPIXEL_BKGD_LED_INDEX, 255, 0, 0, 0);
|
neo.set_background_color(255, 0, 0, 0);
|
||||||
neo.show();
|
neo.show();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -84,18 +84,20 @@
|
|||||||
EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true);
|
EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true);
|
||||||
EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true);
|
EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true);
|
||||||
EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true);
|
EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true);
|
||||||
#if EITHER(RGBW_LED, NEOPIXEL_LED)
|
#if HAS_WHITE_LED
|
||||||
EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds.color.w, 0, 255, leds.update, true);
|
EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds.color.w, 0, 255, leds.update, true);
|
||||||
#if ENABLED(NEOPIXEL_LED)
|
#endif
|
||||||
EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true);
|
#if ENABLED(NEOPIXEL_LED)
|
||||||
#endif
|
EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true);
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(NEOPIXEL2_SEPARATE)
|
#if ENABLED(NEOPIXEL2_SEPARATE)
|
||||||
STATIC_ITEM_N(MSG_LED_CHANNEL_N, 2, SS_DEFAULT|SS_INVERT);
|
STATIC_ITEM_N(MSG_LED_CHANNEL_N, 2, SS_DEFAULT|SS_INVERT);
|
||||||
EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true);
|
EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true);
|
||||||
EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true);
|
EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true);
|
||||||
EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true);
|
EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true);
|
||||||
EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds2.color.w, 0, 255, leds2.update, true);
|
#if HAS_WHITE_LED2
|
||||||
|
EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds2.color.w, 0, 255, leds2.update, true);
|
||||||
|
#endif
|
||||||
EDIT_ITEM(uint8, MSG_NEO2_BRIGHTNESS, &leds2.color.i, 0, 255, leds2.update, true);
|
EDIT_ITEM(uint8, MSG_NEO2_BRIGHTNESS, &leds2.color.i, 0, 255, leds2.update, true);
|
||||||
#endif
|
#endif
|
||||||
END_MENU();
|
END_MENU();
|
||||||
|
@ -18,7 +18,7 @@ opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \
|
|||||||
ASSISTED_TRAMMING ASSISTED_TRAMMING_WIZARD REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \
|
ASSISTED_TRAMMING ASSISTED_TRAMMING_WIZARD REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \
|
||||||
EEPROM_SETTINGS SDSUPPORT BINARY_FILE_TRANSFER \
|
EEPROM_SETTINGS SDSUPPORT BINARY_FILE_TRANSFER \
|
||||||
BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \
|
BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \
|
||||||
NEOPIXEL_LED CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_USE_RGB_LED CASE_LIGHT_MENU \
|
NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_USE_RGB_LED CASE_LIGHT_MENU \
|
||||||
NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_DISTANCE_MM FILAMENT_RUNOUT_SENSOR \
|
NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_DISTANCE_MM FILAMENT_RUNOUT_SENSOR \
|
||||||
AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
|
AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
|
||||||
SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE CALIBRATION_GCODE \
|
SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE CALIBRATION_GCODE \
|
||||||
|
@ -14,8 +14,10 @@ set -e
|
|||||||
#exec_test $1 $2 "Default Configuration" "$3"
|
#exec_test $1 $2 "Default Configuration" "$3"
|
||||||
|
|
||||||
restore_configs
|
restore_configs
|
||||||
opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB NEOPIXEL_PIN P1_16 SERIAL_PORT_3 3
|
opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB SERIAL_PORT_3 3 \
|
||||||
opt_enable VIKI2 SDSUPPORT SDCARD_READONLY SERIAL_PORT_2 NEOPIXEL_LED
|
NEOPIXEL_TYPE NEO_GRB RGB_LED_R_PIN P2_12 RGB_LED_G_PIN P1_23 RGB_LED_B_PIN P1_22 RGB_LED_W_PIN P1_24
|
||||||
|
opt_enable FYSETC_MINI_12864_2_1 SDSUPPORT SDCARD_READONLY SERIAL_PORT_2 RGBW_LED \
|
||||||
|
NEOPIXEL_LED NEOPIXEL_IS_SEQUENTIAL NEOPIXEL_STARTUP_TEST NEOPIXEL_BKGD_INDEX_FIRST NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_COLOR NEOPIXEL_BKGD_ALWAYS_ON
|
||||||
exec_test $1 $2 "ReARM EFB VIKI2, SDSUPPORT, 2 Serial ports (USB CDC + UART0), NeoPixel" "$3"
|
exec_test $1 $2 "ReARM EFB VIKI2, SDSUPPORT, 2 Serial ports (USB CDC + UART0), NeoPixel" "$3"
|
||||||
|
|
||||||
#restore_configs
|
#restore_configs
|
||||||
|
@ -22,7 +22,7 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P
|
|||||||
PREHEAT_BEFORE_PROBING PROBING_HEATERS_OFF PROBING_FANS_OFF PROBING_STEPPERS_OFF WAIT_FOR_BED_HEATER \
|
PREHEAT_BEFORE_PROBING PROBING_HEATERS_OFF PROBING_FANS_OFF PROBING_STEPPERS_OFF WAIT_FOR_BED_HEATER \
|
||||||
EEPROM_SETTINGS SDSUPPORT SD_REPRINT_LAST_SELECTED_FILE BINARY_FILE_TRANSFER \
|
EEPROM_SETTINGS SDSUPPORT SD_REPRINT_LAST_SELECTED_FILE BINARY_FILE_TRANSFER \
|
||||||
BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \
|
BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \
|
||||||
NEOPIXEL_LED CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_MENU \
|
NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_MENU \
|
||||||
PID_PARAMS_PER_HOTEND PID_AUTOTUNE_MENU PID_EDIT_MENU LCD_SHOW_E_TOTAL \
|
PID_PARAMS_PER_HOTEND PID_AUTOTUNE_MENU PID_EDIT_MENU LCD_SHOW_E_TOTAL \
|
||||||
PRINTCOUNTER SERVICE_NAME_1 SERVICE_INTERVAL_1 LEVEL_BED_CORNERS LEVEL_CENTER_TOO \
|
PRINTCOUNTER SERVICE_NAME_1 SERVICE_INTERVAL_1 LEVEL_BED_CORNERS LEVEL_CENTER_TOO \
|
||||||
NOZZLE_PARK_FEATURE FILAMENT_RUNOUT_SENSOR FILAMENT_RUNOUT_DISTANCE_MM \
|
NOZZLE_PARK_FEATURE FILAMENT_RUNOUT_SENSOR FILAMENT_RUNOUT_DISTANCE_MM \
|
||||||
|
Loading…
Reference in New Issue
Block a user