Hello everyone.  Some details first: The Platform:

Hello everyone. Some details first:
The Platform:
Nodemcu (ESP8266)
Arduino SDK with Eclipse

The Issue:
I am having a very odd issue that I can’t seem to isolate. I have a very simple loop that flashes LEDs:

while( isCommandAvailable() == false )
{
	fill(onColor, true);
	if( commandDelay(onTime) ) break;
	fill(offColor, true);
	if( commandDelay(offTime) ) break;
}

fill() is my function that simply loops through the LEDs and sets the to a color. It called FastLED.show() if the second parameter is true; I developed it before I used FastLED and have not switched it out yet. commandDelay checks if a variable is set and calls delay(1) in a loop until the delay is reached or a command is received (command come in over WIFI and commandAvailable is set in the callback).

When I use the “stock” delay() command in commandDelay, the fill command does not always finish and part of the LED string is black when shown. It does not happen every time in the loop - it seems to be random - but it will consistently happen every 5-10 times fill is called.

When I switch to FastLED.delay() the LEDs fill each time properly, but the delay is 2x longer than specified. I’m nearly certain it is because show() is called in the delay loop every 1 ms (still trying to figure out why show is called in delay, but…).

Disclosure:

  1. Same code was working fine on Arduino using RF24 hardware prior to being ported to ESP8266. Arduino runs much slower than the ESP8266, but the ESP8266 is doing a lot more in the background.
  2. Calling yield() in the commandDelay routine has no effect on the LEDs being blacked out.
  3. Other, more complex routines like rainbow and confetti work perfectly with the stock delay(). Inserting FastLED.delay() does double the delay() for all routines but they show fine.

I’m trying to isolate the issue and create a compact test that I can provide that reproduces the issue. Hopefully I can get that done tomorrow. But in the mean time - any insights into why my fill routine does not work properly or the delay is 2x longer than specified? I’m nearly certain the ESP8266 is being interrupted while writing out the data, but I don’t know how to prove that. Looking for insights. Thanks!

How many LEDs and what type?

If you are using ws2812 LEDs, I’ve enabled interrupt handling on the esp8266 - what this means, however, is that if an interrupt handler runs too long, it will cut out the rest of the strip update.

Try making

#define FASTLED_ALLOW_INTERRUPTS 0

The very first line in the file and see if that helps (it is possible that disabling interrupts for too long will cause things to lock up).

If have some other possible code fixes, but I’m way too sick right now to try or describe them.

Another idea would be to use multiple, shorter strips.

Daniel - I just wanted to say this worked, but then caused watchdog issues. I’m working around the watchdog problems but I will return to this and debug as soon as I can. Thanks for the insight!