adafruit_max7219.max7219 - MAX7219 LED Matrix/Digit Display Driver

CircuitPython library to support MAX7219 LED Matrix/Digit Display Driver. This library supports the use of the MAX7219-based display in CircuitPython, either an 8x8 matrix or a 8 digit 7-segment numeric display.

See Also

  • matrices.Maxtrix8x8 is a class support an 8x8 led matrix display
  • bcddigits.BCDDigits is a class that support the 8 digit 7-segment display

Beware that most CircuitPython compatible hardware are 3.3v logic level! Make sure that the input pin is 5v tolerant.

  • Author(s): Michael McWethy

Implementation Notes

Hardware:

Software and Dependencies:

Notes: #. Datasheet: https://cdn-shop.adafruit.com/datasheets/MAX7219.pdf

class adafruit_max7219.max7219.MAX7219(width, height, spi, cs, *, baudrate=8000000, polarity=0, phase=0)[source]

MAX2719 - driver for displays based on max719 chip_select

Parameters:
  • width (int) – the number of pixels wide
  • height (int) – the number of pixels high
  • spi (object) – an spi busio or spi bitbangio object
  • chip_select (DigitalInOut) – digital in/out to use as chip select signal
  • baudrate – for SPIDevice baudrate (default 8000000)
  • polarity – for SPIDevice polarity (default 0)
  • phase – for SPIDevice phase (default 0)
brightness(value)[source]

Controls the brightness of the display.

Parameters:value (int) – 0->15 dimmest to brightest
fill(bit_value)[source]

Fill the display buffer.

Parameters:bit_value (int) – value > 0 set the buffer bit, else clears the buffer bit
init_display()[source]

Must be implemented by derived class (matrices, bcddigits)

pixel(xpos, ypos, bit_value=None)[source]

Set one buffer bit

Parameters:
  • xpos – x position to set bit
  • ypos – y position to set bit
  • bit_value (int) – value > 0 sets the buffer bit, else clears the buffer bit
scroll(delta_x, delta_y)[source]

Srcolls the display using delta_x,delta_y.

show()[source]

Updates the display.

write_cmd(cmd, data)[source]

Writes a command to spi device.

adafruit_max7219.matrices.Matrix8x8

class adafruit_max7219.matrices.Matrix8x8(spi, cs)[source]

Driver for a 8x8 LED matrix based on the MAX7219 chip.

Parameters:
  • spi (object) – an spi busio or spi bitbangio object
  • cs (DigitalInOut) – digital in/out to use as chip select signal
clear_all()[source]

Clears all matrix leds.

text(strg, xpos, ypos, bit_value=1)[source]

Draw text in the 8x8 matrix.

Parameters:
  • xpos (int) – x position of LED in matrix
  • ypos (int) – y position of LED in matrix
  • strg (string) – string to place in to display
  • bit_value – > 1 sets the text, otherwise resets

adafruit_max7219.bcddigits.BCDDigits

class adafruit_max7219.bcddigits.BCDDigits(spi, cs, nDigits=1)[source]

Basic support for display on a 7-Segment BCD display controlled by a Max7219 chip using SPI.

Parameters:
  • spi (object) – an spi busio or spi bitbangio object
  • cs (DigitalInOut) – digital in/out to use as chip select signal
  • nDigits (int) – number of led 7-segment digits; default 1; max 8
clear_all()[source]

Clear all digits and decimal points.

set_digit(dpos, value)[source]

Display one digit.

Parameters:
  • dpos (int) – the digit position; zero-based
  • value (int) – integer ranging from 0->15
set_digits(start, values)[source]

Display digits from a list.

Parameters:
  • s (int) – digit to start display zero-based
  • ds (list) – list of integer values ranging from 0->15
show_dot(dpos, bit_value=None)[source]

The decimal point for a digit.

Parameters:
  • dpos (int) – the digit to set the decimal point zero-based
  • value (int) – value > zero lights the decimal point, else unlights the point
show_help(start)[source]

Display the word HELP in the display.

Parameters:start (int) – start position to show HELP
show_str(start, strg)[source]

Displays a numeric str in the display. Shows digits 0-9, -, and ..

Parameters:
  • start (int) – start position to show the numeric string
  • str (string) – the numeric string