SmartMatrix Library ESP32 Port

Ok, thanks for the tips.
So, the good news is that I have it working somewhat. It looks mostly ok but there are issues.
First on wiring, I only used 2 level shifters, and shifted all 16 pins (the 2 that were ground I just put on ground on the level shifters input).
The most visible thing is that on layer demo, in
SMARTMATRIX_HUB75_32ROW_MOD16SCAN layer4 and layer5 don’t display at all. It’s not a problem with colors, if I change their colors it doesn’t matter.

SMARTMATRIX_HUB75_64ROW_MOD32SCAN strangely shows all 5 layers. but layer 4 and 5 are scrolling in the wrong direction (horizontal).

Now, I don’t actually need more than one layer so it doesn’t matter, but still weird. The regular demo has ghosting on fonts that scroll but it’s not visible on my phone video. It thankfully does not flash like it does here:

Edit: I just tried 64x64 panel on ESP32 and that demo looked pretty close to normal (I don’t know it by heart, so maybe I missed a detail or two). Strangely the refresh rate demo at the end shows only 16fps, however the background task takes care of a faster refresh, so I don’t see flickering. Aaah, I see a comment in the code that changing refresh rate is broken, so I’ll ignore that number. I don’t need to change it anyway as long as I can’t see flickering.

Is there a good way to validate what works and what’s off by a bit?
I’ll try and add some capacitors on the level shifters to see if it helps.

I used this:
const uint8_t kMatrixHeight = 64; // known working: 16, 32, 48, 64
const uint8_t kRefreshDepth = 36; // known working: 24, 36, 48
const uint8_t kDmaBufferRows = 4; // known working: 2-4, use 2 to save memory, more to keep from dropping frames and automatically lowering refresh rate
//const uint8_t kPanelType = SMARTMATRIX_HUB75_32ROW_MOD16SCAN;
const uint8_t kPanelType = SMARTMATRIX_HUB75_64ROW_MOD32SCAN;

In #if (GPIOPINOUT == ESP32_FORUM_PINOUT) I added this wiring comment which you’re welcome to copy/integrate if you’d like:

/*
                ESP32 pin / comment
1	R1	2	Red Data (columns 1-16)
2	G1	15	Green Data (columns 1-16)
3	B1	4	Blue Data (columns 1-16)
4	GND	GND	Ground
5	R2	16/RX2	Red Data (columns 17-32)
6	G2	27	Green Data (columns 17-32)
7	B2	17/TX2	Blue Data (columns 17-32)
8	E	12	Demux Input E for 64x64 panels
------------------------------------------------------
9	A	5	Demux Input A0
10	B	18	Demux Input A1
11	C	19	Demux Input A2
12	D	21	Demux Input E1, E3 (32x32 panels only)
13	CLK	22	LED Drivers' Clock
14	STB	26	LED Drivers' Latch
15	OE	25	LED Drivers' Output Enable
16	GND	GND	Ground
*/

I’ll make a separate comment on development questions between teensy and ESP32.
Because teensy patches my arduino install, I usually have 2 arduinos
arduino-teensy and arduino.
They launch as separate binaries with their own windows. Sadly they share the same preferences, so I have to re-set the compile target back and forth between teensy and ESP32.

Now my bigger problem/question is with the Smartmatrix ESP32 branch in teensylc. I now have this:

saruman:~/arduino/libraries$ l -d SmartMatrix* SM_ESP32*
lrwxrwxrwx 1 merlin merlin   8 Dec 22 13:42 SmartMatrix -> SM_ESP32/
drwxr-xr-x 1 merlin merlin 166 Dec 16 18:58 SmartMatrix.orig/
drwxr-xr-x 1 merlin merlin 166 Dec 21 18:27 SM_ESP32/

Currently I move the symlink back and forth because both libraries are called the same and I don’t have a good way to switch between them, and even then I have to invalidate the arduino cache which pretty much means restarting the IDE.
I think I already compiled for ESP32 once by mistake while using the master branch and it seemed to work anyway, so I’m not even sure what’s different between the branches.

That said, my method sucks and I’d like to do something easier. Any suggestions?

Add unique header files to the SmartMatrix Library inside each instance of the SmartMatrix Library. Have the header file contain #include <SmartLEDShieldV4.h> for the Teensy one, and #include <SmartMatrix3.h> for the ESP32 one.

So in your Teensy sketch you `#include <SmartMatrix_Teensy_Unique_Header.h>

In your ESP32 sketch you `#include <SmartMatrix_ESP32_Unique_Header.h>

Good tip, I’ll try that, thanks. To be clear the teensylc/ESP32 branch is not compatible with teensy v3.x, so I can’t just use that branch for both, correct?

Hmm, some weirdness with the Layers sketch on ESP32. Not sure why.

You can try lowering the CLK rate on the ESP32 sketch. I can’t remember off hand how to do that, but there’s support for doing it.

Here is a better demo of teensy v3.6 (top) vs ESP32 direct wiring (bottom)

the demo mostly works, you can see a bit of ghosting on the white font (strangely no ghosting when I use 64x64 panel output instead of 64x32). Strangely too the first background is dark red by default with teensy, but full black with ESP32.

On the bright side, ESP32 is 99% working for me out of the box with direct wiring, so thank you for that :slight_smile:

I originally had some thoughts/questions about sync rate changing and how to not make it look so bad when filming, but I split that to a separate thread: Working around sync offsets and flicker when filming/taking pictures

Actually since I’ll be working with both the ESP32 and teensy trees: is it accurate that master and teenylc(aka ESP32) have diverged and that one is not inclusive of the other?
Or does one of the trees work on both chips and I don’t have to switch back and forth?

teensylc branch supports both but the Teensy code was extensively refactored and probably contains more bugs than the latest release.

This is a known issue (unknown solution). I noted this in the README: “Need a ~10ms delay between matrix.begin() and drawing to backgroundLayer”

Thanks for clearing up the teensylc branch. I’ll make sure only to use it for ESP32 then. And no big deal with the red background issue, I was just checking the differences between the two. All in all ESP32 worked pretty well, even with direct wiring which you haven’t used in a while.
Given that it’s unlikely that I’ll get neopixel strips working with teensy ( SmartMatrix + FastLED Neopixels + Interrupt driven IR - #2 by marcmerlin) this is good news. I’ll try and do more work with ESP32 since it seems to work well enough.

Joyeux Noël, Marc

Just FYI, I have this up an running video, and it’s great at 64x32 (30+ fps) but it DRAGS as the matrix, and hence the data, get larger. At 64x64 its only 10-15 fps, and so on.

I think this is because I am caching the frames in PSRAM.

I also added Alpha blending and chroma keying to layers. Can I send you (Louis) a zip to review or did I need to check it into github myself? I’ve never done that…

I think it would be best for both of us if you committed your changes to GitHub, but if it’s a real barrier right now, send it to me and I can look it over.

Hi Dave, I’m going to be working on a major SmartMatrix Library release over the next month or so, so now would be a good time for me to get your changes integrated into the library. If using GitHub is too difficult, please send me a zip with anything you’d like to commit. Thanks!

hi Kev
I have same problem how solve it?

You probably have an old version of SmartMatrix Library. Upgrade to the latest version and try again. If it doesn’t compile, please post your full compilation output in a new thread and I’ll try to help.

Hi Louis thank you for your replaying I use Arduino IDE 1.8.16 and I have a problem with esp32_i2s_parallel.c and ESP 2.0.1 SDK when compiling the example

Sorry, I don’t think ESP SDK 2.x is supported. I’m using 1.6 myself. If you open a GitHub issue and add a few details that would be helpful, but I don’t think I can fix this myself anytime soon

with esp 1.0.6 compile is ok
thank you Louis

Hi, Louis. Just checking in to see if support was added to use the SmartMatrix library with the ESP32 2.x board in Arduino. Thanks!

Checking again about ESP32 2.x board support.