2dom / P10_matrix

ESP8266 Adafruit GFX compatible graphics driver for P10 32x16 LED matrix
Other
60 stars 13 forks source link

Note ... this library is deprecated and will no longer be maintained

Please use the PxMatrix library that supports more panels and layouts and contains performance optimizations.

Overview

This is a Adafruit GFX compatible driver for a single chinese 32x16 or 64x32 RGB LED module.

P10

They are about EUR 15-20 a piece and commonly used for large-scale LED displays, e.g. see aliexpress.

This driver currently works with ESP8266 microcontrollers, however, it should be rather straightforward to port it to ESP32 or Atmel-based Arduinos. There are different panels out there - this driver only works with panels using a 4, 8 or 16 (thanks to irazaq) row-step pattern (details below).

Display structure

The display basically consists of 6 large shift register. On the input connector you will find the inputs to the shift register (two for each color - Rx,Gx,Bx), a 2 to 4 bit latch address input (A,B,C,D), a latch enable input (LAT/STB), a clock input (CLK) and the output enable input (OE).

There are a few basic layouts/patterns: 4 row-step (4RS), 8 row-step (8RS) or 16 row-step (16RS). You can enable the correct pattern for your display in the header file via #define PATTERN4, #define PATTERN8 or #define PATTERN16.

The 32x16 displays work like this: Each of the shift register is 64(4RS)/32(8RS) bits long. R1 and R2 will together therefore cover 128(4RS)/64(8RS) bits or 4(4RS)/2(8RS) lines respectively. The rows are, however, not next to each other but have a spacing of 4(4RS)/8(8RS). In case of 4RS adjacent bytes also alternate between lines n and n+4.

Setting Rx to high, cycling CLK 64(4RS)/32(8RS) times, setting (A,B,C) to low and setting LAT/STB to low will light up rows 0,4,8,12(4RS)/0,8(8RS). Repeating the same experiment with A high, B and C low will light up rows 1,5,8,13(4RS)/1,9(8RS) and so forth. The same principle applies to the other colors. As the row spacing for 4RS is 4 we only need A and B for the latch address - C has no function. Only 8RS requires C. 16RS will also require a D signal.

The P10 LED matrix is usually used as a sub-module for larger displays and therefore features an output connector for daisy chaining. On the output connector you will find the identical signals to the input connector where A,B,C,LAT,CLK are simply routed through and (R,G,B) pins are the outputs of the shift registers on the module.

Set-up and cabling

When driving a long chain of LED modules in a row, parallel color data lines make a lot of sense since it reduces the data rate. But since we are only driving a single module here, we really don't need that. We can therefore use jumper wires between input connector (PI) and output connector (PO) to chain all shift registers together and create one big shift register. This has two advantages: it reduces the number of required GPIO pins on the microcontroller and we can use the hardware SPI interface to drive it.

You should end up with something like this (VCC/supply not nonnected here yet):

Cabling

Colors

The number of color levels can be selected in the header file. The default (8 color levels per primary RGB color) works well with hardly any flickering. Note that the number of color levels determines the achievable display refresh rate. Hence, the more color levels are selected, the more flickering is to be expected. If you run into problems with flickering it is a good idea to increase the CPU frequency to 160MHz. This way the processor has more headroom to compute the display updates and refresh the display in time.

Troubleshooting

Examples

Test sketch with 16 levels per primary color

Colors

Animated weather clock from here

Example

Animated picture frame (work in progress) - pixels from eboy.

Example