p4 ken
/
LED_Matrix_Japanese_Scroll
LT-5016M1を74HC595で制御します。文字スクロールなどの参考にどうぞ。
制作の過程はNotebookに書いています。
Diff: main.cpp
- Revision:
- 34:e9895343c300
- Parent:
- 33:c68c7a1138db
- Child:
- 35:e0efaf59276e
- Child:
- 38:97031cb65085
diff -r c68c7a1138db -r e9895343c300 main.cpp --- a/main.cpp Mon Feb 27 09:02:41 2017 +0000 +++ b/main.cpp Mon Feb 27 09:29:29 2017 +0000 @@ -9,24 +9,41 @@ //Timer timer; // 経過時間のカウンター // 点灯パターン 手前赤、手前緑... -unsigned short pattern1[16][2*11] = // 急行13:05やや混雑 -{{0,16,0,8,32,0,0,0,0,0,0,0,0,16448,0,16448,0,514,8224,2056,4626,0}, - {0,240,7,200,63,0,0,0,0,0,0,0,0,32896,0,32896,0,58596,16191,2056,4626,0}, - {0,8,2,4,0,0,49344,49344,257,32896,57825,3855,0,3084,257,3084,257,10280,8224,7967,18761,0}, - {0,4,17,18,0,0,41120,8224,514,16448,8738,0,0,2056,0,2056,0,8224,8224,5140,32639,0}, - {0,254,63,17,0,0,32896,4112,1028,8224,9252,0,0,34952,7967,34952,7967,57825,16191,38036,2313,0}, - {0,1,16,8,64,0,32896,0,1028,8224,9252,0,0,28784,8224,28784,8224,10794,8224,21074,2313,0}, - {0,0,16,232,127,0,32896,0,33924,8481,42148,771,0,6168,16448,6168,16448,10280,8224,29041,18761,0}, - {0,252,31,4,8,0,32896,0,33410,8481,25700,1028,0,5397,16448,5397,16448,58596,16191,2056,32639,0}, - {0,0,16,4,8,0,32896,32896,257,8224,1028,2056,0,8995,16448,8995,16448,1028,0,2056,2313,0}, - {0,0,16,6,8,0,32896,0,514,8224,1028,2056,0,8224,12593,8224,12593,8738,1028,32639,2313,0}, - {0,252,31,5,8,0,32896,0,1028,8224,1028,2056,0,16448,3598,16448,3598,8995,9252,2056,18761,0}, - {0,128,16,4,8,0,32896,0,1028,8224,1028,2056,0,16448,0,16448,0,58082,5397,7196,32639,0}, - {0,36,33,4,8,0,32896,4112,33924,8481,9252,2056,0,32896,0,32896,0,8738,3084,10794,2313,0}, - {0,36,73,4,8,0,32896,8224,33410,16705,16962,1028,0,32896,0,32896,0,8738,17476,19018,2313,0}, - {0,34,72,4,8,0,57568,50115,257,32896,33153,771,0,0,257,0,257,58082,17733,2313,18761,0}, - {0,193,15,4,15,0,0,0,0,0,0,0,0,0,257,0,257,14906,30840,2056,32639,0}}; +unsigned short pattern1[16][2*11] = +{{0,16,0,8,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1028,0,0}, + {0,240,7,200,63,0,0,0,0,0,0,0,0,0,63736,3855,57568,771,3598,514,0,0}, + {0,8,2,4,0,0,49344,49344,257,32896,57825,3855,0,0,2056,2056,4112,1028,4369,514,0,0}, + {0,4,17,18,0,0,41120,8224,514,16448,8738,0,0,0,2056,2056,2056,2056,4369,257,0,0}, + {0,254,63,17,0,0,32896,4112,1028,8224,9252,0,0,0,2056,1028,6168,2056,4369,257,0,0}, + {0,1,16,8,64,0,32896,0,1028,8224,9252,0,0,0,0,1028,0,2056,37265,0,0,0}, + {0,0,16,232,127,0,32896,0,33924,8481,42148,771,0,0,0,514,0,1028,37265,0,0,0}, + {0,252,31,4,8,0,32896,0,33410,8481,25700,1028,0,0,0,514,0,514,20046,0,0,0}, + {0,0,16,4,8,0,32896,32896,257,8224,1028,2056,0,0,0,514,0,257,16448,7196,0,0}, + {0,0,16,6,8,0,32896,0,514,8224,1028,2056,0,0,0,257,32896,0,8224,8738,0,0}, + {0,252,31,5,8,0,32896,0,1028,8224,1028,2056,0,0,0,257,16448,0,8224,8738,0,0}, + {0,128,16,4,8,0,32896,0,1028,8224,1028,2056,0,0,0,257,8224,4112,4112,8738,0,0}, + {0,36,33,4,8,0,32896,4112,33924,8481,9252,2056,0,0,32896,0,4112,4112,4112,8738,0,0}, + {0,36,73,4,8,0,32896,8224,33410,16705,16962,1028,0,0,32896,0,63736,7967,2056,8738,0,0}, + {0,34,72,4,8,0,57568,50115,257,32896,33153,771,0,0,32896,0,0,0,2056,7196,0,0}, + {0,193,15,4,15,0,0,0,0,0,0,0,0,0,0,0,0,0,1028,0,0,0}}; + unsigned char pattern2[16][32*11/8] = // 急行13:05やや混雑 +{{0,0,16,0,0,0,8,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,64,0,0,64,64,0,0,2,2,32,32,8,8,18,18,0,0}, + {0,0,240,0,7,0,200,0,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,128,0,0,128,128,0,0,228,228,63,63,8,8,18,18,0,0}, + {0,0,8,0,2,0,4,0,0,0,0,0,192,192,192,192,1,1,128,128,225,225,15,15,0,0,12,12,1,1,12,12,1,1,40,40,32,32,31,31,73,73,0,0}, + {0,0,4,0,17,0,18,0,0,0,0,0,160,160,32,32,2,2,64,64,34,34,0,0,0,0,8,8,0,0,8,8,0,0,32,32,32,32,20,20,127,127,0,0}, + {0,0,254,0,63,0,17,0,0,0,0,0,128,128,16,16,4,4,32,32,36,36,0,0,0,0,136,136,31,31,136,136,31,31,225,225,63,63,148,148,9,9,0,0}, + {0,0,1,0,16,0,8,0,64,0,0,0,128,128,0,0,4,4,32,32,36,36,0,0,0,0,112,112,32,32,112,112,32,32,42,42,32,32,82,82,9,9,0,0}, + {0,0,0,0,16,0,232,0,127,0,0,0,128,128,0,0,132,132,33,33,164,164,3,3,0,0,24,24,64,64,24,24,64,64,40,40,32,32,113,113,73,73,0,0}, + {0,0,252,0,31,0,4,0,8,0,0,0,128,128,0,0,130,130,33,33,100,100,4,4,0,0,21,21,64,64,21,21,64,64,228,228,63,63,8,8,127,127,0,0}, + {0,0,0,0,16,0,4,0,8,0,0,0,128,128,128,128,1,1,32,32,4,4,8,8,0,0,35,35,64,64,35,35,64,64,4,4,0,0,8,8,9,9,0,0}, + {0,0,0,0,16,0,6,0,8,0,0,0,128,128,0,0,2,2,32,32,4,4,8,8,0,0,32,32,49,49,32,32,49,49,34,34,4,4,127,127,9,9,0,0}, + {0,0,252,0,31,0,5,0,8,0,0,0,128,128,0,0,4,4,32,32,4,4,8,8,0,0,64,64,14,14,64,64,14,14,35,35,36,36,8,8,73,73,0,0}, + {0,0,128,0,16,0,4,0,8,0,0,0,128,128,0,0,4,4,32,32,4,4,8,8,0,0,64,64,0,0,64,64,0,0,226,226,21,21,28,28,127,127,0,0}, + {0,0,36,0,33,0,4,0,8,0,0,0,128,128,16,16,132,132,33,33,36,36,8,8,0,0,128,128,0,0,128,128,0,0,34,34,12,12,42,42,9,9,0,0}, + {0,0,36,0,73,0,4,0,8,0,0,0,128,128,32,32,130,130,65,65,66,66,4,4,0,0,128,128,0,0,128,128,0,0,34,34,68,68,74,74,9,9,0,0}, + {0,0,34,0,72,0,4,0,8,0,0,0,224,224,195,195,1,1,128,128,129,129,3,3,0,0,0,0,1,1,0,0,1,1,226,226,69,69,9,9,73,73,0,0}, + {0,0,193,0,15,0,4,0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,58,58,120,120,8,8,127,127,0,0}}; char scan = 16; // 点灯中の行 int round = 0; // スキャンを何周したか int scroll = 0; // 左スクロールした量 @@ -38,7 +55,7 @@ int main() { SPI spi(D11, D12, D13); // SPIピン mosi, miso, sclk - spi.format(8, 0); // 74595へ8ビットずつ送る + spi.format(8, 0); // 74595へ~ビットずつ送る spi.frequency(1*1000*1000); // 74595へのクロック周波数 最高96 初期1 // pc.attach(receive, Serial::RxIrq); // シリアル受信割り込み // pc.baud(9600); // シリアル通信のクロックレート デフォルト9600 @@ -58,15 +75,15 @@ } // 表示パターン送り込み - for(int i=0; i<2*11; i++){ // iは最大で4*11文字 + for(int i=0; i<4*11; i++){ // iは最大で~*11文字 // if(round < 500) { // spi.write(pattern1[scan-1][8-1-i%8]); // } else if(round < 1000) { - spi.write(pattern1[scan-1][2*11-1-i%(2*11)]); //2*11-1-i%(2*11) + spi.write(pattern2[scan-1][4*11-1-i%(4*11)]); //2*11-1-i%(2*11) // } else { // spi.write(pattern3[scan-1][8-1-i%8]); // } -spi.write(0); //消灯 +//spi.write(0); //消灯 //spi.write(0b1111111111111111); }