Minor cleanup w/r/t LEDs
This commit is contained in:
@ -129,12 +129,9 @@ void LEDLights::set_color(const LEDColor &incol
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(PCA9632)
|
||||
// Update I2C LED driver
|
||||
pca9632_set_led_color(incol);
|
||||
#endif
|
||||
|
||||
TERN_(PCA9533, PCA9533_setColor(incol.r, incol.g, incol.b));
|
||||
// Update I2C LED driver
|
||||
TERN_(PCA9632, PCA9632_set_led_color(incol));
|
||||
TERN_(PCA9533, PCA9533_set_rgb(incol.r, incol.g, incol.b));
|
||||
|
||||
#if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS)
|
||||
// Don't update the color when OFF
|
||||
|
@ -104,11 +104,7 @@ typedef struct LEDColor {
|
||||
bool operator!=(const LEDColor &right) { return !operator==(right); }
|
||||
|
||||
bool is_off() const {
|
||||
return 3 > r + g + b
|
||||
#if HAS_WHITE_LED
|
||||
+ w
|
||||
#endif
|
||||
;
|
||||
return 3 > r + g + b + TERN0(HAS_WHITE_LED, w);
|
||||
}
|
||||
} LEDColor;
|
||||
|
||||
@ -156,7 +152,7 @@ public:
|
||||
#endif
|
||||
);
|
||||
|
||||
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
|
||||
#if HAS_WHITE_LED
|
||||
, uint8_t w=0
|
||||
#if ENABLED(NEOPIXEL_LED)
|
||||
|
@ -53,9 +53,9 @@ Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIX
|
||||
#endif
|
||||
|
||||
void Marlin_NeoPixel::set_color(const uint32_t color) {
|
||||
if (get_neo_index() >= 0) {
|
||||
set_pixel_color(get_neo_index(), color);
|
||||
set_neo_index(-1);
|
||||
if (neoindex >= 0) {
|
||||
set_pixel_color(neoindex, color);
|
||||
neoindex = -1;
|
||||
}
|
||||
else {
|
||||
for (uint16_t i = 0; i < pixels(); ++i) {
|
||||
@ -78,18 +78,17 @@ void Marlin_NeoPixel::set_color_startup(const uint32_t color) {
|
||||
}
|
||||
|
||||
void Marlin_NeoPixel::init() {
|
||||
set_neo_index(-1); // -1 .. NEOPIXEL_PIXELS-1 range
|
||||
neoindex = -1; // -1 .. NEOPIXEL_PIXELS-1 range
|
||||
set_brightness(NEOPIXEL_BRIGHTNESS); // 0 .. 255 range
|
||||
begin();
|
||||
show(); // initialize to all off
|
||||
|
||||
#if ENABLED(NEOPIXEL_STARTUP_TEST)
|
||||
set_color_startup(adaneo1.Color(255, 0, 0, 0)); // red
|
||||
safe_delay(1000);
|
||||
safe_delay(500);
|
||||
set_color_startup(adaneo1.Color(0, 255, 0, 0)); // green
|
||||
safe_delay(1000);
|
||||
safe_delay(500);
|
||||
set_color_startup(adaneo1.Color(0, 0, 255, 0)); // blue
|
||||
safe_delay(1000);
|
||||
#endif
|
||||
|
||||
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
||||
|
@ -65,17 +65,15 @@ private:
|
||||
, adaneo2
|
||||
#endif
|
||||
;
|
||||
static int8_t neoindex;
|
||||
|
||||
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);
|
||||
|
||||
FORCE_INLINE static void set_neo_index(const int8_t neoIndex) { neoindex = neoIndex; }
|
||||
FORCE_INLINE static int8_t get_neo_index() { return neoindex; }
|
||||
|
||||
#ifdef NEOPIXEL_BKGD_LED_INDEX
|
||||
static void set_color_background();
|
||||
#endif
|
||||
|
@ -62,7 +62,7 @@ void PCA9533_setOff() {
|
||||
PCA9533_writeRegister(PCA9533_REG_SEL, 0);
|
||||
}
|
||||
|
||||
void PCA9533_setColor(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
void PCA9533_set_rgb(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
uint8_t r_pwm0 = 0; // Register data - PWM value
|
||||
uint8_t r_pwm1 = 0; // Register data - PWM value
|
||||
|
||||
|
@ -55,5 +55,5 @@
|
||||
|
||||
void PCA9533_init();
|
||||
void PCA9533_reset();
|
||||
void PCA9533_setColor(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void PCA9533_set_rgb(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void PCA9533_setOff();
|
||||
|
@ -120,7 +120,7 @@ static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const
|
||||
}
|
||||
#endif
|
||||
|
||||
void pca9632_set_led_color(const LEDColor &color) {
|
||||
void PCA9632_set_led_color(const LEDColor &color) {
|
||||
Wire.begin();
|
||||
if (!PCA_init) {
|
||||
PCA_init = 1;
|
||||
@ -138,7 +138,7 @@ void pca9632_set_led_color(const LEDColor &color) {
|
||||
|
||||
#if ENABLED(PCA9632_BUZZER)
|
||||
|
||||
void pca9632_buzz(const long, const uint16_t) {
|
||||
void PCA9632_buzz(const long, const uint16_t) {
|
||||
uint8_t data[] = PCA9632_BUZZER_DATA;
|
||||
Wire.beginTransmission(I2C_ADDRESS(PCA9632_ADDRESS));
|
||||
Wire.write(data, sizeof(data));
|
||||
|
@ -29,9 +29,9 @@
|
||||
struct LEDColor;
|
||||
typedef LEDColor LEDColor;
|
||||
|
||||
void pca9632_set_led_color(const LEDColor &color);
|
||||
void PCA9632_set_led_color(const LEDColor &color);
|
||||
|
||||
#if ENABLED(PCA9632_BUZZER)
|
||||
#include <stdint.h>
|
||||
void pca9632_buzz(const long, const uint16_t);
|
||||
void PCA9632_buzz(const long, const uint16_t);
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
Reference in New Issue
Block a user