代码拉取完成,页面将自动刷新
#define FASTLED_ESP8266_D1_PIN_ORDER
#include <FastLED.h>
#include "./font.h"
#define NUM_LEDS 256
#define DATA_PIN 3
CRGB leds[NUM_LEDS];
void disSetup(){
pinMode(DATA_PIN, OUTPUT);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // GRB ordering is assumed
}
int INDEX_XY(char x,char y){
if(x<=8){
return 8*y+x-9;
}
if(x<=16){
return 8*y+x+47;
}
if(x<=24){
return 8*y+x+103;
}
return 8*y+x+159;
}
void printc(char x,char y,char n,unsigned long C){
unsigned char findex=5*n;
for(char i=0;i<5;i++){
unsigned char k=Fonts[findex+i];
for(char p=0;p<=7;p++){
if(k&(1<<p)){
leds[INDEX_XY(x+i,y+p)]=C;
}
}
}
}
void printNum2(char x,char y,char n,unsigned long C){
if(n<9){
printc(x,y,16,C);
printc(x+5,y,16 + n % 10,C);
}else if(n<99){
printc(x+5,y,16 + n % 10,C);
printc(x,y,16 + n / 10,C);
}
}
void printNum(char x,char y,char n,unsigned long C){
x--;
y--;
if(n==1){
leds[INDEX_XY(x+3,y+1)]=C;leds[INDEX_XY(x+3,y+2)]=C;leds[INDEX_XY(x+3,y+3)]=C;leds[INDEX_XY(x+3,y+4)]=C;leds[INDEX_XY(x+3,y+5)]=C;
return;
}
if(n==2){
leds[INDEX_XY(x+1,y+1)]=C;leds[INDEX_XY(x+2,y+1)]=C;leds[INDEX_XY(x+3,y+1)]=C;leds[INDEX_XY(x+3,y+2)]=C;leds[INDEX_XY(x+1,y+3)]=C;leds[INDEX_XY(x+2,y+3)]=C;leds[INDEX_XY(x+3,y+3)]=C;leds[INDEX_XY(x+1,y+4)]=C;leds[INDEX_XY(x+1,y+5)]=C;leds[INDEX_XY(x+2,y+5)]=C;leds[INDEX_XY(x+3,y+5)]=C;
return;
}
if(n==3){
leds[INDEX_XY(x+1,y+1)]=C;leds[INDEX_XY(x+2,y+1)]=C;leds[INDEX_XY(x+3,y+1)]=C;
leds[INDEX_XY(x+3,y+2)]=C;
leds[INDEX_XY(x+1,y+3)]=C;leds[INDEX_XY(x+2,y+3)]=C;
leds[INDEX_XY(x+3,y+4)]=C;
leds[INDEX_XY(x+1,y+5)]=C;leds[INDEX_XY(x+2,y+5)]=C;leds[INDEX_XY(x+3,y+5)]=C;
return;
}
if(n==4){
leds[INDEX_XY(x+1,y+1)]=C;leds[INDEX_XY(x+3,y+1)]=C;leds[INDEX_XY(x+1,y+2)]=C;leds[INDEX_XY(x+3,y+2)]=C;leds[INDEX_XY(x+1,y+3)]=C;
leds[INDEX_XY(x+2,y+3)]=C;leds[INDEX_XY(x+3,y+3)]=C;leds[INDEX_XY(x+3,y+4)]=C;leds[INDEX_XY(x+3,y+5)]=C;
return;
}
if(n==5){
leds[INDEX_XY(x+1,y+1)]=C;leds[INDEX_XY(x+2,y+1)]=C;leds[INDEX_XY(x+3,y+1)]=C;leds[INDEX_XY(x+1,y+2)]=C;leds[INDEX_XY(x+1,y+3)]=C;
leds[INDEX_XY(x+2,y+3)]=C;leds[INDEX_XY(x+3,y+3)]=C;leds[INDEX_XY(x+3,y+4)]=C;
leds[INDEX_XY(x+1,y+5)]=C;leds[INDEX_XY(x+2,y+5)]=C;//leds[INDEX_XY(x+3,y+5)]=C;
return;
}
if(n==6){
leds[INDEX_XY(x+1,y+1)]=C;
leds[INDEX_XY(x+2,y+1)]=C;
leds[INDEX_XY(x+3,y+1)]=C;
leds[INDEX_XY(x+1,y+2)]=C;
leds[INDEX_XY(x+1,y+3)]=C;
leds[INDEX_XY(x+2,y+3)]=C;
leds[INDEX_XY(x+3,y+3)]=C;
leds[INDEX_XY(x+1,y+4)]=C;
leds[INDEX_XY(x+3,y+4)]=C;
leds[INDEX_XY(x+1,y+5)]=C;
leds[INDEX_XY(x+2,y+5)]=C;
leds[INDEX_XY(x+3,y+5)]=C;
return;
}
if(n==7){
leds[INDEX_XY(x+1,y+1)]=C;
leds[INDEX_XY(x+2,y+1)]=C;
leds[INDEX_XY(x+3,y+1)]=C;
leds[INDEX_XY(x+3,y+2)]=C;
leds[INDEX_XY(x+3,y+3)]=C;
leds[INDEX_XY(x+3,y+4)]=C;
leds[INDEX_XY(x+3,y+5)]=C;
return;
}
if(n==8){
leds[INDEX_XY(x+1,y+1)]=C;
leds[INDEX_XY(x+2,y+1)]=C;
leds[INDEX_XY(x+3,y+1)]=C;
leds[INDEX_XY(x+1,y+2)]=C;
leds[INDEX_XY(x+3,y+2)]=C;
leds[INDEX_XY(x+1,y+3)]=C;
leds[INDEX_XY(x+2,y+3)]=C;
leds[INDEX_XY(x+3,y+3)]=C;
leds[INDEX_XY(x+1,y+4)]=C;
leds[INDEX_XY(x+3,y+4)]=C;
leds[INDEX_XY(x+1,y+5)]=C;
leds[INDEX_XY(x+2,y+5)]=C;
leds[INDEX_XY(x+3,y+5)]=C;
return;
}
if(n==9){
leds[INDEX_XY(x+1,y+1)]=C;
leds[INDEX_XY(x+2,y+1)]=C;
leds[INDEX_XY(x+3,y+1)]=C;
leds[INDEX_XY(x+1,y+2)]=C;
leds[INDEX_XY(x+3,y+2)]=C;
leds[INDEX_XY(x+1,y+3)]=C;
leds[INDEX_XY(x+2,y+3)]=C;
leds[INDEX_XY(x+3,y+3)]=C;
leds[INDEX_XY(x+3,y+4)]=C;
leds[INDEX_XY(x+3,y+5)]=C;
return;
}
if(n==0){
leds[INDEX_XY(x+1,y+1)]=C;
leds[INDEX_XY(x+2,y+1)]=C;
leds[INDEX_XY(x+3,y+1)]=C;
leds[INDEX_XY(x+1,y+2)]=C;
leds[INDEX_XY(x+3,y+2)]=C;
leds[INDEX_XY(x+1,y+3)]=C;
leds[INDEX_XY(x+3,y+3)]=C;
leds[INDEX_XY(x+1,y+4)]=C;
leds[INDEX_XY(x+3,y+4)]=C;
leds[INDEX_XY(x+1,y+5)]=C;
leds[INDEX_XY(x+2,y+5)]=C;
leds[INDEX_XY(x+3,y+5)]=C;
return;
}
}
void clearToColor(unsigned char r,unsigned char g,unsigned char b){
for(int i=0;i<NUM_LEDS;i++){
leds[i].red=r;
leds[i].green=g;
leds[i].blue=b;
}
}
void ledTest(){
static uint8_t v = 0;
int i=20;
while(true){
FastLED.showColor(CHSV(0, 255, v));
v+=i;
if(v>=240||v<=0){
i=20-i;
}
delay(10);
}
}
void refresh(){
FastLED.show();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。