Aliexpressなどで販売されている64x32のフルカラードットマトリクスLED2枚とNucleo F401REを利用して、 E233系の駅停車時、路線名表示ありのLED側面行先表示を再現するプログラムです。 3秒間隔、3段階切替で、路線名、種別、行先、次停車駅を個別に指定することが可能です。
Dependencies: SDFileSystem mbed
Revision 17:95bcbc53d96b, committed 2014-11-15
- Comitter:
- chirashi
- Date:
- Sat Nov 15 15:21:40 2014 +0000
- Parent:
- 16:d02248f44c4b
- Child:
- 18:b8563e3319fd
- Commit message:
- a;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Nov 14 22:51:39 2014 +0000
+++ b/main.cpp Sat Nov 15 15:21:40 2014 +0000
@@ -69,25 +69,22 @@
//BusIn SumSWNum(PA_0,PA_1,PA_4,PB_0);
-
-
-
Ticker ChangeTimer;
-
//Debug
bool Debug = 0;
-int ChangeCount = 0;
-
-int LineNumber = 0;
-int KindNumber = 0;
-int ForNumber = 0;
-int NextStaNumber = 0;
+int ChangeCount = 0;
+int LineNumber = 37;
+int KindNumber = 1;
+int ForNumber = 1;
+int NextStaNumber = 1;
+char SerialBuffer[30];
+int count = 0;
//SDCardFilePath
-char* SDFilePath = "/sd/a.txt";
+char SDFilePath[80]= "/sd/a.txt";
unsigned char gm[32][6]; // Buffer with 32x6 bytes. Graphics memory if you like.
unsigned long CT; // Counter for demo code
@@ -500,58 +497,116 @@
}
}
-int main()
-{
+void pc_rx(){
+ //pc.putc(pc.getc());
+
+
+ if (pc.readable() == 1) { // 受信したデータが存在する
+ SerialBuffer[count] = pc.getc(); // 受信データを読み込む
+ if (count > 30 || SerialBuffer[count] == '$') { // 文字数が既定の個数を超えた場合、又は終了文字を受信した場合
+ SerialBuffer[count] = '\0'; // 末尾に終端文字を入れる
+ count = 0;
+
+ if(SerialBuffer[0] == 'L'){
+ unsigned char Sertemp1 = SerialBuffer[1];
+ unsigned char Sertemp2 = SerialBuffer[2];
+ unsigned char Sertemp3 = SerialBuffer[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;
+ pc.printf("%d,",n);
+
+
+ }
+
+ }else{
+ count++;
+ }
+ }
+}
+
+int main(){
Init(); // Set things up
//Serial
pc.printf("Power ON\r\n");
+
//SumSW
- SI = HIGH;
- SCK = HIGH;
+ int testData[16] = {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0};
SI = LOW;
- SCK = LOW;
-
- for(int a = 0; a < 14; a++){
+ for(int a = 0; a < 16; a++){
+ if(testData[a] == 1){
+ SI = HIGH;
+ pc.printf("1,");
+ }else{
+ SI = LOW;
+ pc.printf("0,");
+ }
SCK = HIGH;
- SCK = LOW;
+ wait_us(15);
+ SCK = LOW;
+ wait_us(15);
}
RCK = HIGH;
+ wait_us(15);
RCK = LOW;
+ pc.printf("\r\n");
int SumSWNum = 0;
-
- if(SumSW1){
+ if(SumSW1 == 1 ){
SumSWNum = SumSWNum + 1;
}
- if(SumSW2){
+ if(SumSW2 == 1){
SumSWNum = SumSWNum + 2;
}
- if(SumSW4){
+ if(SumSW4 == 1){
SumSWNum = SumSWNum + 4;
}
- if(SumSW8){
+ if(SumSW8 == 1){
SumSWNum = SumSWNum + 8;
}
-
-
-
-
pc.printf("SumSW:%d\r\n",SumSWNum);
-
//SDCard
- SDFilePath = "/sd/E233/Kind/2.bin";
+ sprintf(SDFilePath,"/sd/E233/Kind/%d.bin",KindNumber);
+ //SDFilePath = "/sd/E233/Kind/2.bin";
SDBufferWrite(LEDBuffer,0,0,48,32);
- SDFilePath = "/sd/E233/For/1.bin";
+ //SDFilePath = "/sd/E233/For/1.bin";
+ sprintf(SDFilePath,"/sd/E233/For/%d.bin",ForNumber);
SDBufferWrite(LEDBuffer,48,0,80,16);
-
- SDFilePath = "/sd/E233/Line/37.bin";
+
+ //SDFilePath = "/sd/E233/Line/37.bin";
+ sprintf(SDFilePath,"/sd/E233/Line/%d.bin",LineNumber);
+ //pc.printf("%s\r\n",SDFilePath);
SDBufferWrite(LEDBuffer,48,0,80,32);
- SDFilePath = "/sd/E233/NextStation/1.bin";
+
+ //SDFilePath = "/sd/E233/NextStation/1.bin";
+ sprintf(SDFilePath,"/sd/E233/NextStation/%d.bin",NextStaNumber);
SDBufferWrite(LEDBuffer,48,16,80,16);
@@ -572,10 +627,15 @@
pc.printf("\r\n");
}
}
-
+ //Serial
+ pc.attach(pc_rx, Serial::RxIrq);
+
//DisplayTimer
ChangeTimer.attach(&TimerTick,3);
+
+
+
while(1) {
CT++;
if (ChangeCount == 0){