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!
Michael

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!
Rick

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.