enum COLORS {
mWhite = 0xFFFFFF,
mSilver = 0xC0C0C0,
mGray = 0x808080,
mBlack = 0x000000,
mRed = 0xFF0000,
mMaroon = 0x800000,
mOrange = 0xFF3000,
mYellow = 0xFF8000,
mOlive = 0x808000,
mLime = 0x00FF00,
mGreen = 0x008000,
mAqua = 0x00FFFF,
mTeal = 0x008080,
mBlue = 0x0000FF,
mNavy = 0x000080,
mMagenta = 0xFF00FF,
mPurple = 0x800080,
};
#include <FastLED.h> // подключаем библу
#define t_CHAR 59
#define percent_CHAR 60
#define celcy_CHAR 61
const byte CHAR_SIZE=6; //Размер символа 8х6
const byte CHAR_ROWS = 2; //количество строк в экране
const byte CHARS_IN_ROW = 2; //Количество символов в строке
const byte DISP_COLLS = CHARS_IN_ROW*CHAR_SIZE;
#define NUMLEDS CHAR_ROWS*CHARS_IN_ROW*CHAR_SIZE*8 // кол-во светодиодов
#define STRIP_PIN 12 // пин ленты
CRGB leds[NUMLEDS];
//char st[]=":;<=";
char st[]={t_CHAR,percent_CHAR,celcy_CHAR,0};
const byte PROGMEM CharTable[]={ //
0X3E,0X51,0X49,0X45,0X3E,0,// 0 48 16
0X00,0X42,0X7F,0X40,0X00,0, // 1 49 17
0X42,0X61,0X51,0X49,0X46,0,// 2 50 18
0X21,0X41,0X45,0X4B,0X31,0,// 3 51 19
0X18,0X14,0X12,0X7F,0X10,0,// 4 52 20
0X27,0X45,0X45,0X45,0X39,0,// 5 53 21
0X3C,0X4A,0X49,0X49,0X30,0,// 6 54 22
0X01,0X71,0X09,0X05,0X03,0,// 7 55 23
0X36,0X49,0X49,0X49,0X36,0,// 8 56 24
0X06,0X49,0X49,0X29,0X1E,0, // 9 57 25
0X00,0X00,0X36,0X36,0X00,0, // : 58 26
// Heart Symbols
0X04,0X3F,0X44,0X40,0X20,0, // t
0X23,0X13,0X08,0X64,0X62,0, // %
0X38,0X44,0X44,0X28,0X03,0X03, // celcy
0x7C,0xFE,0xff,0xff,0xfe,0xfc,
0xfc,0xfe,0xff,0xff,0xfe,0x7c,
0x0,0x01,0x07,0x0f,0x3f,0x7f,
0x7f,0x3f,0x0f,0x07,0x01,0};
void setup() {
FastLED.addLeds <WS2812, STRIP_PIN, GRB>(leds, NUMLEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(255);
Serial.begin(9600);
}
void loop() {
LoadStr(st,mRed);
while(1);
}
void LoadStr(char *s,COLORS clr){
byte curCharByte;
byte curChar=0; //Порядковый номер символа выводимой строки
byte curStrRow=0; //текущаа строка экрана (расчитывается от количества символов)
while(*s!=0){
Serial.print("--Char--");
Serial.println(*s);
for(byte i=0;i<CHAR_SIZE;i++){ //цикл по символу
//curCharByte=(i!=CHAR_SIZE-1)?pgm_read_byte(&CharTable[(*s-0x30)*(CHAR_SIZE-1)+i]):0;
curCharByte=pgm_read_byte(&CharTable[(*s-0x30)*(CHAR_SIZE)+i]);
Serial.println(curCharByte,HEX);
for (byte j=0;j<8;j++){ //цикл по разрядом
if (curCharByte & 1){
if (j%2==0)
leds[curStrRow*DISP_COLLS*8+j*DISP_COLLS+i+curChar*CHAR_SIZE]=clr;
else
leds[(curStrRow*DISP_COLLS*8+(j+1)*DISP_COLLS)-1-i-curChar*CHAR_SIZE]=clr;
}
curCharByte >>= 1;
} //next j
}//next i
s++; // указатель на след символ
curChar++; //перейти к след симвлу
if (curChar%CHARS_IN_ROW==0) {
curStrRow++; //если перешли к символу на второй строке
curChar=0; //индекс на начало
}
} //while !=EOF
FastLED.show();
}
void my(COLORS clr,COLORS clr2){
static byte counter = 0;
for (byte cycle=0;cycle<NUMLEDS;cycle++){
for (byte i=0;i<NUMLEDS-cycle;i++){
if (i !=0) leds[i-1]=clr2;
leds[i]=clr;
FastLED.show(); // вывод
delay(5);
}
}
}//my