引用: 吾妻思萌 发表于 2022-11-5 17:31 不厉害,头回上手这单元板,老是找不到北,只能一边查资料学习一边发帖,呵呵 我当年接触pi的 ...
事业有成,向您学习中......
【花雕动手做】有趣好玩的音乐可视化系列项目(30)--P6LED单元板
项目程序之一:点亮P6单元板——点与线的简单控制
/*
【花雕动手做】有趣好玩的音乐可视化系列项目(30)--P6LED单元板
项目程序之一:点亮P6单元板——点与线的简单控制
*/
#include <Adafruit_GFX.h> //核心图形库
#include <RGBmatrixPanel.h> //硬件特定库
#define CLK 8 //必须在这个端口上! (在Mega上使用PIN 11)
#define LAT A3
#define OE 9
#define A A0
#define B A1
#define C A2
//最后一个参数='false'禁用双屏障
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
void setup() {
matrix.begin(); //矩阵开始(启动)
}
void loop() {
//用红色在0,0处画一个像素
matrix.drawPixel(0, 0, matrix.Color333(7, 0, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
//用绿色在31,0处画一个像素
matrix.drawPixel(31, 0, matrix.Color333(0, 7, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
//用蓝色在31,15处画一个像素
matrix.drawPixel(31, 15, matrix.Color333(0, 0, 7));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
//用白色在0,15处画一个像素
matrix.drawPixel(0, 15, matrix.Color333(5, 5, 5));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
//用四种颜色在单元板四角各画一个像素
matrix.drawPixel(0, 0, matrix.Color333(7, 0, 0));
matrix.drawPixel(31, 0, matrix.Color333(0, 7, 0));
matrix.drawPixel(31, 15, matrix.Color333(0, 0, 7));
matrix.drawPixel(0, 15, matrix.Color333(5, 5, 5));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 0, matrix.Color333(7, 0, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(31, 0, 31, 15, matrix.Color333(0, 7, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 15, 31, 15, matrix.Color333(0, 0, 7));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 0, 15, matrix.Color333(5, 5, 5));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 0, matrix.Color333(7, 0, 0));
matrix.drawLine(31, 0, 31, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(0, 15, 31, 15, matrix.Color333(0, 0, 7));
matrix.drawLine(0, 0, 0, 15, matrix.Color333(5, 5, 5));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 15, matrix.Color333(4, 7, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(31, 0, 0, 15, matrix.Color333(4, 7, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 15, matrix.Color333(0, 7, 4));
matrix.drawLine(31, 0, 0, 15, matrix.Color333(0, 7, 4));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 0, matrix.Color333(7, 0, 0));
matrix.drawLine(31, 0, 31, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(0, 15, 31, 15, matrix.Color333(0, 0, 7));
matrix.drawLine(0, 0, 0, 15, matrix.Color333(5, 5, 5));
matrix.drawLine(0, 0, 31, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(31, 0, 0, 15, matrix.Color333(0, 7, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 0, matrix.Color333(7, 0, 0));
matrix.drawLine(31, 0, 31, 15, matrix.Color333(7, 0, 0));
matrix.drawLine(0, 15, 31, 15, matrix.Color333(7, 0, 0));
matrix.drawLine(0, 0, 0, 15, matrix.Color333(7, 0, 0));
matrix.drawLine(0, 0, 31, 15, matrix.Color333(7, 0, 0));
matrix.drawLine(31, 0, 0, 15, matrix.Color333(7, 0, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 0, matrix.Color333(0, 7, 0));
matrix.drawLine(31, 0, 31, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(0, 15, 31, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(0, 0, 0, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(0, 0, 31, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(31, 0, 0, 15, matrix.Color333(0, 7, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 0, matrix.Color333(0, 0, 7));
matrix.drawLine(31, 0, 31, 15, matrix.Color333(0, 0, 7));
matrix.drawLine(0, 15, 31, 15, matrix.Color333(0, 0, 7));
matrix.drawLine(0, 0, 0, 15, matrix.Color333(0, 0, 7));
matrix.drawLine(0, 0, 31, 15, matrix.Color333(0, 0, 7));
matrix.drawLine(31, 0, 0, 15, matrix.Color333(0, 0, 7));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
}
【花雕动手做】有趣好玩的音乐可视化系列项目(30)--P6LED单元板
项目程序之二:点亮P6单元板——显示图形与文字
/*
【花雕动手做】有趣好玩的音乐可视化系列项目(30)--P6LED单元板
项目程序之二:点亮P6单元板——显示图形与文字
*/
#include <Adafruit_GFX.h>
#include <RGBmatrixPanel.h>
#define CLK 8
#define LAT A3
#define OE 9
#define A A0
#define B A1
#define C A2
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
void setup() {
matrix.begin();
}
void loop() {
// draw a pixel in solid white
matrix.drawPixel(0, 0, matrix.Color333(7, 7, 7));
delay(500);
// fix the screen with green
matrix.fillRect(0, 0, 32, 16, matrix.Color333(0, 7, 0));
delay(500);
// draw a box in yellow
matrix.drawRect(0, 0, 32, 16, matrix.Color333(7, 7, 0));
delay(500);
// draw an 'X' in red
matrix.drawLine(0, 0, 31, 15, matrix.Color333(7, 0, 0));
matrix.drawLine(31, 0, 0, 15, matrix.Color333(7, 0, 0));
delay(500);
// draw a blue circle
matrix.drawCircle(7, 7, 7, matrix.Color333(0, 0, 7));
delay(500);
// fill a violet circle
matrix.fillCircle(23, 7, 7, matrix.Color333(7, 0, 7));
delay(500);
// fill the screen with 'black'
matrix.fillScreen(matrix.Color333(0, 0, 0));
// draw some text!
matrix.setCursor(1, 0);
matrix.setTextSize(1);
// print each letter with a rainbow color
matrix.setTextColor(matrix.Color333(7, 0, 0));
matrix.print('1');
matrix.setTextColor(matrix.Color333(7, 4, 0));
matrix.print('6');
matrix.setTextColor(matrix.Color333(7, 7, 0));
matrix.print('x');
matrix.setTextColor(matrix.Color333(4, 7, 0));
matrix.print('3');
matrix.setTextColor(matrix.Color333(0, 7, 0));
matrix.print('2');
matrix.setCursor(1, 9); // next line
matrix.setTextColor(matrix.Color333(0, 7, 7));
matrix.print('*');
matrix.setTextColor(matrix.Color333(0, 4, 7));
matrix.print('R');
matrix.setTextColor(matrix.Color333(0, 0, 7));
matrix.print('G');
matrix.setTextColor(matrix.Color333(4, 0, 7));
matrix.print('B');
matrix.setTextColor(matrix.Color333(7, 0, 4));
matrix.print("*");
delay(5000);
}