Erick Barrera
/
matriz
matriz
Revision 0:d6fe56fdc91c, committed 2018-09-13
- Comitter:
- Esbp10
- Date:
- Thu Sep 13 03:50:54 2018 +0000
- Commit message:
- matriz;
Changed in this revision
diff -r 000000000000 -r d6fe56fdc91c b.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/b.h Thu Sep 13 03:50:54 2018 +0000 @@ -0,0 +1,85 @@ +SPI deviceM(PB_15, PB_14, PB_13); +DigitalOut ssel (PB_12); +float Vel=0.8; + +void sendSPI(uint8_t d1, uint8_t d2) +{ + deviceM.unlock(); + ssel=0; + deviceM.write(d1); + deviceM.write(d2); + ssel=1; + deviceM.lock(); +} + +void printMatrix(uint8_t* vC, uint8_t col) +{ + int i; + int j=1; + int h=1; + for(i=1;i<=8;i++){ + if(*(vC+1)==0b00000000 && *(vC)==0b00000000){ + sendSPI(i,*(vC+2)>>col-1); + if(i>0){ + sendSPI(i-1,0); + } + wait(Vel); + } + else + { + if(i>1){ + j=i-2; + h=i-3; + if(*(vC)==0b00000000){ + j=i-1; + h=i; + } + sendSPI(i,*(vC)>>col-1); + sendSPI(j,*(vC+1)>>col-1); + sendSPI(h,*(vC+2)>>col-1); + if(i>2){ + sendSPI(i-3,0); + } + wait(Vel); + } + } + } +} + +void giro(uint8_t *f,uint8_t col,uint8_t gi) + { + uint8_t a[3]={0,0,0}; + int i; + int j; + switch(gi){ + case 0: + printMatrix(f,col); + break; + case 1: + for(j=0;j<3;j++){ + for(i=0;i<3;i++){ + a[i]=((((*(f+j))<<2-i)&0b10000000)>>j)+a[i]; + } + } + printMatrix(a,col); + break; + case 2: + for(j=0;j<3;j++){ + for(i=0;i<3;i++){ + a[i]=((((*(f+(2-i)))>>2-j)&0b00100000)<<j)+a[i]; + } + } + printMatrix(a,col); + break; + case 3: + for(j=0;j<3;j++){ + for(i=0;i<3;i++){ + a[i]=((((*(f+j))>>2-i)&(0b00100000))<<j)+a[i]; + } + } + printMatrix(a,col); + break; + default: + break; + } + }
diff -r 000000000000 -r d6fe56fdc91c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 13 03:50:54 2018 +0000 @@ -0,0 +1,66 @@ +#include "mbed.h" +#include "b.h" + +Serial a(USBTX,USBRX); +#define uint8_t unsigned char +int Tipofig=0; +int vcol; +uint8_t c=0b00000000; +int grado=0; +uint8_t dat [8]={0,0,0,0,0,0,0,0}; +uint8_t F_t[3]={0b11100000,0b01000000,0}; +uint8_t F_s[3]={0b11000000,0b01100000,0}; +uint8_t F_c[3]={0b11000000,0b11000000,0}; +uint8_t F_l[3]={0b11000000,0b10000000,0b10000000}; +uint8_t F_I[3]={0b10000000,0b10000000,0b10000000}; +int poscol; + + +void borrar() +{ + for(int i=1;i<=8;i++){ + sendSPI(i,0);} +} + +int main() { + a.baud(9600); + sendSPI(0x0c,1); + sendSPI(0x09,0); + sendSPI(0x0A,0x01); + sendSPI(0x0F,1); + wait (0.5); + sendSPI(0x0F,0); + wait (0.5); + sendSPI(0xB,0x7); + borrar(); + while(1){ + Tipofig=a.getc(); + vcol=a.getc(); + grado=a.getc(); + switch(Tipofig) + { + case 1: + giro(F_t,vcol,grado); + break; + case 2: + giro(F_s,vcol,grado); + break; + case 3: + giro(F_c,vcol,grado); + break; + case 4: + giro(F_l,vcol,grado); + break; + case 5: + giro(F_I,vcol,grado); + break; + default: + borrar(); + break; + } + Tipofig=0; + vcol=0; + grado=0; + } + +}
diff -r 000000000000 -r d6fe56fdc91c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Sep 13 03:50:54 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file