Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

LED matrix support for 74HC595 type displays?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

LED matrix support for 74HC595 type displays?

by kmevans on Sat Jun 06, 2020 6:43 pm

Does anyone know if there's a clever way to get CircuitPython to support RGB LED matrices which use 74HC595 shift registers to drive the rows/columns? When I tried to do this on my own in high-level CircuitPython with an ItsyBitsy M4 Express I found that the refresh rate was too low and erratic to be usable - basically there's too much flicker. An example of a board is the following one which is about $13.50 in single units (EBay). It's not as nice as the NeoPixel displays, but it's less than a third the price.

https://wiki.52pi.com/index.php/RPI-RGB-LED-Matrix_SKU:EP-0075

I believe that this is the type of LED RGB Matrix used on the board:

https://www.seeedstudio.com/8x8-RGB-LED-Matrix-Square-LED-Dot-p-1730.html

So it's driven by 4 x 74HC595s. One for the common row (active high anode) + 3 x RGB columns (active low cathode). So typically one does the following sequence many times (1) drive SPI CS low (2) use SPI hardware to clock out 4 bytes of data (3) drive SPI CS high to latch the data.

So if there were a way to have such SPI traffic generated in the background versus by high-level CircuitPython code it would probably be fine. It's ok to assume that SPI is not being shared if that makes it easier. Also the LEDs must be refreshed frequently, but actual changes to the frame buffer could be done by slower code. Low-end Arduinos can handle this with C code.

Here's an example of Python to drive such a board, but it must be running on a much faster system.

https://github.com/hanckmann/matrixdriver

I did see that none of the single color 8x8 LEDs matrices which AdaFruit sells have example code provided in CircuitPython. And the creator of the PewPew board created a custom module (https://circuitpython.readthedocs.io/en/5.0.x/shared-bindings/_pew/PewPew.html) to handle that matrix, but I didn't want to pursue that route if there's already support which I've missed - e.g. if there a way to use displayio.FourWire or rgbmatrix that I'm missing?

kmevans
 
Posts: 30
Joined: Mon Feb 06, 2017 4:32 pm

Re: LED matrix support for 74HC595 type displays?

by adafruit_support_bill on Sun Jun 07, 2020 5:37 am

I did see that none of the single color 8x8 LEDs matrices which AdaFruit sells have example code provided in CircuitPython.

https://learn.adafruit.com/adafruit-led ... thon-usage

adafruit_support_bill
 
Posts: 77937
Joined: Sat Feb 07, 2009 10:11 am

Re: LED matrix support for 74HC595 type displays?

by kmevans on Sun Jun 07, 2020 12:54 pm

Unfortunately that one is a "backpack" with an I2C interface. So the display contains memory and handles the LED refresh. Here's an example of a single color display which could be driven by a 74HC595 https://www.adafruit.com/product/454 and here's a bicolor display https://www.adafruit.com/product/458

There's only a link to the Arduino playground for this type.

kmevans
 
Posts: 30
Joined: Mon Feb 06, 2017 4:32 pm

Re: LED matrix support for 74HC595 type displays?

by adafruit_support_bill on Sun Jun 07, 2020 1:24 pm

Here's an example of a single color display which could be driven by a 74HC595 https://www.adafruit.com/product/454

That display and the bicolor one are both is covered in the tutorial link I posted. They are mounted on a backpack based on an HT16K33. We have HT16K33 backpacks and CircuitPython code for a wide variety of LED modules. We do not have boards or libraries for the 74HC595,

adafruit_support_bill
 
Posts: 77937
Joined: Sat Feb 07, 2009 10:11 am

Re: LED matrix support for 74HC595 type displays?

by kmevans on Sun Jun 07, 2020 1:48 pm

That tutorial link begins with:

The matrices use a driver chip that does all the heavy lifting for you: They have a built in clock so they multiplex the display. They use constant-current drivers for ultra-bright, consistent color (the images above are photographed at the dimmest setting to avoid overloading our camera!), 1/16 step display dimming, all via a simple I2C interface. The backpacks come with address-selection jumpers so you can connect up to four mini 8x8's or eight 7-segments (or a combination, such as four mini 8x8's and four 7-segments, etc) on a single I2C bus.


I'm interested in displays which unfortunately don't have a driver chip to do this heavy lifting. If I try to do all of this in high-level CircuitPython the results aren't satisfactory, but maybe I'm missing something.

kmevans
 
Posts: 30
Joined: Mon Feb 06, 2017 4:32 pm

Re: LED matrix support for 74HC595 type displays?

by adafruit_support_bill on Sun Jun 07, 2020 1:58 pm

Python is an interpreted language and as such has a lot more overhead than compiled languages such as C++. And some of the overhead like garbage collection can occur at random times - introducing random delays.

While it is a great language for fast development, prototyping and learning to code, it is not the language of choice for writing device drivers or other time-critical code.

adafruit_support_bill
 
Posts: 77937
Joined: Sat Feb 07, 2009 10:11 am

Re: LED matrix support for 74HC595 type displays?

by kmevans on Sun Jun 07, 2020 3:33 pm

Yes I understand. Since this isn't too exotic I was hoping that there might be some way to use a built-in driver that I'm missing.

I believe that the PewPew board (https://circuitpython.org/board/pewpew10/) uses a single-color matrix connected directly to GPIOs (no 74HC595s) but serves as an example of how to handle display refresh in the background. Perhaps there are better examples which make use of SPI.

kmevans
 
Posts: 30
Joined: Mon Feb 06, 2017 4:32 pm

Re: LED matrix support for 74HC595 type displays?

by adafruit_support_bill on Sun Jun 07, 2020 3:48 pm

The designer/author of the pew-pew has published all of his source, so you can see how he has implemented that. https://github.com/pewpew-game/pewpew/tree/master/libs

All else being equal, serial protocols like SPI are inherently slower than direct IO. i2c is even slower than SPI, but the HT16K33 takes care of all the refresh, so you only need to send the data once.

adafruit_support_bill
 
Posts: 77937
Joined: Sat Feb 07, 2009 10:11 am

Re: LED matrix support for 74HC595 type displays?

by kmevans on Sun Jun 14, 2020 12:44 am

Yes all of the PewPew code is in the CircuitPython repo, and builds are done for the PewPew board automatically. I was able to use it as an example, and get something working pretty quickly. I guess this is more obscure than I expected, so I'm not sure that there would be much enthusiasm to get it pulled into CircuitPython. It's actually quite simple once you understand the interfaces.

kmevans
 
Posts: 30
Joined: Mon Feb 06, 2017 4:32 pm

Re: LED matrix support for 74HC595 type displays?

by tannewt on Mon Jun 15, 2020 5:14 pm

I don't know of anything for these displays but would be happy to review and merge a PR to add support. It's likely similar to the RGBMatrix code for "HUB75" displays.

tannewt
 
Posts: 1685
Joined: Thu Oct 06, 2016 8:48 pm

Please be positive and constructive with your questions and comments.