Aliexpressなどで販売されている64x32のフルカラードットマトリクスLED2枚とNucleo F401REを利用して、 E233系の駅停車時、路線名表示ありのLED側面行先表示を再現するプログラムです。 3秒間隔、3段階切替で、路線名、種別、行先、次停車駅を個別に指定することが可能です。
Dependencies: SDFileSystem mbed
Revision 34:9ee64899b004, committed 2015-03-19
- Comitter:
- chirashi
- Date:
- Thu Mar 19 17:40:52 2015 +0000
- Parent:
- 33:c934bc793c5a
- Commit message:
- bug fix; Add DisPlayTestMode
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r c934bc793c5a -r 9ee64899b004 main.cpp --- a/main.cpp Thu Mar 19 10:55:18 2015 +0000 +++ b/main.cpp Thu Mar 19 17:40:52 2015 +0000 @@ -107,9 +107,6 @@ DigitalOut B2(D3); // BLUE Serial in for lower half - - - //SumSW(現状未使用) DigitalOut SCK(PB_7); DigitalOut SI(PC_13); @@ -121,12 +118,22 @@ DigitalIn SumSW8(PB_0); //BusIn SumSWNum(PA_0,PA_1,PA_4,PB_0); +DigitalIn Button1 (USER_BUTTON); //表示切替用タイマ Ticker ChangeTimer; +//表示切替用タイマ(テスト表示用) +Ticker ChangeTimerTest; + + //スクロール用タイマ Ticker ScrollTimer; + + + + + //Debug bool Debug = 0; @@ -153,6 +160,8 @@ int ChangeCount = 0; +//テスト表示用 +int ChangeCountTest = 0; //路線コード int LineNumber = 1; //種別コード @@ -532,96 +541,6 @@ } } - - -void TimerTick(){ - //OE = HIGH; - //DisplayMode = 1 3段階表示ならば - if(DisplayMode == 1){ - if (ChangeCount == 0){ - CopyBuffer(LEDBuffer,LEDMainBuffer); - ChangeCount = ChangeCount + 1; - }else if(ChangeCount == 1 ){ - CopyBuffer(LEDBuffer2,LEDMainBuffer); - ChangeCount = ChangeCount + 1; - //ChangeCount = 0; - }else if(ChangeCount == 2){ - CopyBuffer(LEDBuffer3,LEDMainBuffer); - ChangeCount = 0; - }else{ - ChangeCount = 0; - } - } - //DisplayMode = 2 2段階表示ならば - //次駅表示なし2段階表示に使用 - - if (DisplayMode == 2){ - - if(ChangeCount == 0 ){ - //CopyBuffer(LEDBuffer,LEDMainBuffer); - CopyBuffer(LEDBuffer5,LEDMainBuffer); - ChangeCount = ChangeCount + 1; - }else if(ChangeCount == 1){ - //CopyBuffer(LEDBuffer2,LEDMainBuffer); - CopyBuffer(LEDBuffer6,LEDMainBuffer); - ChangeCount = 0; - }else{ - ChangeCount = 0; - } - } - //DisplayMode = 3 ならば LEDBuffer2を固定表示 - if (DisplayMode == 3){ - CopyBuffer(LEDBuffer2,LEDMainBuffer); - ChangeCount = 1; - } - - //2段階表示 次駅表示あり、路線名なしパターンに使用 - if(DisplayMode == 4){ - if(ChangeCount == 1 ){ - CopyBuffer(LEDBuffer2,LEDMainBuffer); - ChangeCount = ChangeCount + 1; - }else{ - CopyBuffer(LEDBuffer3,LEDMainBuffer); - ChangeCount = 1; - } - } - - //DisplayMode = 5 5段階表示ならば - if(DisplayMode == 5){ - if (ChangeCount == 0){ - CopyBuffer(LEDBuffer,LEDMainBuffer); - ChangeCount = ChangeCount + 1; - }else if(ChangeCount == 1 ){ - CopyBuffer(LEDBuffer4,LEDMainBuffer); - ChangeCount = ChangeCount + 1; - //ChangeCount = 0; - }else if(ChangeCount == 2){ - CopyBuffer(LEDBuffer2,LEDMainBuffer); - ChangeCount = ChangeCount + 1; - }else if(ChangeCount == 3){ - CopyBuffer(LEDBuffer3,LEDMainBuffer); - ChangeCount = 0; - }else{ - ChangeCount = 0; - } - } - - //OE = LOW; - //クロック確認 - //pc.printf("CPU SystemCoreClock is %.2f MHz\r\n", (float)SystemCoreClock/1000/1000); -} - -void ScrollTimerTick(){ - if(ScrollCount < ScrollWriteCount + 80){ - CopyScrollBuffer(ScrollBuffer,LEDMainBuffer,ScrollCount); - ScrollCount = ScrollCount + 1; - }else{ - ScrollCount = 0; - } -} - - - //書込み対象バッファ,書込み開始位置x,書込み開始位置y,読み出し幅x,読み出し高さy,読み出し開始位置(バイト) bool SDBufferWrite(int8_t TargetBuffer[32][LED_Width], int Startx, int Starty, int Readx, int Ready, int StartByte ){ FILE *fp = fopen(SDFilePath, "r"); @@ -630,7 +549,7 @@ //error("Could not open file for write\r\n"); return 1; }else{ - pc.printf("SDFileOpen Success %s\r\n",SDFilePath); + //pc.printf("SDFileOpen Success %s\r\n",SDFilePath); //SDDataReadtest int8_t Data; @@ -708,6 +627,110 @@ } } +void TimerTick(){ + //OE = HIGH; + //DisplayMode = 1 3段階表示ならば + if(DisplayMode == 1){ + if (ChangeCount == 0){ + CopyBuffer(LEDBuffer,LEDMainBuffer); + ChangeCount = ChangeCount + 1; + }else if(ChangeCount == 1 ){ + CopyBuffer(LEDBuffer2,LEDMainBuffer); + ChangeCount = ChangeCount + 1; + //ChangeCount = 0; + }else if(ChangeCount == 2){ + CopyBuffer(LEDBuffer3,LEDMainBuffer); + ChangeCount = 0; + }else{ + ChangeCount = 0; + } + } + //DisplayMode = 2 2段階表示ならば + //次駅表示なし2段階表示に使用 + + if (DisplayMode == 2){ + + if(ChangeCount == 0 ){ + //CopyBuffer(LEDBuffer,LEDMainBuffer); + CopyBuffer(LEDBuffer5,LEDMainBuffer); + ChangeCount = ChangeCount + 1; + }else if(ChangeCount == 1){ + //CopyBuffer(LEDBuffer2,LEDMainBuffer); + CopyBuffer(LEDBuffer6,LEDMainBuffer); + ChangeCount = 0; + }else{ + ChangeCount = 0; + } + } + //DisplayMode = 3 ならば LEDBuffer2を固定表示 + if (DisplayMode == 3){ + CopyBuffer(LEDBuffer,LEDMainBuffer); + ChangeCount = 1; + } + + //2段階表示 次駅表示あり、路線名なしパターンに使用 + if(DisplayMode == 4){ + if(ChangeCount == 1 ){ + CopyBuffer(LEDBuffer2,LEDMainBuffer); + ChangeCount = ChangeCount + 1; + }else{ + CopyBuffer(LEDBuffer3,LEDMainBuffer); + ChangeCount = 1; + } + } + + //DisplayMode = 5 5段階表示ならば + if(DisplayMode == 5){ + if (ChangeCount == 0){ + CopyBuffer(LEDBuffer,LEDMainBuffer); + ChangeCount = ChangeCount + 1; + }else if(ChangeCount == 1 ){ + CopyBuffer(LEDBuffer4,LEDMainBuffer); + ChangeCount = ChangeCount + 1; + //ChangeCount = 0; + }else if(ChangeCount == 2){ + CopyBuffer(LEDBuffer2,LEDMainBuffer); + ChangeCount = ChangeCount + 1; + }else if(ChangeCount == 3){ + CopyBuffer(LEDBuffer3,LEDMainBuffer); + ChangeCount = 0; + }else{ + ChangeCount = 0; + } + } + + //OE = LOW; + //クロック確認 + //pc.printf("CPU SystemCoreClock is %.2f MHz\r\n", (float)SystemCoreClock/1000/1000); +} + +void TestDisplayTimerTick(){ + + if (ChangeCountTest <= 10){ + sprintf(SDFilePath,"/sd/E233/LEDTest/LEDTest%d.bin",ChangeCountTest); + OE = HIGH; + SDBufferWrite(LEDMainBuffer,0,0,128,32,0); + OE = LOW; + ChangeCountTest = ChangeCountTest + 1; + }else{ + ChangeCountTest = 0; + } + +} + +void ScrollTimerTick(){ + if(ScrollCount < ScrollWriteCount + 80){ + CopyScrollBuffer(ScrollBuffer,LEDMainBuffer,ScrollCount); + ScrollCount = ScrollCount + 1; + }else{ + ScrollCount = 0; + } +} + + + + + void ScrollRead2(){ //スクロールカウンタを0に戻す ScrollCount = 0; @@ -1366,35 +1389,30 @@ //Serial pc.printf("Power ON\r\n"); - - //SDカードから表示データを読み込み - SDFileRead(); + if(Button1 == 0){ + //起動時にボタンが押されているならテスト表示モードに移行 + pc.printf("DisplayTestMode\r\n"); + ChangeTimerTest.attach(&TestDisplayTimerTick,1); + Scroll=0; - //起動時にスクロールデータを読み込み - if(ScrollEnable == 1){ - ScrollRead2(); + }else{ + //通常モード + //SDカードから表示データを読み込み + SDFileRead(); + + //起動時にスクロールデータを読み込み + if(ScrollEnable == 1){ + ScrollRead2(); + } + //表示切替タイマ有効 + ChangeTimer.attach(&TimerTick,3); + } + //2段階表示に変更 //DisplayMode = 2; - //Debug - if(Debug == 1){ - //DataSerialOut - for(int y = 0; y < 32; y++){ - for(int x = 0; x <LED_Width; x++){ - if(LEDBuffer[y][x]== 0){ - //pc.printf("0,"); - pc.printf(" "); - }else{ - //pc.printf("#"); - pc.printf("%.02d",LEDBuffer[y][x]); - } - } - pc.printf("\r\n"); - } - } - //test //sprintf(SDFilePath,"/sd/E233/whitetest.bin"); //SDBufferWrite(LEDBuffer,0,0,128,32); @@ -1403,8 +1421,7 @@ //Serial割り込み有効 pc.attach(pc_rx, Serial::RxIrq); - //表示切替タイマ有効 - ChangeTimer.attach(&TimerTick,3); + while(1) {
diff -r c934bc793c5a -r 9ee64899b004 mbed.bld --- a/mbed.bld Thu Mar 19 10:55:18 2015 +0000 +++ b/mbed.bld Thu Mar 19 17:40:52 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0 \ No newline at end of file