p4 ken
/
LED_Matrix_Japanese_Scroll
LT-5016M1を74HC595で制御します。文字スクロールなどの参考にどうぞ。
制作の過程はNotebookに書いています。
Diff: main.cpp
- Revision:
- 27:c49fd2b1279a
- Parent:
- 26:a370873304d9
- Child:
- 28:4b4682ad3b17
--- a/main.cpp Sat Nov 05 06:57:12 2016 +0000 +++ b/main.cpp Sat Nov 05 08:28:00 2016 +0000 @@ -9,59 +9,23 @@ Timer timer; // 経過時間のカウンター // 点灯パターン 手前赤、手前緑... -unsigned char pattern1[16][8] = // 緑「次は」 -{{0,128,0,0,0,0,0,0}, - {0,129,0,0,0,0,0,6}, - {0,130,0,0,0,0,0,4}, - {0,68,0,32,0,4,0,4}, - {0,192,0,127,0,36,0,124}, - {0,72,0,34,0,196,0,7}, - {0,40,0,18,0,2,0,4}, - {0,36,0,18,0,2,0,4}, - {0,4,0,2,0,2,0,4}, - {0,4,0,5,0,2,0,4}, - {0,3,0,5,0,2,0,4}, - {0,130,0,8,0,202,0,15}, - {0,130,0,8,0,42,0,52}, - {0,66,0,16,0,68,0,68}, - {0,48,0,32,0,132,0,7}, - {0,12,0,64,0,0,0,0}}; - -unsigned char pattern2[16][8] = // 橙「横浜」 -{{8,8,9,9,2,2,24,24}, - {8,8,73,73,4,4,7,7}, - {200,200,127,127,200,200,0,0}, - {8,8,9,9,64,64,0,0}, - {63,63,73,73,65,65,64,64}, - {200,200,127,127,194,194,127,127}, - {8,8,4,4,72,72,8,8}, - {156,156,63,63,72,72,8,8}, - {170,170,36,36,68,68,8,8}, - {138,138,36,36,68,68,8,8}, - {137,137,63,63,67,67,72,72}, - {136,136,36,36,242,242,127,127}, - {136,136,36,36,2,2,0,0}, - {136,136,63,63,130,130,16,16}, - {8,8,17,17,98,98,32,32}, - {232,232,96,96,26,26,64,64}}; - -unsigned char pattern3[16][8] = // 赤「終点」 -{{4,0,1,0,64,0,0,0}, - {4,0,9,0,64,0,32,0}, - {18,0,31,0,192,0,63,0}, - {145,0,8,0,64,0,0,0}, - {138,0,8,0,64,0,0,0}, - {68,0,5,0,252,0,31,0}, - {18,0,5,0,4,0,16,0}, - {17,0,10,0,4,0,16,0}, - {31,0,17,0,4,0,16,0}, - {196,0,96,0,4,0,16,0}, - {53,0,6,0,252,0,31,0}, - {21,0,8,0,0,0,0,0}, - {149,0,17,0,36,0,18,0}, - {21,0,6,0,68,0,36,0}, - {5,0,8,0,66,0,68,0}, - {4,0,16,0,65,0,68,0}}; +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}}; char scan = 16; // 点灯中の行 int round = 0; // スキャンを何周したか @@ -75,7 +39,7 @@ int main() { SPI spi(PB_15, PB_14, PB_13); // SPIピンを指定 spi.format(8, 0); // 74595へ8ビットずつ送る - spi.frequency(1*1000*1000); // 74595へのクロック周波数 最高96 初期1 + spi.frequency(10*1000*1000); // 74595へのクロック周波数 最高96 初期1 pc.attach(receive, Serial::RxIrq); // シリアル受信割り込み pc.baud(9600); // シリアル通信のクロックレート デフォルト9600 timer.start(); // 経過時間のカウントを開始 @@ -94,11 +58,11 @@ } // 表示パターン送り込み - for(int i=0; i<4*12; i++){ // iは最大で4*11文字 + for(int i=0; i<4*11; i++){ // iは最大で4*11文字 // if(round < 500) { // spi.write(pattern1[scan-1][8-1-i%8]); // } else if(round < 1000) { - spi.write(pattern2[scan-1][8-1-i%8]); + spi.write(pattern1[scan-1][4*11-1-i%(4*11)]); // } else { // spi.write(pattern3[scan-1][8-1-i%8]); // } @@ -121,15 +85,15 @@ CLK = 1; // ここまでの処理時間が長いほど明るくなる - while(timer.read_us()<0) { // 数字のぶんだけ暗くする - wait_us(10); - } +// while(timer.read_us()<0) { // 数字のぶんだけ暗くする +// wait_us(10); +// } G = !BUTTON; // ボタン押すと!点灯 // ダイナミック点灯のパルス幅を決める - while(timer.read_us()<100) { // 100*2500でゆっくり - wait_us(10); - } +// while(timer.read_us()<100) { // 100*2500でゆっくり +// wait_us(10); +// } // pc.printf("%d\r\n", timer.read_us()); // pc.printf("%d\r\n", round/100); }