Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of moggo_2 by
Revision 7:2e5fc288f80b, committed 2018-09-14
- Comitter:
- jiuk
- Date:
- Fri Sep 14 04:00:36 2018 +0000
- Parent:
- 6:19ee6d34681e
- Commit message:
- Imprime correctamente las figuras y actualiza la matriz, no se logra arrojar mas de n cantidad de figuras.
Changed in this revision
moggo.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 19ee6d34681e -r 2e5fc288f80b moggo.cpp --- a/moggo.cpp Thu Sep 13 07:04:32 2018 +0000 +++ b/moggo.cpp Fri Sep 14 04:00:36 2018 +0000 @@ -52,28 +52,28 @@ void buscar_fil(){ for (uint8_t i=0;i<9;i++){ - if((mat_act[i]& mat_tmp[2])==0){ //&& mat_act[i]& mat_tmp[1]==0 && mat_act[i]& mat_tmp[0]==0) + if(((mat_act[i]& mat_tmp[3])==0) && ((mat_act[i]& mat_tmp[1])==0) && ((mat_act[i]& mat_tmp[0])==0)){ fila=i; command.printf("\n1- comparacion inicial:\n %d",mat_act[i]& mat_tmp[2]); } - if((mat_act[i]& mat_tmp[2])!=0){ + if((mat_act[i]& mat_tmp[3])!=0){ fila=i-1; //cambio de 2 a 1 i=9; command.printf("\n2- comparacion mat_act[i]& mat_tmp[2] :\n %d",mat_act[i]& mat_tmp[2]); } - if((mat_act[i]& mat_tmp[1])!=0){ //se condicionan las salidas de la busqueda de lanueva fila + if((mat_act[i]& mat_tmp[2])!=0){ //se condicionan las salidas de la busqueda de lanueva fila fila=i; //cambio de 2 a 1 i=9; command.printf("\n3- comparacion mat_act[i]& mat_tmp[1] :\n %d",mat_act[i]& mat_tmp[1]); } - if((mat_act[i]& mat_tmp[0])!=0){ + if((mat_act[i]& mat_tmp[1])!=0){ fila=i+1; //cambio de 2 a 1 i=9; command.printf("\n4- comparacion mat_act[i]& mat_tmp[0]:\n %d",mat_act[i]& mat_tmp[0]); } } if(fila>8) - fila=7; + fila=8; command.printf("\n buscar fila \n %d",fila); command.printf("\n ******************************* \n "); }; @@ -141,39 +141,47 @@ } int main() { - int info[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // almacenara todos los caracteres que se escriban inicialmente maximo 4 figuras. - int cant_fichas=3; // cantidad de fichas que se enviaran en la linea de comando. + int cant_fichas=10; // cantidad de fichas que se enviaran en la linea de comando. + int info[50]; // almacenara todos los caracteres que se escriban inicialmente maximo 4 figuras. test(); borrar(); - int r=cant_fichas*5; // r toma el valor de las fichas por 5 porque "<xyz>" son 5 caracteres. - for(int i=0;i<=r;i+=5) // almacenallena el vector que recibe los caracteres de las fichas. + int r=cant_fichas*5; // r toma el valor de las fichas por 5 porque "<xyz>" son 5 caracteres. + for(int i=0;i<=r;i+=5) // almacenallena el vector que recibe los caracteres de las fichas. { for(int j=0;j<5;j++ ) { info[i+j]=command.getc(); } } - while(1){ - for (int k=0;k<=r;k+=5) //imprime el vector con las fichas + //while(1){ + for (int k=0;k<r;k+=5) //imprime el vector con las fichas { if(info[k]==0x3c && info[k+4]==0x3e) { + if(info[k+1]<6 && info[k+2]<5 && info[k+3]<9) + { dibujar(info[k+1],info[k+2],info[k+3]); imp_mat(mat_tmp); guardar_mat(); + } + else + goto error; } else { + error: while(1) // error infinito en caso que no se cumplan las condiciones { borrar(); sendSPI(0x04,0b00011000); - wait(VEL); + sendSPI(0x05,0b00011000); + wait(0.5); sendSPI(0x04,0b00000000); - wait(VEL); + sendSPI(0x05,0b00000000); + wait(0.1); } } wait(1); // tiempo entre caida de cada pieza puede dejarlo pequeño apra optimizar tiempo - } + // } } } \ No newline at end of file