pimoroni-pico/micropython/modules/hub75
Phil Howard bc0390b86c MicroPython: Use placement new to alloc classes on GC_HEAP 2022-05-23 15:34:49 +01:00
..
README.md HUB75 Perf, C++ scrolling text, docs 2021-12-02 12:41:30 +00:00
hub75.c HUB75: Add expansion and feature pins 2021-12-06 14:37:04 +00:00
hub75.cpp MicroPython: Use placement new to alloc classes on GC_HEAP 2022-05-23 15:34:49 +01:00
hub75.h HUB75 Perf, C++ scrolling text, docs 2021-12-02 12:41:30 +00:00
micropython.cmake MicroPython: Drop PicoDisplay/PicoDisplay2 modules. 2022-05-12 12:49:33 +01:00

README.md

Interstate 75

The Interstate 75 library is intended for the Interstate 75 "HUB75" matrix panel driver board.

It can, in theory, be used with your own custom wiring, though custom pin assignments are not supported yet.

Notes On PIO & DMA Limitations

The Interstate 75 driver uses the PIO hardware on the RP2040. There are only two PIOs with four state machines each, and i75 uses one of these (PIO0) and two state machines- one for clocking out pixels, and another for latching/lighting a row.

It also uses two DMA channels, one to copy pixel data from the back buffer back to the front buffer and one to supply the row driving PIO with row data.

Getting Started

Contruct a new Hub75 instance, specifying the width/height of the display and any additional options.

import hub75

WIDTH = 64
HEIGHT = 64

matrix = hub75.Hub75(WIDTH, HEIGHT, stb_invert=True)

Use stb_invert if you see a missing middle row corruption on the top row.

Start the matrix strip by calling start. This sets up DMA and PIO to drive your panel, pulling rows from the back buffer and refreshing as fast as it can.

matrix.start()

FM6216A Panels

Some panels - based on the FM6126A chips - require a couple of register settings in order for them to display anything at all. Interstate 75 will set these for you if you specify panel_type=hub75.PANEL_FM6126A. Eg:

import hub75

WIDTH = 64
HEIGHT = 64

matrix = hub75.Hub75(WIDTH, HEIGHT, panel_type=hub75.PANEL_FM6126A)

Quick Reference

Set A Pixel

You can set the colour of an pixel in either the RGB colourspace, or HSV (Hue, Saturation, Value). HSV is useful for creating rainbow patterns.

Color

Set the top left-most LED - 0, 0 - to a pre-calculated colour.

matrix.set_color(0, 0, color)

There are a couple of functions for generating colours, which take your red, green and blue values, gamma correct them and pack them into a single number. By converting a colour and saving this value you can pay the cost of conversion up-front and drawing pixels in that colour will be faster:

red = hub75.color(255, 0, 0)
red = hub75.color_hsv(1.0, 0, 0)

Eg:

red = hub75.color(255, 0, 0)

for x in range(32):
    matrix.set_color(0, 0, red)

RGB

Set the top left-most LED - 0, 0 - to Purple 255, 0, 255:

matrix.set_rgb(0, 0, 255, 0, 255)

HSV

Set the top left-most LED - 0, o - to Red 0.0:

matrix.set_hsv(0, 0, 0.0, 1.0, 1.0)

Update The Display

You can update the back buffer - the framebuffer used by the driver to drive the screen - by calling flip:

matrix.flip()

flip will swap the front buffer (the one you draw into) with the back buffer (the one the screen is refreshed from) so that the display can start drawing your changes immediately.

Since the back buffer contains your previous frame it then blocks and copies across the contents of the buffer you've just flipped.

If you want fresh, clear buffer to draw into at the start of your next frame you can use flip_and_clear instead:

background_color = hub75.color(0, 0, 0)
matrix.flip_and_clear(background_color)

This will fill your buffer with the background colour, so you don't need to call clear.