test aff8x8 avec 2*74HC595 (KRM2388AURPGB)

Dependencies:   mbed

Fork of DigitalIn_test by Junichi Katsu

Committer:
ER4
Date:
Mon Mar 09 11:13:37 2015 +0000
Revision:
2:a0e8e160bed1
Parent:
1:5a049a86616a
Child:
3:555b0f6dd516
Affichage d'un smile a partir d'un tableau

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:592717f4890b 1 #include "mbed.h"
ER4 1:5a049a86616a 2
ER4 1:5a049a86616a 3 SPI spi(P0_9,P0_8,P0_7); // mosi, miso, sclk
ER4 1:5a049a86616a 4 DigitalOut cs(P0_6);
jksoft 0:592717f4890b 5
ER4 1:5a049a86616a 6 void ligne(char val){
ER4 1:5a049a86616a 7 cs = 0;
ER4 1:5a049a86616a 8 //spi.write(val);
ER4 1:5a049a86616a 9 spi.write(0xFF);
ER4 1:5a049a86616a 10 cs = 1;
ER4 1:5a049a86616a 11 }
ER4 1:5a049a86616a 12 //void colone(char val1){
ER4 1:5a049a86616a 13 // cs=0;
ER4 1:5a049a86616a 14 //spi.write(val1);
ER4 1:5a049a86616a 15 //cs=1;
ER4 1:5a049a86616a 16 //}
ER4 1:5a049a86616a 17
jksoft 0:592717f4890b 18
ER4 2:a0e8e160bed1 19 char Im [8][8] = { {0,0,0,0,0,0,0,0},
ER4 2:a0e8e160bed1 20 {0,0,1,0,1,0,0,0},
ER4 2:a0e8e160bed1 21 {0,0,1,0,1,0,0,0},
ER4 2:a0e8e160bed1 22 {0,0,1,0,1,0,0,0},
ER4 2:a0e8e160bed1 23 {1,0,0,0,0,0,0,1},
ER4 2:a0e8e160bed1 24 {0,1,1,1,1,1,1,0},
ER4 2:a0e8e160bed1 25 {0,0,0,0,0,0,0,0},
ER4 2:a0e8e160bed1 26 {0,0,0,0,0,0,0,0}};
ER4 1:5a049a86616a 27
ER4 1:5a049a86616a 28
ER4 1:5a049a86616a 29
ER4 1:5a049a86616a 30 int main() {
ER4 1:5a049a86616a 31 int i=0,j=0;
ER4 1:5a049a86616a 32 // Chip must be deselected
ER4 1:5a049a86616a 33 cs = 1;
ER4 1:5a049a86616a 34
ER4 1:5a049a86616a 35 // Setup the spi for 8 bit data, high steady state clock,
ER4 1:5a049a86616a 36 // second edge capture, with a 1MHz clock rate
ER4 1:5a049a86616a 37 spi.format(8,3);
ER4 1:5a049a86616a 38 spi.frequency(1000000);
ER4 1:5a049a86616a 39 while(1){
ER4 2:a0e8e160bed1 40 for(i=0;i<8;i++){
ER4 2:a0e8e160bed1 41 for (j=0;j<=7;j++){
ER4 1:5a049a86616a 42 //spi.write(colone[j]);
ER4 2:a0e8e160bed1 43 cs = 0;
ER4 2:a0e8e160bed1 44 if(Im[i][j]==1)
ER4 2:a0e8e160bed1 45 spi.write(~(1<<j));//allume pixel
ER4 2:a0e8e160bed1 46 else
ER4 2:a0e8e160bed1 47 spi.write(0xFF); //eteind pixel
ER4 2:a0e8e160bed1 48 spi.write(1<<i);//lignes
ER4 1:5a049a86616a 49 //spi.write(0xFF);
ER4 2:a0e8e160bed1 50 cs = 1;
ER4 2:a0e8e160bed1 51 }
ER4 2:a0e8e160bed1 52 }
ER4 2:a0e8e160bed1 53 wait(0.001);
ER4 2:a0e8e160bed1 54
jksoft 0:592717f4890b 55 }
ER4 2:a0e8e160bed1 56 }