Minor cleanup w/r/t LEDs
This commit is contained in:
		@@ -2363,7 +2363,7 @@
 | 
			
		||||
  //#define NEOPIXEL2_TYPE NEOPIXEL_TYPE
 | 
			
		||||
  //#define NEOPIXEL2_PIN    5
 | 
			
		||||
  //#define NEOPIXEL2_INSERIES     // Default behavior is NeoPixel 2 in parallel
 | 
			
		||||
  #define NEOPIXEL_PIXELS 30       // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used
 | 
			
		||||
  #define NEOPIXEL_PIXELS 30       // Number of LEDs in the strip, larger of 2 strips if 2 NeoPixel strips are used
 | 
			
		||||
  #define NEOPIXEL_IS_SEQUENTIAL   // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once.
 | 
			
		||||
  #define NEOPIXEL_BRIGHTNESS 127  // Initial brightness (0-255)
 | 
			
		||||
  //#define NEOPIXEL_STARTUP_TEST  // Cycle through colors at startup
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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/>.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -155,7 +155,7 @@
 | 
			
		||||
 * M141 - Set heated chamber target temp. S<temp> (Requires a chamber heater)
 | 
			
		||||
 * M145 - Set heatup values for materials on the LCD. H<hotend> B<bed> F<fan speed> for S<material> (0=PLA, 1=ABS)
 | 
			
		||||
 * M149 - Set temperature units. (Requires TEMPERATURE_UNITS_SUPPORT)
 | 
			
		||||
 * M150 - Set Status LED Color as R<red> U<green> B<blue> P<bright>. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632).
 | 
			
		||||
 * M150 - Set Status LED Color as R<red> U<green> B<blue> W<white> P<bright>. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632).
 | 
			
		||||
 * M155 - Auto-report temperatures with interval of S<seconds>. (Requires AUTO_REPORT_TEMPERATURES)
 | 
			
		||||
 * M163 - Set a single proportion for a mixing extruder. (Requires MIXING_EXTRUDER)
 | 
			
		||||
 * M164 - Commit the mix and save to a virtual tool (current, or as specified by 'S'). (Requires MIXING_EXTRUDER)
 | 
			
		||||
 
 | 
			
		||||
@@ -34,18 +34,19 @@
 | 
			
		||||
  #include "../../feature/leds/leds.h"
 | 
			
		||||
 | 
			
		||||
  #if ENABLED(LED_COLOR_PRESETS)
 | 
			
		||||
 | 
			
		||||
    void menu_led_presets() {
 | 
			
		||||
      START_MENU();
 | 
			
		||||
      #if LCD_HEIGHT > 2
 | 
			
		||||
        STATIC_ITEM(MSG_LED_PRESETS, SS_DEFAULT|SS_INVERT);
 | 
			
		||||
      #endif
 | 
			
		||||
      BACK_ITEM(MSG_LED_CONTROL);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_WHITE, leds.set_white);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_RED, leds.set_red);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_WHITE,  leds.set_white);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_RED,    leds.set_red);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds.set_orange);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_YELLOW,leds.set_yellow);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_GREEN, leds.set_green);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_BLUE, leds.set_blue);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds.set_yellow);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_GREEN,  leds.set_green);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_BLUE,   leds.set_blue);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds.set_indigo);
 | 
			
		||||
      ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds.set_violet);
 | 
			
		||||
      END_MENU();
 | 
			
		||||
@@ -83,11 +84,10 @@
 | 
			
		||||
  #endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void menu_led() {
 | 
			
		||||
  START_MENU();
 | 
			
		||||
  BACK_ITEM(MSG_MAIN);
 | 
			
		||||
 | 
			
		||||
  #if ENABLED(LED_CONTROL_MENU)
 | 
			
		||||
    bool led_on = leds.lights_on;
 | 
			
		||||
    EDIT_ITEM(bool, MSG_LEDS, &led_on, leds.toggle);
 | 
			
		||||
@@ -97,6 +97,7 @@ void menu_led() {
 | 
			
		||||
    #endif
 | 
			
		||||
    SUBMENU(MSG_CUSTOM_LEDS, menu_led_custom);
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  //
 | 
			
		||||
  // Set Case light on/off/brightness
 | 
			
		||||
  //
 | 
			
		||||
 
 | 
			
		||||
@@ -81,7 +81,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
 | 
			
		||||
  #endif
 | 
			
		||||
  void MarlinUI::buzz(const long duration, const uint16_t freq) {
 | 
			
		||||
    #if ENABLED(PCA9632_BUZZER)
 | 
			
		||||
      pca9632_buzz(duration, freq);
 | 
			
		||||
      PCA9632_buzz(duration, freq);
 | 
			
		||||
    #elif USE_BEEPER
 | 
			
		||||
      buzzer.tone(duration, freq);
 | 
			
		||||
    #endif
 | 
			
		||||
 
 | 
			
		||||
@@ -113,7 +113,7 @@
 | 
			
		||||
#define FAN1_PIN                            PA8   // FAN  (fan0 on board) e0 cool fan
 | 
			
		||||
#define FAN2_PIN                            PB9   // FAN  (fan1 on board) controller cool fan
 | 
			
		||||
 | 
			
		||||
// One neopixel onboard and a connector for other neopixels
 | 
			
		||||
// One NeoPixel onboard and a connector for other NeoPixels
 | 
			
		||||
#define NEOPIXEL_PIN                        PC7   // The NEOPIXEL LED driving pin
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user