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... | |
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:
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().
MAX7219::MAX7219 | ( | SPI * | spi, |
int | numDevices = 1 |
||
) |
Create a new MAX7219 controller.
[in] | spi | SPI controller. |
[in] | numDevices | maximum number of devices that can be controlled that are daisy chained together. |
void MAX7219::clearDisplay | ( | int | addr | ) |
Switch all Leds on the display off.
[in] | addr | Address of the display to control. |
int MAX7219::getDeviceCount | ( | ) |
Gets the number of devices attached to 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', '.','-','_',' '
[in] | digit | The position of the character on the display (0..7). |
[in] | value | The character to be displayed. |
[in] | dp | Sets the decimal point. |
[in] | addr | Address 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.
[in] | col | column which is to be set (0..7). |
[in] | value | each bit set to 1 will light up the corresponding Led. |
[in] | addr | address 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.
[in] | digit | The position of the digit on the display (0..7). |
[in] | value | The value to be displayed. (0x00..0x0F). |
[in] | dp | Sets the decimal point. |
[in] | addr | Address of the display. |
void MAX7219::setIntensity | ( | int | intensity, |
int | addr = 0 |
||
) |
Set the brightness of the display.
[in] | intensity | the brightness of the display. (0..15). |
[in] | addr | The 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.
[in] | row | The row of the Led (0..7). |
[in] | col | The column of the Led (0..7). |
[in] | state | If true the led is switched on, if false it is switched off. |
[in] | addr | Address 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.
[in] | number | The number to display. |
[in] | addr | Address 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.
[in] | row | Row which is to be set (0..7). |
[in] | value | Each bit set to 1 will light up the corresponding Led. |
[in] | addr | Address 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.
[in] | limit | Number of digits to be displayed (1..8). |
[in] | addr | Address of the display to control. |
void MAX7219::shutdown | ( | bool | status, |
int | addr = 0 |
||
) |
Set the shutdown (power saving) mode for the device.
[in] | status | If true the device goes into power-down mode. Set to false for normal operation. |
[in] | addr | The address of the display to control. |