LEDmatrix
Dependencies: mbed
Revision 0:ddaa166a52da, committed 2018-09-01
- Comitter:
- Yuto_K
- Date:
- Sat Sep 01 09:48:17 2018 +0000
- Commit message:
- LEDmatrix
Changed in this revision
diff -r 000000000000 -r ddaa166a52da led_func.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/led_func.h Sat Sep 01 09:48:17 2018 +0000 @@ -0,0 +1,112 @@ +#include "necleo_pin.h" + +#define L 0 +#define H 1 + +#define R 0 +#define G 1 +#define B 2 + +class Dot{ + public: + bool red; + bool green; + bool blue; +}; + +Dot led_board[16][16]; + +void ResetBoard(){ + for(char i=0;i<16;i++){ + for(char j=0;j<16;j++){ + led_board[i][j].red=false; + led_board[i][j].green=false; + led_board[i][j].blue=false; + } + } +} + +void PrintBoard(){ + CLK=0; + LAT=0; + for(char i=0;i<4;i++){ + OE=H; + Address=i; + for(char j=0;j<32;j++){ + if(i<16){ + Red1=led_board[i][j].red; + Green1=led_board[i][j].green; + Blue1=led_board[i][j].blue; + Red2=led_board[i+8][j].red; + Green2=led_board[i+8][j].green; + Blue2=led_board[i+8][j].blue; + }else{ + Red1=led_board[i+4][j-16].red; + Green1=led_board[i+4][j-16].green; + Blue1=led_board[i+4][j-16].blue; + Red2=led_board[i+12][j-16].red; + Green2=led_board[i+12][j-16].green; + Blue2=led_board[i+12][j-16].blue; + } + wait_us(10); + CLK=H; + wait_us(10); + CLK=L; + } + wait_us(10); + LAT=H; + wait_us(10); + LAT=L; + OE=L; + wait_us(100); + } +} +/*class LED{ + public: + char led_board[16][16]; + void ResetBoard(){ + for(char i=0;i<16;i++){ + for(char j=0;j<16;j++){ + this->led_board[i][j]=1; + } + } + } + void ResetPin(){ + Address=0; + OE=H; + CLK=L; + LAT=L; + } + void PrintLine(char board[16][16],char line){ + this->ResetPin(); + Address=line; + for(char i=0;i<32;i++){ + if(i<16){ + Red1=board[line][i]&R; + Green1=board[line][i]&G; + Blue1=board[line][i]&B; + Red2=board[line+8][i]&R; + Green2=board[line+8][i]&G; + Blue2=board[line+8][i]&B; + }else{ + Red1=board[line+4][i-16]&R; + Green1=board[line+4][i-16]&G; + Blue1=board[line+4][i-16]&B; + Red2=board[line+12][i-16]&R; + Green2=board[line+12][i-16]&G; + Blue2=board[line+12][i-16]&B; + } + CLK=H; + CLK=L; + } + LAT=H; + LAT=L; + OE=L; + } + void PrintBoard(){ + for(char i=0;i<4;i++){ + PrintLine(this->led_board,i); + wait_us(100); + } + } +};*/ \ No newline at end of file
diff -r 000000000000 -r ddaa166a52da main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Sep 01 09:48:17 2018 +0000 @@ -0,0 +1,202 @@ +#include "led_func.h" + +/*int main(){ + while(1){ + myLED=L; + CLK=L; + LAT=L; + Address=0; + wait(0.1); + for(char i=0;i<1;i++){ + CLK=H; + wait(0.1); + CLK=L; + wait(0.1); + Red1=1; + wait(0.1); + } + LAT=H; + wait(0.1); + LAT=L; + wait(0.1); + OE=L; + myLED=H; + wait(0.1); + } +}*/ + +int main(){ + ResetBoard(); + for(char i=0;i<16;i++){ + for(char j=0;j<8;j++){ + led_board[i][j].blue=true; + } + } + while(1){ + PrintBoard(); + } +} + +/*int main(){ + LED LedBoard; + LedBoard.ResetBoard(); + char test[16][16]={{0,1,2,4,3,5,6,7,0,0,0,0,0,0,0,0}}; + LedBoard.led_board[0][0]=B; + while(1){ + LedBoard.PrintBoard(); + } +}*/ +/*char k=0; + +void Init(){ + OE=1; + Address=0; + CLK=0; + LAT=0; +} + +void WriteLine(uint8_t line){ + Init(); + OE=1; + Red1=1; + Green1=0; + Blue1=0; + Red2=1; + Green2=0; + Blue2=0; + Address=line; + for(int j=0;j<32;j++){ + if(line==3&&j==31)Blue1=1; + CLK=1; + CLK=0; + } + LAT=1; + LAT=0; + OE=0; +} + +int main(){ + while(1){ + for(int i=0;i<4;i++){ + WriteLine(i); + wait_us(100); + } + } +}*/ +/*BusOut pin(PC_7,PB_6,PA_7);//9 DS(データ),10 ST_CP(ラッチ),11 SH_CP(クロック) +DigitalOut datapin(PC_7);//9 DS +DigitalOut latchpin(PB_6);//10 ST_CP +DigitalOut clockpin(PA_7);//11 SH_CP + +uint8_t datared; +uint8_t datagreen; +uint8_t datablue; +uint8_t dataarrayred[10]; +uint8_t dataarraygreen[10]; +uint8_t dataarrayblue[10]; + +void setup(){ + dataarrayred[0]=0xff; + dataarrayred[1]=0xfe; + dataarrayred[2]=0xfc; + dataarrayred[3]=0xf8; + dataarrayred[4]=0xf0; + dataarrayred[5]=0xe0; + dataarrayred[6]=0xc0; + dataarrayred[7]=0x80; + dataarrayred[8]=0x00; + + dataarraygreen[0]=0xff; + dataarraygreen[1]=0xfe; + dataarraygreen[2]=0xfc; + dataarraygreen[3]=0xf8; + dataarraygreen[4]=0xf0; + dataarraygreen[5]=0xe0; + dataarraygreen[6]=0xc0; + dataarraygreen[7]=0x80; + dataarraygreen[8]=0x00; + + dataarrayblue[0]=0xff; + dataarrayblue[1]=0xfe; + dataarrayblue[2]=0xfc; + dataarrayblue[3]=0xf8; + dataarrayblue[4]=0xf0; + dataarrayblue[5]=0xe0; + dataarrayblue[6]=0xc0; + dataarrayblue[7]=0x80; + dataarrayblue[8]=0x00; +} + +void shiftout(uint8_t data){ + datapin=0; + clockpin=0; + for(int i=7;i>0;i--){ + clockpin=0; + wait_us(1); + if (data&(1<<i)){ + datapin=0; + }else{ + datapin=1; + } + wait_us(1); + clockpin=1; + wait_us(1); + datapin=0; + wait_us(1); + } + clockpin=0; +} + +void loop(){ + for(int i=0;i<10;i++){ + datared=dataarrayred[i]; + datagreen=dataarraygreen[i]; + datablue=dataarrayblue[i]; + latchpin=1; + shiftout(datagreen); + shiftout(datared); + shiftout(datablue); + latchpin=0; + wait(3); + } +} + +int main(){ + setup(); + while(1){ + loop(); + } +}*/ +/*BusInOut kathode(PC_1,PB_0,PA_4,PA_1); +//BusInOut led(PD_2,PC_11,PC_10,PC_12,PA_13,PA_14,PA_15,PB_7,PC_13,PC_3,PC_0,PA_0); +BusInOut redled(PA_13,PC_13,PA_0,PA_13); +BusInOut greenled(PB_7,PC_0,PD_2,PC_12); +BusInOut blueled(PA_15,PC_3,PC_11,PC_10); + +int main() { + kathode.output(); + redled.output(); + redled.mode(OpenDrain); + greenled.output(); + greenled.mode(OpenDrain); + blueled.output(); + blueled.mode(OpenDrain); + while(1){ + kathode=0b0001; + for(int i=0;i<4;i++){ + redled=0b0000; + greenled=0b0000; + blueled=0b1111; + wait_us(1); + redled=0; + greenled=0; + blueled=0; + kathode=kathode<<1; + } + } + kathode=0b1111; + led.output(); + led.mode(OpenDrain); + led=0xffff; + while(1){} +}*/
diff -r 000000000000 -r ddaa166a52da mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Sep 01 09:48:17 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/a7c7b631e539 \ No newline at end of file
diff -r 000000000000 -r ddaa166a52da necleo_pin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/necleo_pin.h Sat Sep 01 09:48:17 2018 +0000 @@ -0,0 +1,12 @@ +#include "mbed.h" +DigitalOut Red1(PA_3); +DigitalOut Green1(PC_0); +DigitalOut Blue1(PA_2); +DigitalOut Red2(PA_9); +DigitalOut Green2(PB_0); +DigitalOut Blue2(PB_3); +BusOut Address(PA_4,PB_5); +DigitalOut CLK(PA_10); +DigitalOut LAT(PA_0); +DigitalOut OE(PA_8); +DigitalOut myLED(LED1); \ No newline at end of file