Matrix.stop() to Completely Shut Off LED Matrix

Hi, @Louis. I am using the ESP32 with forum wiring and the SmartMatrix 4.0 library.

Is there any mechanism to perform the equivalent of matrix.stop()? I need to keep the ESP32 active, but I also need to be able to stop (and eventually restart) the SmartMatrix code. Making the brightness = 0 will reduce power consumption, but what would be much more effective would be to stop latching data, disable Output Enable, and stop the clock going to my LED matrix.

Was matrix.stop() ever implemented in SmartMatrix? I can’t find it, if so. Thank you!

Hi Michael, no this doesn’t exist. It hasn’t been a popular request over the years and I’ve never had a need for it. Brightness=0 is probably the best you can do right now without a hack that disables output, but requires a reset of the micro to get the matrix running again.

if I had to do this, I would find the ISR in the code, and disable the timer that calls it, or set a global, and in the ISR code, check for it, delay(1) and return if it’s set, instead of running the rest of the code.

Marc, great suggestion, and that makes good sense! Perhaps someone has dug this deep into the code and has a feel for where that interrupt service routine might be. :grinning:

I’m not going to grep the code for you, but if you don’t find it, @Louis can probably give you a hint.

I am defiantly way out of my depth of experience on this one but thought I would throw out a suggestion of wiring the OE pin on the level sifters to an analog pin and pull the pin high to turn them off instead of stopping/restarting the matrix code.

Nope, I wouldn’t expect any users to do the searching, other than me. I thought those who are most familiar with the code (@Louis :wink:) might know where to start looking: e.g., would the ISR be in SmartMatrix code or somewhere deep in the Adafruit code?

it’s in the smartmatrix code for sure.
sauron:~/arduino/libraries/SmartMatrix$ grep -ri ISR .
gives plenty of hits, note that the ISR is per architecture, so there is more than one. For instance:
./src/esp32_i2s_parallel.c:static void IRAM_ATTR i2s_isr(void* arg) {

Excellent! Thank you, Marc.

I’m trying to implement this great idea of using a global variable to ‘mask’ the execution of the body of ISRs but struggling.

I can’t seem to find a way or a place to declare the global variable so that the code will successfully compile.

I’ve tried “volatile bool maskInterrupt = false;” declared at the very top of my main code file (above all the includes which are above setup() and loop().) I then try to inspect this variable in the ISR you mentioned above (in esp32_i2s_parallel.c). The compiler is calling out an error in the c code saying the maskInterrupt variable is undeclared.

Sorry to bother with such a basic question. Can you help? I don’t have experience sharing global variables between the main code and ISRs.

Thanks so much for any help you can provide!

1 Like

In the midst of tinkering with this, I found that there’s two functions that help with what I’m trying to achieve (squelch any timer interrupts while I’m in the midst of a long transfer of data via BLE). “noInterrupts()” and “interrupts()”. This appears so far after some testing to be effective…I issue the noInterrupts() when the BLE transfer begins and then issue interrupts() when the BLE event is complete (sometimes one or two minutes later, these are large files). Are there any gotchas I should know about when using these functions with SmartMatrix? This seems like a simple solution, seems effective, and seems almost too good to be true.

@Rick_Rudowicz are you also on ESP32? I think with ESP32 if you turn off interrupts then there won’t be anything to switch buffers so DMA will keep refreshing one frame over and over, it will look paused, but not be completely shut off like Michael needs. (On Teensy refreshing is totally different and you’ll likely get some static pixels on the panel instead)

Yes, also on ESP32. Not wishing to display anything while transferring data via BLE. I blank the display first and then attempt file transfer. Just want to squelch any timer interrupts related to SmartMatrix, and any unrelated to BLE until a multi-packet file transfer is complete.