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:
- 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.
- Calling yield() in the commandDelay routine has no effect on the LEDs being blacked out.
- 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!