pdwerryhouse / max7219_8digit

Micropython driver for the max7219 with 8 x 7segment display

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is a micropython library for MAX7219 + 8 x 7digit display boards.

I have tested it with both an ESP8266 and a ESP32, running micropython version 1.19.1.

Requires a minimum of three spare GPIO lines to run SPI.

Example of use:

# Connections:
# SCK (CLK) -> GPIO4 (D2)
# MOSI (DIN) -> GPIO2 (D4)
# SS (CS) -> GPIO5 (D1)

from machine import Pin, SPI
import max7219_8digit

# the max7219 doesn't use the MISO, but unfortunately SoftSPI requires that
# we specify it anyway
spi = SoftSPI(baudrate=100000, polarity=1, phase=0, sck=Pin(4), mosi=Pin(2), miso=Pin(0))

ss = Pin(5, Pin.OUT)

display = max7219_8digit.Display(spi, ss)
display.write_to_buffer('12345678')
display.display()

There is also a write_to_buffer_with_dots method, which attempts to use the display decimal points properly. Note that there are some rather big bugs in this at the moment, do not put dots at the start of the string, or put two of them in a row.

# Connections:
# SCK (CLK) -> GPIO4 (D2)
# MOSI (DIN) -> GPIO2 (D4)
# SS (CS) -> GPIO5 (D1)

from machine import Pin, SPI
import max7219_8digit

spi = SoftSPI(baudrate=100000, polarity=1, phase=0, sck=Pin(4), mosi=Pin(2), miso=Pin(0))

ss = Pin(5, Pin.OUT)

display = max7219_8digit.Display(spi, ss)
display.write_to_buffer_with_dots('1234.56.78')
display.display()

About

Micropython driver for the max7219 with 8 x 7segment display

License:GNU General Public License v3.0


Languages

Language:Python 100.0%