Treehopper Python API
Max7219 Class Reference

Maxim MAX7219 8x8 LED matrix driver. More...

Inheritance diagram for Max7219:
LedDriver Flushable

Public Member Functions

def __init__ (spi_module, load_pin, parent, speed_mhz)
 
def send_decode_mode (decode_mode)
 
def send_test (test)
 
def flush (force)
 
def brightness ()
 
def clear ()
 

Public Attributes

 address
 
 auto_flush
 Gets or sets whether the driver should auto-flush when an LED is modified. More...
 
 state
 a list of 8 numbers that represent the bit pattern of the display More...
 
 use_native_led_order
 Whether to use the native LED order of the MAX7219, or the standard for Treehopper drivers. More...
 
 global_brightness
 whether this controller has global brightness control More...
 
 individual_brightness
 whether this controller has individual brightness control More...
 
 leds
 the collection of LEDs controlled by this driver. More...
 
 parent
 

Properties

 shutdown = property
 Gets or sets whether the display should be disabled. More...
 
 scan_limit = property
 Gets or sets the maximum digit index (from 0 to 7) that should be scanned. More...
 
 brightness = property
 

Detailed Description

Maxim MAX7219 8x8 LED matrix driver.

The Maxim MAX7219 (and compatible MAX7221, and MAX6951) drives 8x8 matrices of LEDs commonly found in multi-digit 7-segment displays, as well as LED dot matrices. Because of the proliferation of low-cost MAX7219 dev boards on eBay, Amazon, and other popular retailers, these devices have been popular among hobbyists and students.

Examples

>>> from time import sleep
>>> from treehopper.api import *
>>> from treehopper.libraries.displays import Max7219, SevenSegmentDisplay
>>> board = find_boards()[0]
>>> board.connect()
>>> driver = Max7219(spi_module=board.spi, load_pin=board.pins[15])
>>> for led in driver.leds:
>>> led.state = True
>>> sleep(0.01)
>>> for led in driver.leds:
>>> led.state = False
>>> sleep(0.01)

The driver also supports chaining multiple MAX7219 ICs together with the parent property.

>>> driver1 = Max7219(spi_module=board.spi, load_pin=board.pins[15])
>>> driver2 = Max7219(parent=driver1)
>>> driver3 = Max7219(parent=driver2)
>>> leds = driver3.leds + driver2.leds + driver1.leds
>>> for led in leds:
>>> led.state = True
>>> sleep(0.01)
>>> for led in leds:
>>> led.state = False
>>> sleep(0.01)

By default, this driver orders the LEDs using the Treehopper convention for seven-segment LEDs (A-DP), which allows hooking up a SevenSegmentDisplay class directly to the LED collection to create a display you can print numbers (and some letters) to.

>>> display = SevenSegmentDisplay(leds)
>>> i = 0
>>> while board.connected:
>>> display.clear()
>>> display.write(i)
>>> i += 1

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   spi_module,
  load_pin,
  parent,
  speed_mhz 
)

Member Function Documentation

◆ brightness()

def brightness ( )
inherited

◆ clear()

def clear ( )
inherited

◆ flush()

def flush (   force)

◆ send_decode_mode()

def send_decode_mode (   decode_mode)

◆ send_test()

def send_test (   test)

Member Data Documentation

◆ address

address

◆ auto_flush

auto_flush

Gets or sets whether the driver should auto-flush when an LED is modified.

◆ global_brightness

global_brightness
inherited

whether this controller has global brightness control

◆ individual_brightness

individual_brightness
inherited

whether this controller has individual brightness control

◆ leds

leds
inherited

the collection of LEDs controlled by this driver.

◆ parent

parent
inherited

◆ state

state

a list of 8 numbers that represent the bit pattern of the display

◆ use_native_led_order

use_native_led_order

Whether to use the native LED order of the MAX7219, or the standard for Treehopper drivers.

If True, LED segments are ordered G-A, DP. If False, LED segments are ordered A-DP. All Treehopper LED driver libraries are, by default, standardized so that the LSB of the driver corresponds with segment "A", the 7th bit corresponds with "G" and the MSB corresponds to the "DP" segment. This allows easy consumption of display libraries that require ordered collections of segments. However, you may choose to work with this library using the native LED ordering, where the LSB corresponds with segment "G", the 7th bit corresponds to segment "A" and the MSB corresponds to segment "DP".

Property Documentation

◆ brightness

brightness = property
staticinherited

◆ scan_limit

scan_limit = property
static

Gets or sets the maximum digit index (from 0 to 7) that should be scanned.

◆ shutdown

shutdown = property
static

Gets or sets whether the display should be disabled.


The documentation for this class was generated from the following file: