My Project
 All Classes Functions Variables Pages
Public Member Functions | List of all members
MAX7219 Class Reference

MAX7219 and MAX7221 controller. More...

#include <MAX7219.h>

Public Member Functions

 MAX7219 (SPI *spi, int numDevices=1)
 Create a new MAX7219 controller. More...
 
void clearDisplay (int addr)
 Switch all Leds on the display off. More...
 
int getDeviceCount ()
 Gets the number of devices attached to this MAX7219. More...
 
void setChar (int digit, char value, bool dp=false, int addr=0)
 Display a character on a 7-Segment display. More...
 
void setColumn (int col, uint8_t value, int addr=0)
 Set all 8 Led's in a column to a new state. More...
 
void setDigit (int digit, uint8_t value, bool dp=false, int addr=0)
 Display a hexadecimal digit on a 7-Segment Display. More...
 
void setIntensity (int intensity, int addr=0)
 Set the brightness of the display. More...
 
void setLed (int row, int col, bool state, int addr=0)
 Set the status of a single Led. More...
 
void setNumber (uint32_t number, int addr=0)
 Display a number on the 7-Segment display. More...
 
void setRow (int row, uint8_t value, int addr=0)
 Set all 8 Led's in a row to a new state. More...
 
void setScanLimit (int limit, int addr=0)
 Set the number of digits (or rows) to be displayed. See datasheet for side effects of the scanlimit on the brightness of the display. More...
 
void shutdown (bool status, int addr=0)
 Set the shutdown (power saving) mode for the device. More...
 

Detailed Description

MAX7219 and MAX7221 controller.

This is a port of the Arduino MAX7219 class to the ESP32. We can attach multiple IC instances daisy chained together. Each device has its own address with the first device being 0 (the default).

All the devices are in shutdown mode by default when we start. Any devices that are to be used must be taken out of shutdown mode with a call to:

shutdown(false);

For a given configuration, we are likely going to work with the MAX7219 as either an 8 digit 7 segment LED driver or an 8x8 led matrix. Working with the two styles have similarities and distinctions. For the 7 segment LED, we will typically use setDigit(), setChar() and setNumber() to set digits while in the 8x8 led matrix, we will use setLed(), setRow() and setColumn().

Constructor & Destructor Documentation

MAX7219::MAX7219 ( SPI spi,
int  numDevices = 1 
)

Create a new MAX7219 controller.

Parameters
[in]spiSPI controller.
[in]numDevicesmaximum number of devices that can be controlled that are daisy chained together.

Member Function Documentation

void MAX7219::clearDisplay ( int  addr)

Switch all Leds on the display off.

Parameters
[in]addrAddress of the display to control.
int MAX7219::getDeviceCount ( )

Gets the number of devices attached to this MAX7219.

Returns
The number of devices on this MAX7219.
void MAX7219::setChar ( int  digit,
char  value,
bool  dp = false,
int  addr = 0 
)

Display a character on a 7-Segment display.

There are only a few characters that make sense here : '0','1','2','3','4','5','6','7','8','9','0', 'A','b','c','d','E','F','H','L','P', '.','-','_',' '

Parameters
[in]digitThe position of the character on the display (0..7).
[in]valueThe character to be displayed.
[in]dpSets the decimal point.
[in]addrAddress of the display.
void MAX7219::setColumn ( int  col,
uint8_t  value,
int  addr = 0 
)

Set all 8 Led's in a column to a new state.

Parameters
[in]colcolumn which is to be set (0..7).
[in]valueeach bit set to 1 will light up the corresponding Led.
[in]addraddress of the display.
void MAX7219::setDigit ( int  digit,
uint8_t  value,
bool  dp = false,
int  addr = 0 
)

Display a hexadecimal digit on a 7-Segment Display.

Parameters
[in]digitThe position of the digit on the display (0..7).
[in]valueThe value to be displayed. (0x00..0x0F).
[in]dpSets the decimal point.
[in]addrAddress of the display.
void MAX7219::setIntensity ( int  intensity,
int  addr = 0 
)

Set the brightness of the display.

Parameters
[in]intensitythe brightness of the display. (0..15).
[in]addrThe address of the display to control.
void MAX7219::setLed ( int  row,
int  col,
bool  state,
int  addr = 0 
)

Set the status of a single Led.

Parameters
[in]rowThe row of the Led (0..7).
[in]colThe column of the Led (0..7).
[in]stateIf true the led is switched on, if false it is switched off.
[in]addrAddress of the display.
void MAX7219::setNumber ( uint32_t  number,
int  addr = 0 
)

Display a number on the 7-Segment display.

A non negative whole number that is 8 digits or less is displayed.

Parameters
[in]numberThe number to display.
[in]addrAddress of the display.
void MAX7219::setRow ( int  row,
uint8_t  value,
int  addr = 0 
)

Set all 8 Led's in a row to a new state.

Parameters
[in]rowRow which is to be set (0..7).
[in]valueEach bit set to 1 will light up the corresponding Led.
[in]addrAddress of the display.
void MAX7219::setScanLimit ( int  limit,
int  addr = 0 
)

Set the number of digits (or rows) to be displayed. See datasheet for side effects of the scanlimit on the brightness of the display.

Parameters
[in]limitNumber of digits to be displayed (1..8).
[in]addrAddress of the display to control.
void MAX7219::shutdown ( bool  status,
int  addr = 0 
)

Set the shutdown (power saving) mode for the device.

Parameters
[in]statusIf true the device goes into power-down mode. Set to false for normal operation.
[in]addrThe address of the display to control.

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