#include <Adafruit_GFX.h> //绘图库
#include <FastLED.h> //屏幕
#include <FastLED_NeoMatrix.h>
#include <FastLED_NeoPixel.h>
#include <Fonts/Picopixel.h>
#include <RGBmatrixPanel.h>
/*
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32,8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
const uint16_t colors[] = {
matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };
#define NUM_LEDS 256
#define DATA_PIN 1
CRGB leds[NUM_LEDS];
*/
#define LED_PIN 1
#define LED_WIDTH 32
#define LED_HEIGHT 8
#define LED_NUM (LED_WIDTH * LED_HEIGHT)
CRGB leds[LED_NUM];
const uint8_t timeAnim1[] PROGMEM = {
//const long timeAnim1[] PROGMEM = {
0x00,0x40,0x08,0x00,
0x00,0x40,0x08,0x00,
0x1D,0xE3,0xBC,0x00,
0x14,0x42,0x88,0x00,
0x09,0x43,0xA8,0x00,
0x14,0x42,0x88,0x00,
0x00,0x43,0x88,0x00,
0x00,0xC0,0x18,0x54
};
/*
const long ledarray0[] PROGMEM = {
0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF,
0x000000FF, 0x000000FF, 0x00FF0000, 0x000000FF, 0x000000FF, 0x000000FF, 0x00FF0000, 0x000000FF,
0x000000FF, 0x000000FF, 0x00FF0000, 0x00FF0000, 0x00FF0000, 0x00FF0000, 0x00FF0000, 0x000000FF,
0x000000FF, 0x000000FF, 0x00FF0000, 0x000000FF, 0x000000FF, 0x000000FF, 0x00FF0000, 0x000000FF,
0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF,
0x000000FF, 0x000000FF, 0x00FF0000, 0x00FF0000, 0x00FF0000, 0x00FF0000, 0x00FF0000, 0x000000FF,
0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x00FF0000, 0x000000FF, 0x000000FF, 0x000000FF,
0x000000FF, 0x000000FF, 0x00FF0000, 0x00FF0000, 0x00FF0000, 0x00FF0000, 0x00FF0000, 0x000000FF,
};
*/
FastLED_NeoMatrix *matrix;
uint8_t colorW = 250;//默认亮度
// 初始化矩阵显示屏相关参数
void initMatrix()
{
matrix = new FastLED_NeoMatrix(leds, 32, 8, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG);
FastLED.addLeds<NEOPIXEL, LED_PIN > (leds, 256).setCorrection(TypicalLEDStrip);
matrix->begin(); //屏幕初始化
matrix->setTextWrap(false); //文字换行
matrix->setBrightness(colorW); //亮度
matrix->setFont(&Picopixel); //字体
}
void logo1(){
//白天晴
matrix->clear();
matrix->fillRect(2,3,4,2,matrix->Color(255,200,100));
matrix->fillRect(3,2,2,4,matrix->Color(255,200,100));
matrix->drawPixel(2,0,matrix->Color(255,200,100));
matrix->drawPixel(5,0,matrix->Color(255,200,100));
matrix->drawPixel(0,2,matrix->Color(255,200,100));
matrix->drawPixel(7,2,matrix->Color(255,200,100));
matrix->drawPixel(0,5,matrix->Color(255,200,100));
matrix->drawPixel(7,5,matrix->Color(255,200,100));
matrix->drawPixel(2,7,matrix->Color(255,200,100));
matrix->drawPixel(5,7,matrix->Color(255,200,100));
matrix->show();
delay(2000);
}
void setup() {
initMatrix();// 初始化矩阵显示屏相关参数
}
void loop() {
/*
//显示英文
matrix->clear();
matrix->setTextColor(matrix->Color(255,0,255)); //文本颜色
matrix->setCursor(5, 6); //文本位置
matrix->print("WiFi");
matrix->show();
delay(2000);
//显示数字
matrix->clear();
matrix->setTextColor(matrix->Color(255,0,0)); //文本颜色
matrix->setCursor(3, 6); //文本位置
matrix->print("20:50:59");
matrix->show();
delay(2000);
//显示标点符号
matrix->clear();
matrix->setTextColor(matrix->Color(0,255,0)); //文本颜色
matrix->setCursor(0, 6); //文本位置
matrix->print("%%%%%%%");
matrix->show();
delay(2000);
//显示像素点
matrix->clear();
matrix->drawPixel(6, 2, matrix->Color(30,144,255));
matrix->show();
delay(2000);
//画垂线(x,y, h/1-8(实际数量-10进制), color)
matrix->clear();
matrix->drawFastVLine(5, 0, 7, matrix->Color(255,0,0));
matrix->show();
delay(2000);
//画水平线(x,y,w/1-32,color)
matrix->clear();
matrix->drawFastHLine(1, 0, 8, matrix->Color(255,0,255));
matrix->show();
delay(2000);
//画填充矩形
//fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
matrix->clear();
matrix->fillRect(0,0,7,7,matrix->Color(255,0,0));
matrix->show();
delay(2000);
//两点画线
matrix->clear();
//drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
matrix->drawLine(1,1,6,3,matrix->Color(255,0,0));
matrix->show();
delay(2000);
//画空心矩形
matrix->clear();
//drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
matrix->drawRect(1,1,6,6,matrix->Color(255,0,0));
matrix->show();
delay(2000);
*/
//画空心圆(*int16_t r //圆半径)
matrix->clear();
//drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
matrix->drawCircle(4,4,3,matrix->Color(255,0,0));
matrix->show();
delay(2000);
logo1();
//自定义图像drawBitmap(x,y,数组名,w,h,color)
matrix->clear();
for(int i = 0; i < 256; i++) {
leds[i] = pgm_read_dword(&(timeAnim1[i])); // Read array from Flash
}
matrix->show();
delay(2000);
/*
//填充屏幕
fillScreen(uint16_t color);
//画填充圆
fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
//三点绘制空心三角形
drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,int16_t x2, int16_t y2, uint16_t color);
//三点绘制填充三角形
fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,int16_t x2, int16_t y2,uint16_t color;)
//画空心圆矩形
drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
//画填充圆形矩形
fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,int16_t radius, uint16_t color);
//绘制位图
drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[ ],int16_t w, int16_t h, uint16_t color);
//绘制位图 +背景
drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],int16_t w, int16_t h, uint16_t color, uint16_t bg);
drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,int16_t w, int16_t h, uint16_t color, uint16_t bg);
//绘制字符
drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,uint16_t bg, uint8_t size);
*/
}