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

Dependencies:   SDFileSystem mbed

main.cpp

Committer:
chirashi
Date:
2014-11-14
Revision:
16:d02248f44c4b
Parent:
15:12895e9c6965
Child:
17:95bcbc53d96b

File content as of revision 16:d02248f44c4b:

/*
The goal of this program is to show the basic connections and workings of Adafruits 32x16 RGB LED matrix board (http://www.adafruit.com/products/420),
also sold on other places, for instance http://www.ebay.com/itm/PH6-RGB-Full-Color-LED-16-32-Dot-Matrix-Display-Module-/310303408628?pt=LH_DefaultDomain_0&hash=item483f8641f4 (no
affiliation with either of them).
This program is not intended to be highly optimized or a guideline in C programming in any way (more of the opposite actually).
To have more than 7 colors on this thing, you need to implement software PWM of some sort. I have obviously not done that, but if YOU do, please let me know!
Adafruit have a wicked demo program for an arduino - www.youtube.com/watch?v=lY-flFEfsHo
There are probably lots of ways to make this perform better, perhaps by using Neal Hormans port of the Adafruit_GFX library (http://mbed.org/users/nkhorman/code/Adafruit_GFX/).
No error checking or out-of-bounds checking is done. Use at your own peril.
For more detailed information on the driver chip, see http://www.bjtopspace.com/ziliao/CYT62726.pdf
Although the chips on my board says jx15020, I've been informed that they are equvivalent to the CYT62726, and so far it's a match.
Feel free to use all or parts of this work.
If you choose to do so, I would appreciate a small mentioning in the scrolling opening credits ;)

Best regards,
Hugo Harming
upgraded@hotmail.com
*/

#include "mbed.h"
#include "SDFileSystem.h"

#define LOW 0
#define HIGH 1

#define R_Debug1 0
#define R_Debug2 0
#define R_Debug3 0
#define R_Debug4 0

#define G_Debug1 0
#define G_Debug2 0
#define G_Debug3 0
#define G_Debug4 0

#define B_Debug1 0
#define B_Debug2 0
#define B_Debug3 0
#define B_Debug4 0


#define LED_Width 128
#define LED_Height 16


SDFileSystem sd(D11, D12, D13, D10, "sd");
Serial pc(USBTX,USBRX );
BusOut ABC(D8,D9,PB_13,D14); // Row address.
DigitalOut CLK(PB_14);    //  Data clock    - rising edge
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(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


//SumSW
DigitalOut SCK(PB_7); 
DigitalOut SI(PC_13); 
DigitalOut RCK(PC_14); 

DigitalIn SumSW1(PA_0);
DigitalIn SumSW2(PA_1);
DigitalIn SumSW4(PA_4);
DigitalIn SumSW8(PB_0);

//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;



//SDCardFilePath
char* SDFilePath = "/sd/a.txt";

unsigned char gm[32][6]; // Buffer with 32x6 bytes. Graphics memory if you like.
unsigned long CT; //        Counter for demo code



int8_t LEDBuffer [32][128] = {
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,7,7,7,0,0,0,0,0,7,7,7,7,7,7,0,0,0,0,0,0,7,7,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,7,7,7,0,0,0,7,7,7,15,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,7,7,7,0,0,0,0,0,0,7,7,7,7,7,0,0,0,0,0,0,7,7,7,15,15,15,15,15,15,15,15,15,15,15,0,0,0,0,15,7,7,7,0,0,0,0,0,7,7,7,15,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,7,7,7,0,0,0,0,0,0,0,7,7,7,7,0,0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,0,15,7,7,7,0,0,0,0,0,0,0,7,7,7,15,0,0,0,0,0,0},
{14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,7,7,7,14,14,14,14,14,14,14,14,7,7,7,14,14,14,14,14,14,7,7,7,7,7,7,7,7,7,7,7,7,7,7,14,14,15,7,7,7,14,14,14,14,14,14,14,14,14,7,7,7,15,14,14,14,14,14},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,7,7,1,1,1,1,1,1,1,1,1,7,7,1,1,1,1,1,1,7,7,7,7,7,7,7,7,7,7,7,7,7,7,1,1,7,7,7,1,1,1,1,1,1,1,1,1,1,1,7,7,7,1,1,1,1,1},
{14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}


};

int8_t LEDBuffer2[32][128] = {
{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,0,0,0,0,0,0,0,0,7,7,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,7,7,7,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,7,0,0,7,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0},      
{9,9,9,9,9,9,9,9,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,1,0,1,1,1,1,0,1,1,0};
bool R1Data2[32]={0,1,0,0,1,0,1,1,0,1,1,0,1,0,0,0,0};
bool R1Data3[32]={0,1,0,0,1,0,1,1,0,1,1,0,1,0,0,0,0};
bool R1Data4[32]={0,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,0};

bool G1Data1[32]={0,0,1,0,1,1,0,1,1,0,1,1,1,1,0,1,1};
bool G1Data2[32]={0,0,1,0,1,1,0,1,1,0,1,1,0,0,0,0,1};
bool G1Data3[32]={0,0,1,0,1,1,0,1,0,0,0,0,0,0,0,0,0};
bool G1Data4[32]={0,0,1,0,1,1,0,1,0,0,0,0,0,0,0,0,0};

bool B1Data1[32]={0,0,0,1,0,1,1,1,1,1,0,0,0,0,0,1,0};
bool B1Data2[32]={0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0};
bool B1Data3[32]={0,0,0,1,0,1,1,1,1,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};

  



void Init()
{
    // Set up things to a known state
    CLK = LOW;
    LAT = LOW;
    OE = HIGH; //display off
    ABC = 0;
    CT=0;

}



void WrRow(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_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
    }
    LAT = HIGH; // Latch entire row
    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.
    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.
        R1 = 0; // Red bit, upper half
        G1 = 0; // Green bit, upper half
        B1 = 0; // Blue bit, upper half
        R2 = 0; // Red bit, lower half
        G2 = 0; // Green bit, lower half
        B2 = 0; // Blue bit, lower half
        CLK = HIGH;                 // tick (clock bit in)
        CLK = LOW;                  // tock
    }
    LAT = HIGH; // Latch entire row
    LAT = LOW;
}

void Pset(unsigned char x,unsigned char y, unsigned char c)
{
    // Set pixel (x,y) to color c
    // Manipulates graphics memory, so you won't see any change til you Paint() it.
    unsigned char ud,l,r0,g0,b0;
    ud=(y & 8)>>3; // 0 = upper half, 1 = lower half
    l=y & 7; // Extract row in upper/lower half
    r0=(c & 4) >>2; // Extract red bit from color
    g0=(c & 2) >>1; // Extract green bit from color
    b0=(c & 1); //     Extract blue bit from color
    //            *******Removes current bit ******* *Adds bit**
    gm[x][0+3*ud]=(gm[x][0+3*ud] & (255-(1<<(7-l))))+(r0<<(7-l)); // Red byte
    gm[x][1+3*ud]=(gm[x][1+3*ud] & (255-(1<<(7-l))))+(g0<<(7-l)); // Green byte
    gm[x][2+3*ud]=(gm[x][2+3*ud] & (255-(1<<(7-l))))+(b0<<(7-l)); // Blue byte
}

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(15); // 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(15); // 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(15); // 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(15); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
    }       
}



void PaintOFF()
{
    // Write graphics memory to display
    for(int Row=0; Row<8; Row++) {
        OE = HIGH; // Disable output
        WrRowOFF(Row);
        OE = LOW; // Enable output
        wait_us(50); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
    }
}

void TimerTick(){
    if (ChangeCount == 0){
        ChangeCount = ChangeCount + 1;
    }else if(ChangeCount == 1 ){
        ChangeCount = ChangeCount + 1;
        //ChangeCount = 0;
    }else if(ChangeCount == 2){     
        ChangeCount = 0;
    }else{
         
    }   
}

//書込み対象バッファ,書込み開始位置x,書込み開始位置y,読み出し幅x,読み出し高さy
void SDBufferWrite(int8_t TargetBuffer[32][128], int Startx, int Starty, int Readx, int Ready){
    FILE *fp = fopen(SDFilePath, "r");
        if(fp == NULL) {
            pc.printf("SDFileOpen Error %s\r\n",SDFilePath);
            //error("Could not open file for write\r\n");
        }else{
            //fprintf(fp, "Hello fun SD Card World!");
            pc.printf("SDFileOpen Success %s\r\n",SDFilePath);
        
            //SDDataReadtest
            int8_t Data;
            for(int y = Starty; y < Starty + Ready; y++){  
                for(int x = Startx; x < Startx + Readx; x++){
                    Data = getc(fp);
                    TargetBuffer[y][x] = Data;    
                }           
            }           
            fclose(fp); 
        }
}

int main()
{
    Init(); // Set things up
    //Serial
    pc.printf("Power ON\r\n");
    
    //SumSW
    SI = HIGH;
    SCK = HIGH;
    SI = LOW;
    SCK = LOW;
    
    for(int a = 0; a < 14; a++){
        SCK = HIGH;
        SCK = LOW;     
    }
    
    RCK = HIGH;
    RCK = LOW;
    
    int SumSWNum = 0;
    
    if(SumSW1){
        SumSWNum = SumSWNum + 1;
    }
    if(SumSW2){
        SumSWNum = SumSWNum + 2;
    }
    if(SumSW4){
        SumSWNum = SumSWNum + 4;
    }
    if(SumSW8){
        SumSWNum = SumSWNum + 8;
    }    
    
    
    
    
    pc.printf("SumSW:%d\r\n",SumSWNum);
    
    
    //SDCard
    SDFilePath = "/sd/E233/Kind/2.bin";
    SDBufferWrite(LEDBuffer,0,0,48,32);
    
    SDFilePath = "/sd/E233/For/1.bin";
    SDBufferWrite(LEDBuffer,48,0,80,16);

    SDFilePath = "/sd/E233/Line/37.bin";
    SDBufferWrite(LEDBuffer,48,0,80,32);
    
    SDFilePath = "/sd/E233/NextStation/1.bin";
    SDBufferWrite(LEDBuffer,48,16,80,16);    
    
    
    
    //Debug
    if(Debug == 1){
        //DataSerialOut
        for(int y = 0; y < 32; y++){
            for(int x = 0; x <128; x++){
                if(LEDBuffer[y][x]== 0){
                    //pc.printf("0,"); 
                    pc.printf("  "); 
                }else{
                    //pc.printf("#"); 
                    pc.printf("%.02d",LEDBuffer[y][x]); 
                }
            }
            pc.printf("\r\n");           
        }
    }
         
    //DisplayTimer
    ChangeTimer.attach(&TimerTick,3);
    
    while(1) { 
        CT++;
        if (ChangeCount == 0){
            Paint(LEDBuffer);
        }else if(ChangeCount == 1){
            Paint(LEDBuffer2);
        }else if(ChangeCount == 2){
            Paint(LEDBuffer3);
        }
        
        if(CT>4160) {
            //MkPattern(); // Restore original priceless artwork
            CT=0; // Start all over.
        }
        
        //PaintOFF();
        //wait_us(10);
    }
    
}