Neopixel background LED option (#14025)
This commit is contained in:
		@@ -89,6 +89,9 @@ void LEDLights::set_color(const LEDColor &incol
 | 
			
		||||
                            : pixels.Color(incol.r, incol.g, incol.b, incol.w);
 | 
			
		||||
    static uint16_t nextLed = 0;
 | 
			
		||||
 | 
			
		||||
    #ifdef NEOPIXEL_BKGD_LED_INDEX
 | 
			
		||||
      if (NEOPIXEL_BKGD_LED_INDEX == nextLed) { nextLed++; return; }
 | 
			
		||||
    #endif
 | 
			
		||||
    pixels.setBrightness(incol.i);
 | 
			
		||||
    if (!isSequence)
 | 
			
		||||
      set_neopixel_color(neocolor);
 | 
			
		||||
 
 | 
			
		||||
@@ -37,11 +37,29 @@
 | 
			
		||||
Adafruit_NeoPixel pixels(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800);
 | 
			
		||||
 | 
			
		||||
void set_neopixel_color(const uint32_t color) {
 | 
			
		||||
  for (uint16_t i = 0; i < pixels.numPixels(); ++i) {
 | 
			
		||||
    #ifdef NEOPIXEL_BKGD_LED_INDEX
 | 
			
		||||
      if (NEOPIXEL_BKGD_LED_INDEX == i) i++;
 | 
			
		||||
    #endif
 | 
			
		||||
    pixels.setPixelColor(i, color);
 | 
			
		||||
  }
 | 
			
		||||
  pixels.show();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void set_neopixel_color_startup(const uint32_t color) {
 | 
			
		||||
  for (uint16_t i = 0; i < pixels.numPixels(); ++i)
 | 
			
		||||
    pixels.setPixelColor(i, color);
 | 
			
		||||
  pixels.show();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef NEOPIXEL_BKGD_LED_INDEX
 | 
			
		||||
  void set_neopixel_color_background() {
 | 
			
		||||
    uint8_t background_color[4] = NEOPIXEL_BKGD_COLOR;
 | 
			
		||||
    pixels.setPixelColor(NEOPIXEL_BKGD_LED_INDEX, pixels.Color(background_color[0], background_color[1], background_color[2], background_color[3]));
 | 
			
		||||
    pixels.show();
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void setup_neopixel() {
 | 
			
		||||
  SET_OUTPUT(NEOPIXEL_PIN);
 | 
			
		||||
  pixels.setBrightness(NEOPIXEL_BRIGHTNESS); // 0 - 255 range
 | 
			
		||||
@@ -50,14 +68,18 @@ void setup_neopixel() {
 | 
			
		||||
 | 
			
		||||
  #if ENABLED(NEOPIXEL_STARTUP_TEST)
 | 
			
		||||
    safe_delay(1000);
 | 
			
		||||
    set_neopixel_color(pixels.Color(255, 0, 0, 0));  // red
 | 
			
		||||
    set_neopixel_color_startup(pixels.Color(255, 0, 0, 0));  // red
 | 
			
		||||
    safe_delay(1000);
 | 
			
		||||
    set_neopixel_color(pixels.Color(0, 255, 0, 0));  // green
 | 
			
		||||
    set_neopixel_color_startup(pixels.Color(0, 255, 0, 0));  // green
 | 
			
		||||
    safe_delay(1000);
 | 
			
		||||
    set_neopixel_color(pixels.Color(0, 0, 255, 0));  // blue
 | 
			
		||||
    set_neopixel_color_startup(pixels.Color(0, 0, 255, 0));  // blue
 | 
			
		||||
    safe_delay(1000);
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  #ifdef NEOPIXEL_BKGD_LED_INDEX
 | 
			
		||||
    set_neopixel_color_background();
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  #if ENABLED(LED_USER_PRESET_STARTUP)
 | 
			
		||||
    set_neopixel_color(pixels.Color(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE));
 | 
			
		||||
  #else
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user