Neopixel changes for parity with 1.1.x
This commit is contained in:
		@@ -31,15 +31,31 @@
 | 
			
		||||
#include "leds.h"
 | 
			
		||||
 | 
			
		||||
void set_led_color(
 | 
			
		||||
  const uint8_t r, const uint8_t g, const uint8_t b , const uint8_t w , const uint8_t p
 | 
			
		||||
  const uint8_t r, const uint8_t g, const uint8_t b
 | 
			
		||||
    #if ENABLED(RGBW_LED) || ENABLED(NEOPIXEL_LED)
 | 
			
		||||
      , const uint8_t w // = 0
 | 
			
		||||
      #if ENABLED(NEOPIXEL_LED)
 | 
			
		||||
        , const uint8_t p // = NEOPIXEL_BRIGHTNESS
 | 
			
		||||
        , const bool isSequence // = false
 | 
			
		||||
      #endif
 | 
			
		||||
    #endif
 | 
			
		||||
) {
 | 
			
		||||
 | 
			
		||||
  #if ENABLED(NEOPIXEL_LED)
 | 
			
		||||
    if (w == 255 || (r == 255 && g == 255 && b == 255))
 | 
			
		||||
      neopixel_set_led_color(NEO_WHITE, p);
 | 
			
		||||
    else
 | 
			
		||||
      neopixel_set_led_color(r, g, b, w, p);
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
    const uint32_t color = pixels.Color(r, g, b, w);
 | 
			
		||||
    static uint16_t nextLed = 0;
 | 
			
		||||
 | 
			
		||||
    pixels.setBrightness(p);
 | 
			
		||||
    if (!isSequence)
 | 
			
		||||
      set_neopixel_color(color);
 | 
			
		||||
    else {
 | 
			
		||||
      pixels.setPixelColor(nextLed, color);
 | 
			
		||||
      pixels.show();
 | 
			
		||||
      if (++nextLed >= pixels.numPixels()) nextLed = 0;
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  #if ENABLED(BLINKM)
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,8 @@
 | 
			
		||||
#ifndef __LEDS_H__
 | 
			
		||||
#define __LEDS_H__
 | 
			
		||||
 | 
			
		||||
#include "../../inc/MarlinConfig.h"
 | 
			
		||||
 | 
			
		||||
#if ENABLED(NEOPIXEL_LED)
 | 
			
		||||
  #include <Adafruit_NeoPixel.h>
 | 
			
		||||
  #include "neopixel.h"
 | 
			
		||||
@@ -40,14 +42,6 @@
 | 
			
		||||
  #include "pca9632.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if ENABLED(NEOPIXEL_LED) 
 | 
			
		||||
  #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 NEO_WHITE 255, 255, 255
 | 
			
		||||
  #else
 | 
			
		||||
    #define NEO_WHITE 0, 0, 0, 255
 | 
			
		||||
  #endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if ENABLED(RGB_LED) || ENABLED(BLINKM) || ENABLED(PCA9632)
 | 
			
		||||
  #define LED_WHITE 255, 255, 255
 | 
			
		||||
#elif ENABLED(RGBW_LED)
 | 
			
		||||
@@ -61,7 +55,14 @@
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void set_led_color(
 | 
			
		||||
  const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w = 0, const uint8_t p = 255
 | 
			
		||||
  const uint8_t r, const uint8_t g, const uint8_t b
 | 
			
		||||
    #if ENABLED(RGBW_LED) || ENABLED(NEOPIXEL_LED)
 | 
			
		||||
      , const uint8_t w = 0
 | 
			
		||||
      #if ENABLED(NEOPIXEL_LED)
 | 
			
		||||
        , const uint8_t p = NEOPIXEL_BRIGHTNESS
 | 
			
		||||
        , const bool isSequence = false
 | 
			
		||||
      #endif
 | 
			
		||||
    #endif
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
#endif // __LEDS_H__
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,7 @@ void set_neopixel_color(const uint32_t color) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void setup_neopixel() {
 | 
			
		||||
  SET_OUTPUT(NEOPIXEL_PIN);
 | 
			
		||||
  pixels.setBrightness(NEOPIXEL_BRIGHTNESS); // 0 - 255 range
 | 
			
		||||
  pixels.begin();
 | 
			
		||||
  pixels.show(); // initialize to all off
 | 
			
		||||
@@ -52,22 +53,7 @@ void setup_neopixel() {
 | 
			
		||||
    set_neopixel_color(pixels.Color(0, 0, 255, 0));  // blue
 | 
			
		||||
    delay(2000);
 | 
			
		||||
  #endif
 | 
			
		||||
  set_neopixel_color(pixels.Color(0, 0, 0, 255));    // white
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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) {
 | 
			
		||||
  const uint32_t color = pixels.Color(r, g, b, w);
 | 
			
		||||
  pixels.setBrightness(p);
 | 
			
		||||
  #if !ENABLED(NEOPIXEL_IS_SEQUENTIAL)
 | 
			
		||||
    set_neopixel_color(color);
 | 
			
		||||
    return false;
 | 
			
		||||
  #else
 | 
			
		||||
    static uint16_t nextLed = 0;
 | 
			
		||||
    pixels.setPixelColor(nextLed, color);
 | 
			
		||||
    pixels.show();
 | 
			
		||||
    if (++nextLed >= pixels.numPixels()) nextLed = 0;
 | 
			
		||||
    return true;
 | 
			
		||||
  #endif
 | 
			
		||||
  set_neopixel_color(pixels.Color(NEO_WHITE));       // white
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif // NEOPIXEL_LED
 | 
			
		||||
 
 | 
			
		||||
@@ -27,11 +27,22 @@
 | 
			
		||||
#ifndef __NEOPIXEL_H__
 | 
			
		||||
#define __NEOPIXEL_H__
 | 
			
		||||
 | 
			
		||||
#include "../../inc/MarlinConfig.h"
 | 
			
		||||
 | 
			
		||||
#include <Adafruit_NeoPixel.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
#define NEOPIXEL_IS_RGB  (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_RGBW !NEOPIXEL_IS_RGB
 | 
			
		||||
 | 
			
		||||
#if NEOPIXEL_IS_RGB
 | 
			
		||||
  #define NEO_WHITE 255, 255, 255
 | 
			
		||||
#else
 | 
			
		||||
  #define NEO_WHITE 0, 0, 0, 255
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void setup_neopixel();
 | 
			
		||||
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);
 | 
			
		||||
void set_neopixel_color(const uint32_t color);
 | 
			
		||||
 | 
			
		||||
extern Adafruit_NeoPixel pixels;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user