Aliexpressなどで販売されている64x32のフルカラードットマトリクスLED2枚とNucleo F401REを利用して、 E233系の駅停車時、路線名表示ありのLED側面行先表示を再現するプログラムです。 3秒間隔、3段階切替で、路線名、種別、行先、次停車駅を個別に指定することが可能です。
Dependencies: SDFileSystem mbed
Revision 5:532937f20397, committed 2014-10-20
- Comitter:
- chirashi
- Date:
- Mon Oct 20 13:07:52 2014 +0000
- Parent:
- 4:245f17936b1a
- Child:
- 6:e6cb4a476422
- Commit message:
- ; 65; ;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Oct 19 16:20:02 2014 +0000
+++ b/main.cpp Mon Oct 20 13:07:52 2014 +0000
@@ -124,30 +124,26 @@
//R2 = gm[col][3] & (1<<Row); // Red bit, lower half
//G2 = gm[col][4] & (1<<Row); // Green bit, lower half
//B2 = gm[col][5] & (1<<Row); // Blue bit, lower half
-
-
+
if (LEDBuffer [(7-Row)][col] == 2){
R1 = 1;
G1 = 1;
- B1 = 0;
+ B1 = 1;
}else{
R1 = 0;
- G1 = 0;
+ G1 = 1;
B1 = 0;
}
if (LEDBuffer [(15-Row)][col] == 2){
R2 = 1;
- G2 = 0;
- B2 = 0;
+ G2 = 1;
+ B2 = 1;
}else{
R2 = 0;
- G2 = 0;
- B2 = 0;
- }
-
-
-
+ G2 = 1;
+ B2 = 1;
+ }
CLK = HIGH; // tick (clock bit in)
CLK = LOW; // tock
@@ -161,14 +157,106 @@
// Write specified row (and row+8) to display. Valid input: 0 to 7.
ABC = 7-Row; // Set row address
for(int col=0; col<32; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
- //R1 = gm[col][0] & (1<<Row); // Red bit, upper half
- //G1 = gm[col][1] & (1<<Row); // Green bit, upper half
- //B1 = gm[col][2] & (1<<Row); // Blue bit, upper half
- //R2 = gm[col][3] & (1<<Row); // Red bit, lower half
- //G2 = gm[col][4] & (1<<Row); // Green bit, lower half
- //B2 = gm[col][5] & (1<<Row); // Blue bit, lower half
-
-
+
+ if (LEDBuffer [(7-Row)][col] == 2){
+ R1 = 1;
+ G1 = 1;
+ B1 = 1;
+ }else{
+ R1 = 0;
+ G1 = 1;
+ B1 = 0;
+ }
+
+ if (LEDBuffer [(15-Row)][col] == 2){
+ R2 = 1;
+ G2 = 1;
+ B2 = 1;
+ }else{
+ R2 = 0;
+ G2 = 1;
+ B2 = 1;
+ }
+
+ CLK = HIGH; // tick (clock bit in)
+ CLK = LOW; // tock
+ }
+ LAT = HIGH; // Latch entire row
+ LAT = LOW;
+}
+
+void WrRow3(unsigned char Row)
+{
+ // Write specified row (and row+8) to display. Valid input: 0 to 7.
+ ABC = 7-Row; // Set row address
+ for(int col=0; col<32; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
+
+ if (LEDBuffer [(7-Row)][col] == 2){
+ R1 = 1;
+ G1 = 1;
+ B1 = 1;
+ }else{
+ R1 = 0;
+ G1 = 0;
+ B1 = 0;
+ }
+
+ if (LEDBuffer [(15-Row)][col] == 2){
+ R2 = 1;
+ G2 = 1;
+ B2 = 1;
+ }else{
+ R2 = 0;
+ G2 = 0;
+ B2 = 1;
+ }
+
+ CLK = HIGH; // tick (clock bit in)
+ CLK = LOW; // tock
+ }
+ LAT = HIGH; // Latch entire row
+ LAT = LOW;
+}
+
+void WrRow4(unsigned char Row)
+{
+ // Write specified row (and row+8) to display. Valid input: 0 to 7.
+ ABC = 7-Row; // Set row address
+ for(int col=0; col<32; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
+
+ if (LEDBuffer [(7-Row)][col] == 2){
+ R1 = 1;
+ G1 = 1;
+ B1 = 1;
+ }else{
+ R1 = 0;
+ G1 = 0;
+ B1 = 0;
+ }
+
+ if (LEDBuffer [(15-Row)][col] == 2){
+ R2 = 1;
+ G2 = 1;
+ B2 = 1;
+ }else{
+ R2 = 0;
+ G2 = 0;
+ B2 = 0;
+ }
+
+ CLK = HIGH; // tick (clock bit in)
+ CLK = LOW; // tock
+ }
+ LAT = HIGH; // Latch entire row
+ LAT = LOW;
+}
+
+void WrRow5(unsigned char Row)
+{
+ // Write specified row (and row+8) to display. Valid input: 0 to 7.
+ ABC = 7-Row; // Set row address
+ for(int col=0; col<32; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
+
if (LEDBuffer [(7-Row)][col] == 2){
R1 = 1;
G1 = 1;
@@ -181,17 +269,47 @@
if (LEDBuffer [(15-Row)][col] == 2){
R2 = 1;
- G2 = 0;
+ G2 = 1;
B2 = 1;
}else{
R2 = 0;
G2 = 0;
B2 = 0;
}
-
-
-
-
+
+ CLK = HIGH; // tick (clock bit in)
+ CLK = LOW; // tock
+ }
+ LAT = HIGH; // Latch entire row
+ LAT = LOW;
+}
+
+void WrRow6(unsigned char Row)
+{
+ // Write specified row (and row+8) to display. Valid input: 0 to 7.
+ ABC = 7-Row; // Set row address
+ for(int col=0; col<32; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
+
+ if (LEDBuffer [(7-Row)][col] == 2){
+ R1 = 1;
+ G1 = 1;
+ B1 = 1;
+ }else{
+ R1 = 0;
+ G1 = 0;
+ B1 = 0;
+ }
+
+ if (LEDBuffer [(15-Row)][col] == 2){
+ R2 = 1;
+ G2 = 1;
+ B2 = 1;
+ }else{
+ R2 = 0;
+ G2 = 0;
+ B2 = 0;
+ }
+
CLK = HIGH; // tick (clock bit in)
CLK = LOW; // tock
}
@@ -199,6 +317,71 @@
LAT = LOW;
}
+void WrRow7(unsigned char Row)
+{
+ // Write specified row (and row+8) to display. Valid input: 0 to 7.
+ ABC = 7-Row; // Set row address
+ for(int col=0; col<32; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
+
+ if (LEDBuffer [(7-Row)][col] == 2){
+ R1 = 1;
+ G1 = 1;
+ B1 = 1;
+ }else{
+ R1 = 0;
+ G1 = 0;
+ B1 = 0;
+ }
+
+ if (LEDBuffer [(15-Row)][col] == 2){
+ R2 = 1;
+ G2 = 1;
+ B2 = 1;
+ }else{
+ R2 = 0;
+ G2 = 0;
+ B2 = 0;
+ }
+
+ CLK = HIGH; // tick (clock bit in)
+ CLK = LOW; // tock
+ }
+ LAT = HIGH; // Latch entire row
+ LAT = LOW;
+}
+
+void WrRow8(unsigned char Row)
+{
+ // Write specified row (and row+8) to display. Valid input: 0 to 7.
+ ABC = 7-Row; // Set row address
+ for(int col=0; col<32; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
+
+ if (LEDBuffer [(7-Row)][col] == 2){
+ R1 = 1;
+ G1 = 1;
+ B1 = 1;
+ }else{
+ R1 = 0;
+ G1 = 0;
+ B1 = 0;
+ }
+
+ if (LEDBuffer [(15-Row)][col] == 2){
+ R2 = 1;
+ G2 = 1;
+ B2 = 1;
+ }else{
+ R2 = 0;
+ G2 = 0;
+ B2 = 0;
+ }
+
+ 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.
@@ -236,20 +419,81 @@
void Paint()
{
// Write graphics memory to display
+ //1
for(int Row=0; Row<8; Row++) {
OE = HIGH; // Disable output
WrRow(Row);
//WrRow2(Row);
+ //wait_us(10);
+ OE = LOW; // Enable output
+
+ wait_us(5); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
+ }
+ //2
+ for(int Row=0; Row<8; Row++) {
+ OE = HIGH; // Disable output
+ //WrRow(Row);
+ WrRow2(Row);
+ //wait_us(10);
+ OE = LOW; // Enable output
+
+ wait_us(5); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
+ }
+ //3
+ for(int Row=0; Row<8; Row++) {
+ OE = HIGH; // Disable output
+ WrRow3(Row);
+ //wait_us(10);
+ OE = LOW; // Enable output
+
+ wait_us(5); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
+ }
+ //4
+ for(int Row=0; Row<8; Row++) {
+ OE = HIGH; // Disable output
+ WrRow4(Row);
+ //wait_us(10);
OE = LOW; // Enable output
- wait_us(25); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
+ wait_us(5); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
+ }
+ //5
+ for(int Row=0; Row<8; Row++) {
+ OE = HIGH; // Disable output
+ WrRow5(Row);
+ //wait_us(10);
+ OE = LOW; // Enable output
+
+ wait_us(5); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
+ }
+ //6
+ for(int Row=0; Row<8; Row++) {
+ OE = HIGH; // Disable output
+ WrRow6(Row);
+ //wait_us(10);
+ OE = LOW; // Enable output
+
+ wait_us(5); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
}
-
-
-
-
-
-
+ //7
+ for(int Row=0; Row<8; Row++) {
+ OE = HIGH; // Disable output
+ WrRow7(Row);
+ //wait_us(10);
+ OE = LOW; // Enable output
+
+ wait_us(5); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
+ }
+ //8
+ for(int Row=0; Row<8; Row++) {
+ OE = HIGH; // Disable output
+ WrRow8(Row);
+ //wait_us(10);
+ OE = LOW; // Enable output
+
+ wait_us(5); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
+ }
+
}
void Paint2()
@@ -261,7 +505,7 @@
WrRow2(Row);
OE = LOW; // Enable output
- wait_us(25); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
+ wait_us(20); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
}
}
@@ -286,7 +530,7 @@
CT++;
Paint(); // Refresh display
- Paint2(); // Refresh display
+ //Paint2(); // Refresh display
//if((CT<=2560)||(CT>=2880 && CT<=4160)) {
// Paint(); // Refresh display
@@ -320,7 +564,7 @@
}
//PaintOFF();
- //wait_us(160);
+ wait_us(10);
}
}