Merge upstream changes from Marlin 2.1.1

This commit is contained in:
Stefan Kalscheuer
2022-09-03 09:23:32 +02:00
parent 626283aadb
commit 986e416c7f
1610 changed files with 73839 additions and 40857 deletions

View File

@@ -42,7 +42,7 @@
#include "pca9533.h"
#endif
#if ENABLED(CASE_LIGHT_USE_RGB_LED)
#if EITHER(CASE_LIGHT_USE_RGB_LED, CASE_LIGHT_USE_NEOPIXEL)
#include "../../feature/caselight.h"
#endif
@@ -95,6 +95,10 @@ void LEDLights::set_color(const LEDColor &incol
#endif
#endif
#if BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)
// Update brightness only if caselight is ON or switching leds off
if (caselight.on || incol.is_off())
#endif
neo.set_brightness(incol.i);
#if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
@@ -106,6 +110,10 @@ void LEDLights::set_color(const LEDColor &incol
}
#endif
#if BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)
// Update color only if caselight is ON or switching leds off
if (caselight.on || incol.is_off())
#endif
neo.set_color(neocolor);
#endif
@@ -121,11 +129,11 @@ void LEDLights::set_color(const LEDColor &incol
// This variant uses 3-4 separate pins for the RGB(W) components.
// If the pins can do PWM then their intensity will be set.
#define _UPDATE_RGBW(C,c) do { \
if (PWM_PIN(RGB_LED_##C##_PIN)) \
analogWrite(pin_t(RGB_LED_##C##_PIN), c); \
else \
WRITE(RGB_LED_##C##_PIN, c ? HIGH : LOW); \
#define _UPDATE_RGBW(C,c) do { \
if (PWM_PIN(RGB_LED_##C##_PIN)) \
hal.set_pwm_duty(pin_t(RGB_LED_##C##_PIN), c); \
else \
WRITE(RGB_LED_##C##_PIN, c ? HIGH : LOW); \
}while(0)
#define UPDATE_RGBW(C,c) _UPDATE_RGBW(C, TERN1(CASE_LIGHT_USE_RGB_LED, caselight.on) ? incol.c : 0)
UPDATE_RGBW(R,r); UPDATE_RGBW(G,g); UPDATE_RGBW(B,b);
@@ -150,7 +158,7 @@ void LEDLights::set_color(const LEDColor &incol
void LEDLights::toggle() { if (lights_on) set_off(); else update(); }
#endif
#ifdef LED_BACKLIGHT_TIMEOUT
#if LED_POWEROFF_TIMEOUT > 0
millis_t LEDLights::led_off_time; // = 0
@@ -170,9 +178,9 @@ void LEDLights::set_color(const LEDColor &incol
#if ENABLED(NEO2_COLOR_PRESETS)
const LEDColor LEDLights2::defaultLEDColor = LEDColor(
LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE
OPTARG(HAS_WHITE_LED2, LED_USER_PRESET_WHITE)
OPTARG(NEOPIXEL_LED, LED_USER_PRESET_BRIGHTNESS)
NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE
OPTARG(HAS_WHITE_LED2, NEO2_USER_PRESET_WHITE)
OPTARG(NEOPIXEL_LED, NEO2_USER_PRESET_BRIGHTNESS)
);
#endif

View File

@@ -54,6 +54,8 @@ typedef struct LEDColor {
OPTARG(NEOPIXEL_LED, i(NEOPIXEL_BRIGHTNESS))
{}
LEDColor(const LEDColor&) = default;
LEDColor(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w=0) OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS))
: r(r), g(g), b(b) OPTARG(HAS_WHITE_LED, w(w)) OPTARG(NEOPIXEL_LED, i(i)) {}
@@ -68,11 +70,6 @@ typedef struct LEDColor {
return *this;
}
LEDColor& operator=(const LEDColor &right) {
if (this != &right) memcpy(this, &right, sizeof(LEDColor));
return *this;
}
bool operator==(const LEDColor &right) {
if (this == &right) return true;
return 0 == memcmp(this, &right, sizeof(LEDColor));
@@ -118,7 +115,7 @@ public:
OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false)
);
static inline void set_color(uint8_t r, uint8_t g, uint8_t b
static void set_color(uint8_t r, uint8_t g, uint8_t b
OPTARG(HAS_WHITE_LED, uint8_t w=0)
OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS)
OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false)
@@ -126,23 +123,23 @@ public:
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_green() { set_color(LEDColorGreen()); }
static inline void set_white() { set_color(LEDColorWhite()); }
static void set_off() { set_color(LEDColorOff()); }
static void set_green() { set_color(LEDColorGreen()); }
static void set_white() { set_color(LEDColorWhite()); }
#if ENABLED(LED_COLOR_PRESETS)
static const LEDColor defaultLEDColor;
static inline void set_default() { set_color(defaultLEDColor); }
static inline void set_red() { set_color(LEDColorRed()); }
static inline void set_orange() { set_color(LEDColorOrange()); }
static inline void set_yellow() { set_color(LEDColorYellow()); }
static inline void set_blue() { set_color(LEDColorBlue()); }
static inline void set_indigo() { set_color(LEDColorIndigo()); }
static inline void set_violet() { set_color(LEDColorViolet()); }
static void set_default() { set_color(defaultLEDColor); }
static void set_red() { set_color(LEDColorRed()); }
static void set_orange() { set_color(LEDColorOrange()); }
static void set_yellow() { set_color(LEDColorYellow()); }
static void set_blue() { set_color(LEDColorBlue()); }
static void set_indigo() { set_color(LEDColorIndigo()); }
static void set_violet() { set_color(LEDColorViolet()); }
#endif
#if ENABLED(PRINTER_EVENT_LEDS)
static inline LEDColor get_color() { return lights_on ? color : LEDColorOff(); }
static LEDColor get_color() { return lights_on ? color : LEDColorOff(); }
#endif
#if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED)
@@ -154,15 +151,15 @@ public:
static void toggle(); // swap "off" with color
#endif
#if EITHER(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED)
static inline void update() { set_color(color); }
static void update() { set_color(color); }
#endif
#ifdef LED_BACKLIGHT_TIMEOUT
#if LED_POWEROFF_TIMEOUT > 0
private:
static millis_t led_off_time;
public:
static inline void reset_timeout(const millis_t &ms) {
led_off_time = ms + LED_BACKLIGHT_TIMEOUT;
static void reset_timeout(const millis_t &ms) {
led_off_time = ms + LED_POWEROFF_TIMEOUT;
if (!lights_on) update();
}
static void update_timeout(const bool power_on);
@@ -181,7 +178,7 @@ extern LEDLights leds;
static void set_color(const LEDColor &color);
static inline void set_color(uint8_t r, uint8_t g, uint8_t b
static void set_color(uint8_t r, uint8_t g, uint8_t b
OPTARG(HAS_WHITE_LED, uint8_t w=0)
OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS)
) {
@@ -191,26 +188,26 @@ extern LEDLights leds;
));
}
static inline void set_off() { set_color(LEDColorOff()); }
static inline void set_green() { set_color(LEDColorGreen()); }
static inline void set_white() { set_color(LEDColorWhite()); }
static void set_off() { set_color(LEDColorOff()); }
static void set_green() { set_color(LEDColorGreen()); }
static void set_white() { set_color(LEDColorWhite()); }
#if ENABLED(NEO2_COLOR_PRESETS)
static const LEDColor defaultLEDColor;
static inline void set_default() { set_color(defaultLEDColor); }
static inline void set_red() { set_color(LEDColorRed()); }
static inline void set_orange() { set_color(LEDColorOrange()); }
static inline void set_yellow() { set_color(LEDColorYellow()); }
static inline void set_blue() { set_color(LEDColorBlue()); }
static inline void set_indigo() { set_color(LEDColorIndigo()); }
static inline void set_violet() { set_color(LEDColorViolet()); }
static void set_default() { set_color(defaultLEDColor); }
static void set_red() { set_color(LEDColorRed()); }
static void set_orange() { set_color(LEDColorOrange()); }
static void set_yellow() { set_color(LEDColorYellow()); }
static void set_blue() { set_color(LEDColorBlue()); }
static void set_indigo() { set_color(LEDColorIndigo()); }
static void set_violet() { set_color(LEDColorViolet()); }
#endif
#if ENABLED(NEOPIXEL2_SEPARATE)
static LEDColor color; // last non-off color
static bool lights_on; // the last set color was "on"
static void toggle(); // swap "off" with color
static inline void update() { set_color(color); }
static void update() { set_color(color); }
#endif
};

View File

@@ -35,7 +35,7 @@
#endif
Marlin_NeoPixel neo;
int8_t Marlin_NeoPixel::neoindex;
pixel_index_t Marlin_NeoPixel::neoindex;
Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800);
#if CONJOINED_NEOPIXEL
@@ -44,14 +44,14 @@ Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIX
#ifdef NEOPIXEL_BKGD_INDEX_FIRST
void Marlin_NeoPixel::set_background_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
for (int background_led = NEOPIXEL_BKGD_INDEX_FIRST; background_led <= NEOPIXEL_BKGD_INDEX_LAST; background_led++)
void Marlin_NeoPixel::set_background_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w) {
for (int background_led = NEOPIXEL_BKGD_INDEX_FIRST; background_led <= NEOPIXEL_BKGD_INDEX_LAST; background_led++)
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]);
set_background_color(background_color);
}
#endif
@@ -108,7 +108,7 @@ void Marlin_NeoPixel::init() {
set_color(adaneo1.Color
TERN(LED_USER_PRESET_STARTUP,
(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE),
(0, 0, 0, 0))
(255, 255, 255, 255))
);
}
@@ -116,7 +116,7 @@ void Marlin_NeoPixel::init() {
Marlin_NeoPixel2 neo2;
int8_t Marlin_NeoPixel2::neoindex;
pixel_index_t Marlin_NeoPixel2::neoindex;
Adafruit_NeoPixel Marlin_NeoPixel2::adaneo(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE);
void Marlin_NeoPixel2::set_color(const uint32_t color) {

View File

@@ -63,7 +63,13 @@
#endif
// ------------------------
// Function prototypes
// Types
// ------------------------
typedef IF<(TERN0(NEOPIXEL_LED, NEOPIXEL_PIXELS > 127)), int16_t, int8_t>::type pixel_index_t;
// ------------------------
// Classes
// ------------------------
class Marlin_NeoPixel {
@@ -74,7 +80,7 @@ private:
#endif
public:
static int8_t neoindex;
static pixel_index_t neoindex;
static void init();
static void set_color_startup(const uint32_t c);
@@ -82,16 +88,17 @@ public:
static void set_color(const uint32_t c);
#ifdef NEOPIXEL_BKGD_INDEX_FIRST
static void set_background_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w);
static void set_background_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w);
static void set_background_color(const uint8_t (&rgbw)[4]) { set_background_color(rgbw[0], rgbw[1], rgbw[2], rgbw[3]); }
static void reset_background_color();
#endif
static inline void begin() {
static void begin() {
adaneo1.begin();
TERN_(CONJOINED_NEOPIXEL, adaneo2.begin());
}
static inline void set_pixel_color(const uint16_t n, const uint32_t c) {
static void set_pixel_color(const uint16_t n, const uint32_t c) {
#if ENABLED(NEOPIXEL2_INSERIES)
if (n >= NEOPIXEL_PIXELS) adaneo2.setPixelColor(n - (NEOPIXEL_PIXELS), c);
else adaneo1.setPixelColor(n, c);
@@ -101,12 +108,12 @@ public:
#endif
}
static inline void set_brightness(const uint8_t b) {
static void set_brightness(const uint8_t b) {
adaneo1.setBrightness(b);
TERN_(CONJOINED_NEOPIXEL, adaneo2.setBrightness(b));
}
static inline void show() {
static void show() {
// Some platforms cannot maintain PWM output when NeoPixel disables interrupts for long durations.
TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT());
adaneo1.show();
@@ -122,11 +129,18 @@ public:
}
// Accessors
static inline uint16_t pixels() { return adaneo1.numPixels() * TERN1(NEOPIXEL2_INSERIES, 2); }
static uint16_t pixels() { return adaneo1.numPixels() * TERN1(NEOPIXEL2_INSERIES, 2); }
static inline uint8_t brightness() { return adaneo1.getBrightness(); }
static uint32_t pixel_color(const uint16_t n) {
#if ENABLED(NEOPIXEL2_INSERIES)
if (n >= NEOPIXEL_PIXELS) return adaneo2.getPixelColor(n - (NEOPIXEL_PIXELS));
#endif
return adaneo1.getPixelColor(n);
}
static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w)) {
static uint8_t brightness() { return adaneo1.getBrightness(); }
static 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));
}
};
@@ -150,25 +164,26 @@ extern Marlin_NeoPixel neo;
static Adafruit_NeoPixel adaneo;
public:
static int8_t neoindex;
static pixel_index_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() {
static void begin() { adaneo.begin(); }
static void set_pixel_color(const uint16_t n, const uint32_t c) { adaneo.setPixelColor(n, c); }
static void set_brightness(const uint8_t b) { adaneo.setBrightness(b); }
static void show() {
adaneo.show();
adaneo.setPin(NEOPIXEL2_PIN);
}
// 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 OPTARG(HAS_WHITE_LED2, uint8_t w)) {
static uint16_t pixels() { return adaneo.numPixels();}
static uint32_t pixel_color(const uint16_t n) { return adaneo.getPixelColor(n); }
static uint8_t brightness() { return adaneo.getBrightness(); }
static 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 OPTARG(HAS_WHITE_LED2, w));
}
};

View File

@@ -36,32 +36,32 @@ private:
static bool leds_off_after_print;
#endif
static inline void set_done() { TERN(LED_COLOR_PRESETS, leds.set_default(), leds.set_off()); }
static void set_done() { TERN(LED_COLOR_PRESETS, leds.set_default(), leds.set_off()); }
public:
#if HAS_TEMP_HOTEND
static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
static LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
static void onHotendHeating(const celsius_t start, const celsius_t current, const celsius_t target);
#endif
#if HAS_HEATED_BED
static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
static LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
static void onBedHeating(const celsius_t start, const celsius_t current, const celsius_t target);
#endif
#if HAS_HEATED_CHAMBER
static inline LEDColor onChamberHeatingStart() { old_intensity = 127; return leds.get_color(); }
static LEDColor onChamberHeatingStart() { old_intensity = 127; return leds.get_color(); }
static void onChamberHeating(const celsius_t start, const celsius_t current, const celsius_t target);
#endif
#if HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER
static inline void onHeatingDone() { leds.set_white(); }
static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); }
static void onHeatingDone() { leds.set_white(); }
static void onPidTuningDone(LEDColor c) { leds.set_color(c); }
#endif
#if ENABLED(SDSUPPORT)
static inline void onPrintCompleted() {
static void onPrintCompleted() {
leds.set_green();
#if HAS_LEDS_OFF_FLAG
leds_off_after_print = true;
@@ -71,7 +71,7 @@ public:
#endif
}
static inline void onResumeAfterWait() {
static void onResumeAfterWait() {
#if HAS_LEDS_OFF_FLAG
if (leds_off_after_print) {
set_done();