/*
MAX7219 點陣 LED 模組接線
DIN -> GPIO23
CS -> GPIO2
CLK -> GPIO18
*/
#include "LedController.hpp"
// 定義 CS 腳位為 GPIO 2
#define CS 2
// 延遲時間(單位:毫秒)
#define delayTime 50
// 建立 LedController<幾列LED模組,幾行LED模組> LED矩陣名稱
LedController<1, 1> lc;
// 圖片數據,使用陣列表示 8x8 圖像
//ByteBlock:
//一種由Ledcontroller定義的數據結構,在這裡被用來儲存要顯示的圖像
ByteBlock IMAGES[11] = {
{
0b01111000,
0b00110000,
0b00011110,
0b00111001,
0b01001101,
0b00010100,
0b00100010,
0b01000001
},{
0b01111000,
0b00110000,
0b00011100,
0b00111010,
0b01001101,
0b00010100,
0b00100110,
0b01100010
},{
0b01111000,
0b00110000,
0b00011100,
0b00111010,
0b00001100,
0b00010100,
0b00100100,
0b01100010
},{
0b01111000,
0b00110000,
0b00011100,
0b00011000,
0b00101100,
0b00010100,
0b00010100,
0b00100100
},{
0b01111000,
0b00110000,
0b00011100,
0b00011100,
0b00111100,
0b00001100,
0b00010100,
0b00100100
},{
0b01111000,
0b00110000,
0b00011000,
0b00011000,
0b00011100,
0b00001100,
0b00010100,
0b00010100
},{
0b01111000,
0b00110000,
0b00111000,
0b00001100,
0b00111000,
0b00011000,
0b00010100,
0b00100100
},{
0b01111000,
0b00110000,
0b00111100,
0b00011000,
0b00111000,
0b00010100,
0b00010100,
0b00100100
},{
0b01111000,
0b00110000,
0b00111100,
0b00111010,
0b00011000,
0b00010100,
0b00100100,
0b00100010
},{
0b01111000,
0b00110000,
0b00111100,
0b00111010,
0b01011001,
0b00010100,
0b00100110,
0b01100010
},{
0b01111000,
0b00110000,
0b00111110,
0b00101001,
0b01011001,
0b00010100,
0b00100010,
0b01000001
}};
const int IMAGES_LEN = 11;//總共有幾個圖像,接下來的for迴圈會用到
void setup() {
// 初始化 LedController
lc = LedController<1, 1>(CS);
// 清空矩陣
lc.clearMatrix();
}
void loop() {
// 依序顯示圖片
for (int i = 0; i < IMAGES_LEN; i++) {
lc.displayOnSegment(0, IMAGES[i]); // 顯示在第 0 個模組
delay(50); // 延遲
}
}