Aliexpressなどで販売されている64x32のフルカラードットマトリクスLED2枚とNucleo F401REを利用して、 E233系の駅停車時、路線名表示ありのLED側面行先表示を再現するプログラムです。 3秒間隔、3段階切替で、路線名、種別、行先、次停車駅を個別に指定することが可能です。

Dependencies:   SDFileSystem mbed

Revision:
28:4cc6aa3acd92
Parent:
27:3dccc05e760b
Child:
29:bc82c25b6b94
diff -r 3dccc05e760b -r 4cc6aa3acd92 main.cpp
--- a/main.cpp	Mon Jan 12 05:09:51 2015 +0000
+++ b/main.cpp	Mon Feb 02 11:44:47 2015 +0000
@@ -86,12 +86,12 @@
 DigitalOut LAT(PB_15);    //  Data latch    - active low (pulse up after data load)
 DigitalOut OE(PB_1);     //  Output enable - active low (hold high during data load, bring low after LAT pulse)
 
-DigitalOut R1(D4);     //  RED   Serial in for upper half
-DigitalOut R2(D5);     //  RED   Serial in for lower half
-DigitalOut G1(D6);      //  GREEN Serial in for upper half
-DigitalOut G2(D7);      //  GREEN Serial in for lower half
-DigitalOut B1(D2);      //  BLUE  Serial in for upper half
-DigitalOut B2(D3);      //  BLUE  Serial in for lower half
+DigitalOut R1(D6);     //  RED   Serial in for upper half
+DigitalOut R2(D7);     //  RED   Serial in for lower half
+DigitalOut G1(D2);      //  GREEN Serial in for upper half
+DigitalOut G2(D3);      //  GREEN Serial in for lower half
+DigitalOut B1(D4);      //  BLUE  Serial in for upper half
+DigitalOut B2(D5);      //  BLUE  Serial in for lower half
 
 
 
@@ -132,10 +132,10 @@
 int DisplayMode = 1;
 
 //スクロール有効/無効(テスト用)
-bool Scroll = 0;
+bool Scroll = 1;
 
 //起動時スクロール読み込み有効/無効(SDがない場合0にする)
-bool ScrollEnable = 0;
+bool ScrollEnable = 1;
 
 int ChangeCount = 0;
 int LineNumber = 12;
@@ -332,22 +332,42 @@
 //16 Green(Utsunomiya Line)
 //17 Green(Joban Local Local)
 //18 Keikyu Logo(Gray
-bool R1Data1[32]={0,1,0,0,1,0,1,1,0,1,1,1,1,0,1,1,0,0,1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,1,0,1,0,0,0,0,0,0,0,0,0,1,0}
+};
 
-bool B1Data1[32]={0,0,0,1,0,1,1,1,1,1,0,0,0,0,0,1,0,1,1};
-bool B1Data2[32]={0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,1,1};
-bool B1Data3[32]={0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0};
-bool B1Data4[32]={0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0};
+bool B1Data[8][32]={
+{0,0,0,1,0,1,1,1,1,1,0,0,0,0,0,1,0,1,1},
+{0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,1,1},
+{0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
+{0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
 
-  
+{0,0,0,1,0,1,1,1,1,1,0,0,0,0,0,1,0,1,1},
+{0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,1,1},
+{0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
+{0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0}
+};
 
 
 
@@ -362,144 +382,23 @@
 
 }
 
-
-
-void WrRow(unsigned char Row, int8_t Buffer[32][128])
+void WriteRow(unsigned char Row, int8_t Buffer[32][128], int8_t index)
 {
-    // Write specified row (and row+8) to display. Valid input: 0 to 7.
-    ABC = 15-Row; // Set row address
-    for(int col=0; col<LED_Width; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
-               
-        if (Buffer [(15-Row)][col] == 0){
-            R1 = R_Debug1;
-            G1 = G_Debug1;
-            B1 = B_Debug1;    
-        }else {
-            //R1 = R1Data1[(LEDBuffer [(7-Row)][col])];
-            //G1 = G1Data1[(LEDBuffer [(7-Row)][col])];
-            //B1 = B1Data1[(LEDBuffer [(7-Row)][col])];
-            R1 = R1Data1[(Buffer [(15-Row)][col])];
-            G1 = G1Data1[(Buffer [(15-Row)][col])];
-            B1 = B1Data1[(Buffer [(15-Row)][col])];                      
-        }
-        
-        if (Buffer [(31-Row)][col] == 0){
-            R2 = R_Debug1;
-            G2 = G_Debug1;
-            B2 = B_Debug1;    
-        }else {
-            R2 = R1Data1[(Buffer [(31-Row)][col])];
-            G2 = G1Data1[(Buffer [(31-Row)][col])];
-            B2 = B1Data1[(Buffer [(31-Row)][col])];           
-        }
-        
-        CLK = HIGH;                 // tick (clock bit in)
-        CLK = LOW;                  // tock
+    ABC = 15-Row; 
+    for(int col=0; col<LED_Width; col++) { 
+        R1 = R1Data[index][(Buffer [(15-Row)][col])];
+        G1 = G1Data[index][(Buffer [(15-Row)][col])];   
+        B1 = B1Data[index][(Buffer [(15-Row)][col])];                        
+        R2 = R1Data[index][(Buffer [(31-Row)][col])]; 
+        G2 = G1Data[index][(Buffer [(31-Row)][col])];
+        B2 = B1Data[index][(Buffer [(31-Row)][col])];                  
+        CLK = HIGH;                 
+        CLK = LOW;                  
     }
-    LAT = HIGH; // Latch entire row
+    LAT = HIGH; 
     LAT = LOW;
 }
 
-void WrRow2(unsigned char Row,int8_t Buffer[32][128])
-{
-    // Write specified row (and row+8) to display. Valid input: 0 to 7.
-    ABC = 15-Row; // Set row address
-    for(int col=0; col<LED_Width; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
-  
-        if (Buffer [(15-Row)][col] == 0){
-            R1 = R_Debug2;
-            G1 = G_Debug2;
-            B1 = B_Debug2;    
-        }else{
-            R1 = R1Data2[(Buffer [(15-Row)][col])];
-            G1 = G1Data2[(Buffer [(15-Row)][col])];
-            B1 = B1Data2[(Buffer [(15-Row)][col])];           
-        }
-
-        if (Buffer [(31-Row)][col] == 0){
-            R2 = R_Debug2;
-            G2 = G_Debug2;
-            B2 = B_Debug2;    
-        }else{
-            R2 = R1Data2[(Buffer [(31-Row)][col])];
-            G2 = G1Data2[(Buffer [(31-Row)][col])];
-            B2 = B1Data2[(Buffer [(31-Row)][col])];           
-        }    
-               
-        CLK = HIGH;                 // tick (clock bit in)
-        CLK = LOW;                  // tock
-    }
-    LAT = HIGH; // Latch entire row
-    LAT = LOW;
-}
-
-void WrRow3(unsigned char Row,int8_t Buffer[32][128])
-{
-    // Write specified row (and row+8) to display. Valid input: 0 to 7.
-    ABC = 15-Row; // Set row address
-    for(int col=0; col<LED_Width; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
-  
-        if (Buffer [(15-Row)][col] == 0){
-            R1 = R_Debug3;
-            G1 = G_Debug3;
-            B1 = B_Debug3;    
-        }else{
-            R1 = R1Data3[(Buffer [(15-Row)][col])];
-            G1 = G1Data3[(Buffer [(15-Row)][col])];
-            B1 = B1Data3[(Buffer [(15-Row)][col])];           
-        }
-
-        if (Buffer [(31-Row)][col] == 0){
-            R2 = R_Debug3;
-            G2 = G_Debug3;
-            B2 = B_Debug3;    
-        }else{
-            R2 = R1Data3[(Buffer [(31-Row)][col])];
-            G2 = G1Data3[(Buffer [(31-Row)][col])];
-            B2 = B1Data3[(Buffer [(31-Row)][col])];           
-        }
-               
-        CLK = HIGH;                 // tick (clock bit in)
-        CLK = LOW;                  // tock
-    }
-    LAT = HIGH; // Latch entire row
-    LAT = LOW;
-}
-
-void WrRow4(unsigned char Row,int8_t Buffer[32][128])
-{
-    // Write specified row (and row+8) to display. Valid input: 0 to 7.
-    ABC = 15-Row; // Set row address
-    for(int col=0; col<LED_Width; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
-  
-        if (Buffer [(15-Row)][col] == 0){
-            R1 = R_Debug4;
-            G1 = G_Debug4;
-            B1 = B_Debug4;    
-        }else{
-            R1 = R1Data4[(Buffer [(15-Row)][col])];
-            G1 = G1Data4[(Buffer [(15-Row)][col])];
-            B1 = B1Data4[(Buffer [(15-Row)][col])];            
-        }
-
-        if (Buffer [(31-Row)][col] == 0){
-            R2 = R_Debug4;
-            G2 = G_Debug4;
-            B2 = B_Debug4;    
-        }else{
-            R2 = R1Data4[(Buffer [(31-Row)][col])];
-            G2 = G1Data4[(Buffer [(31-Row)][col])];
-            B2 = B1Data4[(Buffer [(31-Row)][col])];           
-        }  
-               
-        CLK = HIGH;                 // tick (clock bit in)
-        CLK = LOW;                  // tock
-    }
-    LAT = HIGH; // Latch entire row
-    LAT = LOW;
-}
-
-
 void WrRowOFF(unsigned char Row)
 {
     // Write specified row (and row+8) to display. Valid input: 0 to 7.
@@ -536,48 +435,18 @@
 
 void Paint(int8_t Buffer2[32][128])
 {
-    // Write graphics memory to display
-    //1
-    for(int Row=0; Row<LED_Height; Row++) {
-        OE = HIGH; // Disable output
-        WrRow(Row,Buffer2);
-        //wait_us(10);
-        OE = LOW; // Enable output
-        
-        wait_us(DisplayWait); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
+    for(int index = 0; index < 4; index++){
+        for(int Row=0; Row<LED_Height; Row++) {
+            OE = HIGH; // Disable output
+            WriteRow(Row,Buffer2,index);
+            //wait_us(10);
+            OE = LOW; // Enable output
+            wait_us(DisplayWait); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
+        }     
     }
-    //2
-    for(int Row=0; Row<LED_Height; Row++) {
-        OE = HIGH; // Disable output
-        //WrRow(Row);
-        WrRow2(Row,Buffer2);
-        //wait_us(10);
-        OE = LOW; // Enable output
-        
-        wait_us(DisplayWait); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
-    }    
-    //3
-    for(int Row=0; Row<LED_Height; Row++) {
-        OE = HIGH; // Disable output
-        WrRow3(Row,Buffer2);
-        //wait_us(10);
-        OE = LOW; // Enable output
-        
-        wait_us(DisplayWait); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
-    }        
-    //4
-    for(int Row=0; Row<LED_Height; Row++) {
-        OE = HIGH; // Disable output
-        WrRow4(Row,Buffer2);
-        //wait_us(10);
-        OE = LOW; // Enable output
-        
-        wait_us(DisplayWait); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
-    }       
 }
 
 
-
 void PaintOFF()
 {
     // Write graphics memory to display
@@ -1210,9 +1079,15 @@
     }
     
     //test
-    //sprintf(SDFilePath,"/sd/E233/test2.bin");
+    //sprintf(SDFilePath,"/sd/E233/whitetest.bin");
     //SDBufferWrite(LEDBuffer,0,0,128,32);   
     
+    //2段階表示に変更
+    DisplayMode = 2;
+    
+    
+    
+    
     
     //Serial     
     pc.attach(pc_rx, Serial::RxIrq);