#include <Adafruit_GFX.h>
#include <FastLED.h>
#include <FastLED_NeoMatrix.h>
#define PIN 6
#define NUMMATRIX (256)
CRGB matrixleds[NUMMATRIX];
const byte hexDigits[16][8] = {
{0x10,0x10,0x54,0x52,0x92,0x10,0x30,0x00},/*"G:\111\output_image.bmp",0*/
{0xFE,0x10,0xFE,0xAA,0xBA,0xAA,0xFE,0x00},/*"G:\111\output_image.bmp",0*/
{0x54,0xF6,0x50,0x74,0x56,0x00,0xAA,0x00},/*"G:\111\output_image.bmp",0*/
{0x5E,0xE4,0x44,0x64,0xC4,0x44,0xCC,0x00},
{0x28,0x5C,0xC8,0x7E,0x44,0x7E,0x54,0x00},
{0xE8,0x1E,0xFE,0x5E,0xBE,0xEC,0x16,0x00},/*"G:\111\output_image.bmp",0*/
/* (24 X 8 )*/
};
//FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(matrixleds, 32, 8, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG);
//FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(matrixleds, 32, 8, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG);
//FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(matrixleds, 32, 8, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_TILE_PROGRESSIVE);
FastLED_NeoMatrix matrix = FastLED_NeoMatrix(matrixleds, 32, 8, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_TILE_PROGRESSIVE);
const uint16_t colors[] = {
matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };
void setup() {
FastLED.addLeds<NEOPIXEL,PIN>(matrixleds, NUMMATRIX);
//FastLED.addLeds<WS2811_PORTA,3>(matrixleds, NUMMATRIX/3).setCorrection(TypicalLEDStrip);
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(200);
//matrix.setTextColor(colors[0]);
matrix.setTextColor(matrix.Color(0, 255, 0));
}
int x = 0;
int pass = 0;
void displayHexDigit(int digit, int index) {
int intAdd = index * 8;
int colorR = 0;
int colorG = 0;
if (digit >= 0 && digit <= 15) {
for (int y = 0; y < 8; y++) {
for (int x = 0; x < 8; x++) {
if (bitRead(hexDigits[digit][y], 7 - x)) {
colorR = random(100) + 150;
colorG = random(100) + 150;
colorR = 255;
colorG = 0;
colorR = 200 + x * 5;
colorG = 0;
matrix.drawPixel(x + intAdd, y, matrix.Color(colorR, colorG, 0));
} else {
matrix.drawPixel(x + intAdd, y, matrix.Color(0, 0, 0));
}
}
}
matrix.show();
}
}
void loop() {
/**
matrix.fillScreen(0);
matrix.setCursor(x,0);
//matrix.print(F("very well 1 2 3 4 5 6 7 8 9 "));
matrix.print(F("very 中文效果"));
if(--x < -196) {
x = matrix.width();
if(++pass >= 3) pass = 0;
matrix.setTextColor(colors[pass]);
}
matrix.show();
delay(50);
/**/
// 设置点阵
// 显示数字0
displayHexDigit(0, 0);
displayHexDigit(1, 1);
displayHexDigit(2, 2);
delay(1000); // 延迟1秒
displayHexDigit(3, 0);
displayHexDigit(4, 1);
displayHexDigit(5, 2);
delay(1000); // 延迟1秒
}