SmartMatrix + FastLED Neopixels + Interrupt driven IR

@mdauria, if you still care:
This was discussed in the past a bit, and since I needed that, I did some quick tests:

  1. teensy 3.6 with FASTLED_ALLOW_INTERRUPTS 1
    FastLED takes the interrupt, updates 6 to 11 pixels before it’s time for SmartMatrix to do an update. SmartMatrix takes over in the middle of 2 LED updates, takes too long to finish its work, and FastLED detects this and doesn’t try to update more LEDs on the strip since they would be corrupted.

  2. teensy 3.6 with FASTLED_ALLOW_INTERRUPTS 0
    This time FastLED does not let interrupts run until it’s done updating the LED strip. That works, but in turn the SmartMatrix interrupt doesn’t fire in time and I see lines of 40 stuck pixels that flash

Both the above are expected. Given that both SmartMatrix and FastLED are interrupt sensitive, there is no good way around this I think. Things could be made to work if both worked together though and FastLED would disable SmartMatrix interrupt while it runs and only fire a strip update after SmartMatrix is done updating an entire frame. This would however break down eventually as the FastLED strip takes longer to update.
A better fix around this is to use DMA on teensy to update neopixel strips, but FastLED does not support this.

  1. ESP32 with ESP32 git master
    For some reason, it crashes after a few frames for me:
    Guru Meditation Error: Core 1 panic’ed (Interrupt wdt timeout on CPU1)
    PC: 0x400d0f84: SMLayerBackground ::swapBuffers(bool) at /home/merlin/Arduino/libraries/SmartMatrix_ESP32/src/Layer_Background_Impl.h line 921
    EXCVADDR: 0x00000000

Decoding stack results
0x400d0f84: SMLayerBackground ::swapBuffers(bool) at /home/merlin/Arduino/libraries/SmartMatrix_ESP32/src/Layer_Background_Impl.h line 921
0x400d1c3c: loop() at /home/merlin/arduino/libraries/SmartMatrix_ESP32/examples/DemoFastLED/DemoFastLED.ino line 163
0x400e7806: loopTask(void*) at /home/merlin/Arduino/hardware/espressif/esp32/cores/esp32/main.cpp line 17it crashes

  1. ESP32 with
    This one works. FastLED uses RMT while SmartMatrix does not and uses some other DMA, so they don’t step on one another.
    FastLED git also uses RMT, I’m not sure how it’s different from that branch and why the SamGuyer original RMT code for ESP32 works while the TOT git version of FastLED does not.

I did one more test: does interrupt driven IR reading work while updating neopixels and scrolling text on an RGBpanel.
The answer is “yes” :slight_smile:
I was a bit worried because the dirty ESP32 driver I contributed to GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols does not use RMT but the same interrupt routine than the other chips. Thankfully it’s fast enough that it works most of the time (a few times you get back FFFFF instead of the key, but at least you don’t get random garbage back)

I then tested it on teensy 3.6, and it works fine there too.
So, the only sticking point are the interrupts from FastLED Neopixel vs SmartMatrix on teensy 3.6. That’s the only thing that doesn’t really work.

Thanks for posting your results Marc

Have you tried this?

I sure had not seen this. I hope Paul submits this to FastLED, it’s a nice hack (similar to the hack someone did on ESP8266 using the I2S DMA output for neopixels).

And turns out he already did, I just didn’t know where to look.