Aliexpressなどで販売されている64x32のフルカラードットマトリクスLED2枚とNucleo F401REを利用して、 E233系の駅停車時、路線名表示ありのLED側面行先表示を再現するプログラムです。 3秒間隔、3段階切替で、路線名、種別、行先、次停車駅を個別に指定することが可能です。
Dependencies: SDFileSystem mbed
Diff: main.cpp
- Revision:
- 31:d186b04b983e
- Parent:
- 30:3ac9aa4faa34
- Child:
- 32:3bf210e07de7
--- a/main.cpp Sun Feb 15 02:18:58 2015 +0000 +++ b/main.cpp Sun Feb 22 10:25:54 2015 +0000 @@ -811,7 +811,35 @@ } - +int CharToInt(unsigned char Sertemp1,unsigned char Sertemp2,unsigned char Sertemp3){ + int n1 = 0 ; + int n2 = 0 ; + int n3 = 0 ; + int n = 0; + + if ( Sertemp1 < '0' || Sertemp1 > '9' ) { + // error + } else { + n1 = (int)(Sertemp1 - '0') ; + //pc.printf("%d,",n1); + } + if ( Sertemp2 < '0' || Sertemp2 > '9' ) { + // error + } else { + n2 = (int)(Sertemp2 - '0') ; + //pc.printf("%d,",n2); + } + if ( Sertemp3 < '0' || Sertemp3 > '9' ) { + // error + } else { + n3 = (int)(Sertemp3 - '0') ; + //pc.printf("%d\r\n",n3); + } + n = (n1 * 100) + (n2 * 10) + n3; + return n; + } + + void pc_rx(){ //pc.putc(pc.getc()); @@ -831,147 +859,41 @@ //SerialBuffer[count] = '\0'; // 末尾に終端文字を入れる for(int a = 0; a < count; a++){ - ABuffer[a] = SerialBuffer[a]; } - count = 0; //路線名 L if(ABuffer[0] == 'L'){ - unsigned char Sertemp1 = ABuffer[1]; - unsigned char Sertemp2 = ABuffer[2]; - unsigned char Sertemp3 = ABuffer[3]; - int n1 = 0 ; - int n2 = 0 ; - int n3 = 0 ; - int n = 0; - - - if ( Sertemp1 < '0' || Sertemp1 > '9' ) { - // error - } else { - n1 = (int)(Sertemp1 - '0') ; - //pc.printf("%d,",n1); - } - if ( Sertemp2 < '0' || Sertemp2 > '9' ) { - // error - } else { - n2 = (int)(Sertemp2 - '0') ; - //pc.printf("%d,",n2); - } - if ( Sertemp3 < '0' || Sertemp3 > '9' ) { - // error - } else { - n3 = (int)(Sertemp3 - '0') ; - //pc.printf("%d\r\n",n3); - } - n = (n1 * 100) + (n2 * 10) + n3; - LineNumber = n; - pc.printf("Line:%d\r\n",n); + //路線名 L + //ABuffer[0]は'L' + LineNumber = CharToInt(ABuffer[1],ABuffer[2],ABuffer[3]); + pc.printf("Line:%d\r\n",LineNumber); } //種別 K if(ABuffer[0] == 'K'){ - unsigned char Sertemp1 = ABuffer[1]; - unsigned char Sertemp2 = ABuffer[2]; - unsigned char Sertemp3 = ABuffer[3]; - int n1 = 0 ; - int n2 = 0 ; - int n3 = 0 ; - int n = 0; - - - if ( Sertemp1 < '0' || Sertemp1 > '9' ) { - // error - } else { - n1 = (int)(Sertemp1 - '0') ; - //pc.printf("%d,",n1); - } - if ( Sertemp2 < '0' || Sertemp2 > '9' ) { - // error - } else { - n2 = (int)(Sertemp2 - '0') ; - //pc.printf("%d,",n2); - } - if ( Sertemp3 < '0' || Sertemp3 > '9' ) { - // error - } else { - n3 = (int)(Sertemp3 - '0') ; - //pc.printf("%d,",n3); - } - n = (n1 * 100) + (n2 * 10) + n3; - KindNumber = n; - pc.printf("Kind:%d\r\n",n); + //種別 K + //ABuffer[0]は'K' + KindNumber = CharToInt(ABuffer[1],ABuffer[2],ABuffer[3]); + pc.printf("Kind:%d\r\n",KindNumber); } //行先 F if(ABuffer[0] == 'F'){ - unsigned char Sertemp1 = ABuffer[1]; - unsigned char Sertemp2 = ABuffer[2]; - unsigned char Sertemp3 = ABuffer[3]; - int n1 = 0 ; - int n2 = 0 ; - int n3 = 0 ; - int n = 0; - - - if ( Sertemp1 < '0' || Sertemp1 > '9' ) { - // error - } else { - n1 = (int)(Sertemp1 - '0') ; - //pc.printf("%d,",n1); - } - if ( Sertemp2 < '0' || Sertemp2 > '9' ) { - // error - } else { - n2 = (int)(Sertemp2 - '0') ; - //pc.printf("%d,",n2); - } - if ( Sertemp3 < '0' || Sertemp3 > '9' ) { - // error - } else { - n3 = (int)(Sertemp3 - '0') ; - //pc.printf("%d,",n3); - } - n = (n1 * 100) + (n2 * 10) + n3; - ForNumber = n; - pc.printf("For:%d\r\n",n); + //行先 F + //ABuffer[0]は'F' + ForNumber = CharToInt(ABuffer[1],ABuffer[2],ABuffer[3]); + pc.printf("For:%d\r\n",ForNumber); } - //次停車駅 K + //次停車駅 N if(ABuffer[0] == 'N'){ - unsigned char Sertemp1 = ABuffer[1]; - unsigned char Sertemp2 = ABuffer[2]; - unsigned char Sertemp3 = ABuffer[3]; - int n1 = 0 ; - int n2 = 0 ; - int n3 = 0 ; - int n = 0; - - - if ( Sertemp1 < '0' || Sertemp1 > '9' ) { - // error - } else { - n1 = (int)(Sertemp1 - '0') ; - //pc.printf("%d,",n1); - } - if ( Sertemp2 < '0' || Sertemp2 > '9' ) { - // error - } else { - n2 = (int)(Sertemp2 - '0') ; - //pc.printf("%d,",n2); - } - if ( Sertemp3 < '0' || Sertemp3 > '9' ) { - // error - } else { - n3 = (int)(Sertemp3 - '0') ; - //pc.printf("%d,",n3); - } - n = (n1 * 100) + (n2 * 10) + n3; - NextStaNumber = n; - pc.printf("NextStation:%d\r\n",n); + //次停車駅 N + //ABuffer[0]は'N' + NextStaNumber = CharToInt(ABuffer[1],ABuffer[2],ABuffer[3]); + pc.printf("NextStation:%d\r\n",NextStaNumber); } //スクロール有効/無効 S @@ -997,6 +919,38 @@ pc.printf("Set\r\n"); SDFileRead(); } + + //データ一括設定 + //先頭文字:'A' + if(ABuffer[0] == 'A'){ + //路線名 L + //ABuffer[1]は'L' + LineNumber = CharToInt(ABuffer[2],ABuffer[3],ABuffer[4]); + pc.printf("Line:%d\r\n",LineNumber); + + //種別 K + //ABuffer[5]は'K' + KindNumber = CharToInt(ABuffer[6],ABuffer[7],ABuffer[8]); + pc.printf("Kind:%d\r\n",KindNumber); + + //行先 F + //ABuffer[9]は'F' + ForNumber = CharToInt(ABuffer[10],ABuffer[11],ABuffer[12]); + pc.printf("For:%d\r\n",ForNumber); + + //次停車駅 N + //ABuffer[13]は'N' + NextStaNumber = CharToInt(ABuffer[14],ABuffer[15],ABuffer[16]); + pc.printf("NextStation:%d\r\n",NextStaNumber); + + //一括設定時は続けてSDからの読み込み + pc.printf("Set\r\n"); + SDFileRead(); + Scroll = 0; + //即時反映 + TimerTick(); + } + busyflag = false; }else{ count++;