You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With my WS2812B strips, after apply the latest FastLED, about 80% of the time using fill_solid only lights the first LED in the strips. I've tried this with two different strips and two different ESP8266 controllers.
For example, one strip has 50 leds. I setup the led array with:
CRGB leds[NUM_LEDS];
num_leds gets defined by the actual number from settings.
I’m pretty new to this stuff, but I suspect that the “fix” of adding a second FastLED.show may be a coincidence, and that the problem involved something else. I also suspect that it was not a FastLED issue, but something in your hardware or software implementation.
One thing I notice is that NUM_LEDS is capitalized when you declare CRGB leds, but it is lower case in your fill_solid function. I'm not sure exactly what you mean by
num_leds gets defined by the actual number from settings
but that's something you might want to doublecheck.
If the problem returns, I'd suggest asking for help on the reddit forum https://www.reddit.com/r/FastLED/ rather than here. And if you do, you should include your complete sketch (using https://gist.github.com or https://pastebin.com) as well as info about your hardware setup (power source, wiring, etc.). Good luck!
@4wheeljive Thank you for your input. NUM_LEDS is a preprocessor macro defined as an integer constant. It is set as the maximum number of LEDS the sketch will allow. Later, in the global variable declaration section I define num_leds (int num_leds = NUM_LEDS;'.
In setup(), num_leds is redefined based on a value that was retrieved from a config.json file. This way I can use the same sketch for multiple ESP devices that have a different number of leds attached (in this case, an ESP8266 device).
There is no reason FastLED.show() should need to be repeated. The code worked perfectly without doing so until I updated to the latest version. I hope there will be no "if the problem returns" because I've added two FastLED.show()'s everywhere where one used to be, and now fill_solid() works as expected.
#define NUM_LEDS 75 // Maximum number of LEDs
#define BRIGHTNESS 255
#define DATA_PIN 4
// #define CLOCK_PIN 22
#define TRIGGER_PIN 0 // Flash button on ESP8266
#ifndef LED_BUILTIN
#define LED_BUILTIN 2 // ESP32 DOES NOT DEFINE LED_BUILTIN
#endif
int LED = LED_BUILTIN;
char device_name[48];
char qty_leds[3];
int num_leds = NUM_LEDS;
bool shouldSaveConfig = false; // flag for saving data
#ifdef ESP32
#define ESPALEXA_ASYNC
const int buttonStateNotPressed = LOW;
const int buttonStatePressed = HIGH;
#else
const int buttonStateNotPressed = HIGH;
const int buttonStatePressed = LOW;
#endif
int lastButtonState = buttonStateNotPressed; // the current reading from the input pin
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 50; // the debounce time in ms; increase if the output flickers
unsigned long resetDelay = 3000; // the time required to press button to reset, in ms
bool rainbowActive = false;
bool rainbowBootActive = false;
unsigned long rainbowBootStart = 0;
uint8_t lastBrightness = 0;
uint32_t lastRgb = 0;
unsigned long directColorOnDelay = 400;
// Debug toggle via button (hold for 8s)
bool debugTogglePending = false;
unsigned long debugToggleStart = 0;
WiFiManager wifiManager; // global instance
WiFiServer telnetServer(23);
WiFiClient telnetClient;
Espalexa espalexa;
Ticker ticker;
CRGB leds[NUM_LEDS]; // global intialize number of LEDs on device
// Non-blocking color change state variables
bool waitingForColor = false;
unsigned long powerOnTime = 0;
bool changeColorPending = false;
uint32_t pendingRgb = 0;
uint8_t pendingBrightness = 0;
// Unified debug output to Serial and Telnet
void debugPrint(const char *fmt, ...)
{
char buf[256];
va_list args;
va_start(args, fmt);
vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
if (enableDebug)
{
Serial.print(buf);
if (telnetClient && telnetClient.connected())
{
telnetClient.print(buf);
telnetClient.print("\r");
}
}
}
/*
Callbacks and Functions
*/
void setupSpiffs()
{
// clean FS, for testing
// SPIFFS.format();
debugPrint("\nMounting FS...\n");
#ifdef ESP32
if (SPIFFS.begin(true))
#else
if (SPIFFS.begin())
#endif
{
debugPrint("Mounted file system\n");
debugPrint("[SPIFFS] Files present:\n");
#ifdef ESP32
File root = SPIFFS.open("/", "r");
File file = root.openNextFile();
while (file)
{
debugPrint(" %s\n", file.name());
file = root.openNextFile();
}
#else
Dir dir = SPIFFS.openDir("/");
while (dir.next())
{
debugPrint(" %s\n", dir.fileName().c_str());
}
#endif
if (SPIFFS.exists("/config.json"))
{
File configFile = SPIFFS.open("/config.json", "r");
if (configFile)
{
size_t size = configFile.size();
// Allocate a buffer to store contents of the file.
std::unique_ptr<char[]> buf(new char[size]);
configFile.readBytes(buf.get(), size);
DynamicJsonDocument doc(128);
DeserializationError error = deserializeJson(doc, buf.get());
if (error)
{
debugPrint("Failed to load json config, assigning default values\n");
strcpy(device_name, "New Light");
strcpy(qty_leds, "1");
}
else
{
debugPrint("Successfully parsed json config\n");
strcpy(device_name, doc["device_name"]);
if (!doc["qty_leds"])
{
strcpy(qty_leds, "1");
}
else
{
strcpy(qty_leds, doc["qty_leds"]);
}
enableDebug = doc["enableDebug"] | false;
}
configFile.close();
The new WS2812B chipset has a reset time of 280 uS, which is significantly longer than the previous spec of 50 uS. Out of an abundance of caution i'm going to increase the reset time. It's backwards compatible with the WS2812 timings.
@zackees It seems to work for the most part. However, my "rainbow mode" does not (running the Pride 2015 animation no longer works when I have Alexa change the color to lavender).
Activity
4wheeljive commentedon Aug 28, 2025
I’m pretty new to this stuff, but I suspect that the “fix” of adding a second FastLED.show may be a coincidence, and that the problem involved something else. I also suspect that it was not a FastLED issue, but something in your hardware or software implementation.
One thing I notice is that NUM_LEDS is capitalized when you declare CRGB leds, but it is lower case in your fill_solid function. I'm not sure exactly what you mean by
but that's something you might want to doublecheck.
If the problem returns, I'd suggest asking for help on the reddit forum https://www.reddit.com/r/FastLED/ rather than here. And if you do, you should include your complete sketch (using https://gist.github.com or https://pastebin.com) as well as info about your hardware setup (power source, wiring, etc.). Good luck!
mcpacific commentedon Aug 29, 2025
@4wheeljive Thank you for your input. NUM_LEDS is a preprocessor macro defined as an integer constant. It is set as the maximum number of LEDS the sketch will allow. Later, in the global variable declaration section I define num_leds (int num_leds = NUM_LEDS;'.
In setup(), num_leds is redefined based on a value that was retrieved from a config.json file. This way I can use the same sketch for multiple ESP devices that have a different number of leds attached (in this case, an ESP8266 device).
There is no reason FastLED.show() should need to be repeated. The code worked perfectly without doing so until I updated to the latest version. I hope there will be no "if the problem returns" because I've added two FastLED.show()'s everywhere where one used to be, and now fill_solid() works as expected.
I'll check out the reddit forum!
Thanks again!
zackees commentedon Sep 6, 2025
Please post the entire sketch, including the platformio.ini file. Then I can debug this.
mcpacific commentedon Sep 10, 2025
@zackees Thank you for getting back to me. Here is my sketch. I'm using Arduino IDE (not PlatformIO) so I don't have a platformio.ini file.
`/*
*/
#include <WiFiManager.h>
#include <ArduinoJson.h>
#include <WiFiClient.h>
#include <Espalexa.h>
#define FASTLED_ALLOW_INTERRUPTS 0
#include <FastLED.h>
#include <ArduinoOTA.h>
#include <Ticker.h>
#ifdef ESP32
#include <WiFi.h>
#include <WebServer.h>
#include <SPIFFS.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#else
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <FS.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#endif
bool enableDebug = false;
#define NUM_LEDS 75 // Maximum number of LEDs
#define BRIGHTNESS 255
#define DATA_PIN 4
// #define CLOCK_PIN 22
#define TRIGGER_PIN 0 // Flash button on ESP8266
#ifndef LED_BUILTIN
#define LED_BUILTIN 2 // ESP32 DOES NOT DEFINE LED_BUILTIN
#endif
int LED = LED_BUILTIN;
char device_name[48];
char qty_leds[3];
int num_leds = NUM_LEDS;
bool shouldSaveConfig = false; // flag for saving data
#ifdef ESP32
#define ESPALEXA_ASYNC
const int buttonStateNotPressed = LOW;
const int buttonStatePressed = HIGH;
#else
const int buttonStateNotPressed = HIGH;
const int buttonStatePressed = LOW;
#endif
int lastButtonState = buttonStateNotPressed; // the current reading from the input pin
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 50; // the debounce time in ms; increase if the output flickers
unsigned long resetDelay = 3000; // the time required to press button to reset, in ms
bool rainbowActive = false;
bool rainbowBootActive = false;
unsigned long rainbowBootStart = 0;
uint8_t lastBrightness = 0;
uint32_t lastRgb = 0;
unsigned long directColorOnDelay = 400;
// Debug toggle via button (hold for 8s)
bool debugTogglePending = false;
unsigned long debugToggleStart = 0;
WiFiManager wifiManager; // global instance
WiFiServer telnetServer(23);
WiFiClient telnetClient;
Espalexa espalexa;
Ticker ticker;
CRGB leds[NUM_LEDS]; // global intialize number of LEDs on device
// Non-blocking color change state variables
bool waitingForColor = false;
unsigned long powerOnTime = 0;
bool changeColorPending = false;
uint32_t pendingRgb = 0;
uint8_t pendingBrightness = 0;
// Unified debug output to Serial and Telnet
void debugPrint(const char *fmt, ...)
{
char buf[256];
va_list args;
va_start(args, fmt);
vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
if (enableDebug)
{
Serial.print(buf);
if (telnetClient && telnetClient.connected())
{
telnetClient.print(buf);
telnetClient.print("\r");
}
}
}
/*
*/
void setupSpiffs()
{
// clean FS, for testing
// SPIFFS.format();
#ifdef ESP32
if (SPIFFS.begin(true))
#else
if (SPIFFS.begin())
#endif
{
debugPrint("Mounted file system\n");
debugPrint("[SPIFFS] Files present:\n");
#ifdef ESP32
File root = SPIFFS.open("/", "r");
File file = root.openNextFile();
while (file)
{
debugPrint(" %s\n", file.name());
file = root.openNextFile();
}
#else
Dir dir = SPIFFS.openDir("/");
while (dir.next())
{
debugPrint(" %s\n", dir.fileName().c_str());
}
#endif
if (SPIFFS.exists("/config.json"))
{
File configFile = SPIFFS.open("/config.json", "r");
if (configFile)
{
size_t size = configFile.size();
// Allocate a buffer to store contents of the file.
std::unique_ptr<char[]> buf(new char[size]);
configFile.readBytes(buf.get(), size);
DynamicJsonDocument doc(128);
DeserializationError error = deserializeJson(doc, buf.get());
if (error)
{
debugPrint("Failed to load json config, assigning default values\n");
strcpy(device_name, "New Light");
strcpy(qty_leds, "1");
}
else
{
debugPrint("Successfully parsed json config\n");
strcpy(device_name, doc["device_name"]);
if (!doc["qty_leds"])
{
strcpy(qty_leds, "1");
}
else
{
strcpy(qty_leds, doc["qty_leds"]);
}
enableDebug = doc["enableDebug"] | false;
}
configFile.close();
}
void saveConfigFile()
{
DynamicJsonDocument doc(128);
doc["device_name"] = device_name;
doc["qty_leds"] = qty_leds;
doc["enableDebug"] = enableDebug;
File configFile = SPIFFS.open("/config.json", "w");
if (configFile)
{
serializeJson(doc, configFile);
configFile.close();
debugPrint("Config file saved\n");
}
else
{
debugPrint("Failed to open config file for writing\n");
}
}
void configModeCallback(WiFiManager *myWiFiManager)
{
if (enableDebug)
{
debugPrint("Entered config mode\n");
debugPrint("%s\n", WiFi.softAPIP().toString().c_str());
debugPrint("%s\n", myWiFiManager->getConfigPortalSSID().c_str());
}
else
{
Serial.print("Entered config mode\n");
Serial.print(WiFi.softAPIP().toString());
Serial.print(myWiFiManager->getConfigPortalSSID());
}
ticker.attach(0.2, tick); // blink faster in config mode
}
// callback notifying config will be saved
void saveConfigCallback()
{
debugPrint("Should save config\n");
shouldSaveConfig = true;
}
void tick()
{
// toggle state
digitalWrite(LED, !digitalRead(LED)); // set pin to the opposite state
}
void rainbow()
{
static uint16_t sPseudotime = 0;
static uint16_t sLastMillis = 0;
static uint16_t sHue16 = 0;
}
void colorLightChanged(uint8_t brightness, uint32_t rgb)
{
float r = ((rgb >> 16) & 0xFF);
float g = ((rgb >> 8) & 0xFF);
float b = (rgb & 0xFF);
rainbowActive = false;
debugPrint("\nCallback colorLightChanged()\n");
debugPrint("Last HEX: #%06X RAW: %lu\n", lastRgb, lastRgb);
debugPrint("Current HEX: #%06X RGB: (%d, %d, %d) RAW: %lu\n", rgb, (int)r, (int)g, (int)b, rgb);
debugPrint("lastBrightness: %d\n", lastBrightness);
debugPrint("currentBrightness: %d\n", brightness);
}
void setColor(uint32_t rgb, uint8_t brightness)
{
float r = ((rgb >> 16) & 0xFF);
float g = ((rgb >> 8) & 0xFF);
float b = (rgb & 0xFF);
fill_solid(leds, num_leds, CRGB::Black);
FastLED.setBrightness(brightness);
FastLED.show();
FastLED.show();
lastBrightness = brightness;
waitingForColor = false;
}
void checkButton()
{
// Improved button debounce and debug toggle
int reading = digitalRead(TRIGGER_PIN);
if (reading != lastButtonState)
{
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay)
{
if (reading == buttonStatePressed)
{
if (!debugTogglePending)
{
debugTogglePending = true;
debugToggleStart = millis();
}
// If held for 8 seconds, toggle debug
if (debugTogglePending && (millis() - debugToggleStart > 8000))
{
enableDebug = !enableDebug;
debugPrint("[DEBUG] Debug output toggled: %s\n", enableDebug ? "ON" : "OFF");
debugTogglePending = false;
}
// If held for resetDelay, reset device
if (millis() - debugToggleStart > resetDelay)
{
debugPrint("button was pressed for %lu ms, resetting device\n", millis() - debugToggleStart);
digitalWrite(LED, !digitalRead(LED));
WiFi.disconnect(true);
wifiManager.resetSettings();
ESP.restart();
}
}
else
{
debugTogglePending = false;
}
}
lastButtonState = reading;
}
void checkSignalStrength()
{
long rssi = WiFi.RSSI();
int quality;
if (rssi <= -100)
{
quality = 0;
}
else if (rssi >= -50)
{
quality = 100;
}
else
{
quality = 2 * (rssi + 100);
}
char buf[64];
snprintf(buf, sizeof(buf), "Signal strength: %ld dBm (%d%%)", rssi, quality);
telnetClient.println(buf);
}
void checkLedStatus()
{
int r = (int)((lastRgb >> 16) & 0xFF);
int g = (int)((lastRgb >> 8) & 0xFF);
int b = (int)(lastRgb & 0xFF);
Serial.printf("LED Status: %s\n", lastBrightness > 0 ? "ON" : "OFF");
telnetClient.printf("LED Status: %s\r\n", lastBrightness > 0 ? "ON" : "OFF");
if (rainbowActive)
{
Serial.printf("Rainbow Mode: Active\n");
telnetClient.printf("Rainbow Mode: Active\r\n");
return;
}
Serial.printf("LED Color RGB: R=%d G=%d B=%d HEX: #%06X\n", r, g, b, lastRgb);
Serial.printf("LED Brightness: %d (%d%%)\n", lastBrightness, (lastBrightness * 100) / 255);
telnetClient.printf("LED Color RGB: R=%d G=%d B=%d HEX: #%06X\r\n", r, g, b, lastRgb);
telnetClient.printf("LED Brightness: %d (%d%%)\r\n", lastBrightness, (lastBrightness * 100) / 255);
}
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
setupSpiffs();
#ifdef ESP32
digitalWrite(LED, HIGH); // ON for ESP32
#else
digitalWrite(LED, LOW); // ON for ESP8266
#endif
// Get portal values after connection
strlcpy(device_name, custom_device_name.getValue(), sizeof(device_name));
strlcpy(qty_leds, custom_qty_leds.getValue(), sizeof(qty_leds));
debugPrint("'");
debugPrint(device_name);
debugPrint("' connected... yeaay :)\n");
}
void loop()
{
espalexa.loop();
delay(10);
ArduinoOTA.handle();
MDNS.update();
checkButton();
}
`
zackees commentedon Sep 19, 2025
The new WS2812B chipset has a reset time of 280 uS, which is significantly longer than the previous spec of 50 uS. Out of an abundance of caution i'm going to increase the reset time. It's backwards compatible with the WS2812 timings.
zackees commentedon Sep 19, 2025
Manually download the library and install it and let me know if it works for you. If it doesn't then re-open this bug.
mcpacific commentedon Sep 19, 2025
@zackees It seems to work for the most part. However, my "rainbow mode" does not (running the Pride 2015 animation no longer works when I have Alexa change the color to lavender).
zackees commentedon Sep 19, 2025
prove to me this isn't user error for this one.
fixes FastLED#2067