p4 ken
/
LED_Matrix_Japanese_Scroll
LT-5016M1を74HC595で制御します。文字スクロールなどの参考にどうぞ。
制作の過程はNotebookに書いています。
Diff: main.cpp
- Revision:
- 28:4b4682ad3b17
- Parent:
- 27:c49fd2b1279a
- Child:
- 29:eb77dcbcd1e3
- Child:
- 30:7f0f186d2b4a
--- a/main.cpp Sat Nov 05 08:28:00 2016 +0000 +++ b/main.cpp Sat Nov 05 08:42:41 2016 +0000 @@ -9,23 +9,23 @@ Timer timer; // 経過時間のカウンター // 点灯パターン 手前赤、手前緑... -unsigned char pattern1[16][4*11] = // 急行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}}; +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}}; char scan = 16; // 点灯中の行 int round = 0; // スキャンを何周したか @@ -38,7 +38,7 @@ int main() { SPI spi(PB_15, PB_14, PB_13); // SPIピンを指定 - spi.format(8, 0); // 74595へ8ビットずつ送る + spi.format(16, 0); // 74595へ16ビットずつ送る spi.frequency(10*1000*1000); // 74595へのクロック周波数 最高96 初期1 pc.attach(receive, Serial::RxIrq); // シリアル受信割り込み pc.baud(9600); // シリアル通信のクロックレート デフォルト9600 @@ -58,11 +58,11 @@ } // 表示パターン送り込み - for(int i=0; i<4*11; i++){ // iは最大で4*11文字 + for(int i=0; i<2*11; i++){ // iは最大で4*11文字 // if(round < 500) { // spi.write(pattern1[scan-1][8-1-i%8]); // } else if(round < 1000) { - spi.write(pattern1[scan-1][4*11-1-i%(4*11)]); + spi.write(pattern1[scan-1][2*11-1-i%(2*11)]); // } else { // spi.write(pattern3[scan-1][8-1-i%8]); // }