This repository contains a C library for commanding an array of 8x8 LED Matrices that are each equipped with a MAX7219 display driver. A MAX7219 display driver can be accessed via a SPI bus. This repository includes the library and some example code. The library was developed and tested using a Raspberry Pi Pico.
Using this library you can utilize any of the MAX7219 display dirver functions indicated below.
| MAX7219 Function | Supported? |
|---|---|
| Set Brightness Level (Intensity) | ✔️ |
| Set Decode Mode per Digit (Code B or No) | ✔️ |
| Set Digits to Display (Scan Limit) | ✔️ |
| Enter/Exit Shutdown Mode | ✔️ |
| Enter/Exit Display Test | ✔️ |
| Writing to Digit 0-7 Registers | ✔️ |
| Writing to the No-Op Register | ✔️ |
This allows for the following high-level features:
- Writing a Single Character to a specified 8x8 LED Matrix in an array
- Writing a String to an array of 8x8 LED Matrices
- Showing a Message via discrete (matrix-by-matrix) scrolling
- Showing a Message via smooth (dot-by-dot) scrolling
This code assumes the following MAX7219 8x8 LED Matrix Module orientation:
DP A B C D E F G
+------------------------+
| 7 6 5 4 3 2 1 0 | D0
CLK <---| 1 | D1 <--- CLK
CS <---| 2 | D2 <--- CS
DOUT <---| 3 | D3 <--- DIN
GND ----| O 4 | D4 ---- GND
VCC ----| O O 5 | D5 ---- VCC
| O O O 6 | D6
| O O O O 7 | D7
+------------------------+
Although with the appropriate font bit-pattern adjustments this code should work with other orientations.
LedSpiConfig config;
memset(&config, 0, sizeof(config));
config.spi_instance = spi0;
config.baudrate = 10000000;
config.pin_cs = 17;
config.pin_sck = 18;
config.pin_mosi = 19;
config.num_8x8_matrix = 4;
config.smooth_scroll_rate = 300;
config.discrete_scroll_rate = 1000;
init_led_spi(&config);
set_shutdown_mode(&config, SHUTDOWN_YES);
set_display_test_mode(&config, DISPLAY_TEST_NO);
set_scan_limit(&config, DISPLAY_DIGITS_0_7); // use 8 digits
set_decode_mode(&config, 0x00); // no decode mode
set_shutdown_mode(&config, SHUTDOWN_NO);
set_brightness_level(&config, BRIGHTNESS_LVL_4);
clear_display(&config);
show_message(&config, "HELLO WORLD!");
show_message_smooth(&config, "Nice to meet you.");