correccion spi

Dependencies:   mbed MPU6050

Files at this revision

API Documentation at this revision

Comitter:
jiuk
Date:
Thu Nov 22 11:29:25 2018 +0000
Parent:
7:5f1c8385cf8e
Commit message:
correccion datos spi

Changed in this revision

recoge_manzanas.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 5f1c8385cf8e -r 9c2dff610de9 recoge_manzanas.cpp
--- a/recoge_manzanas.cpp	Thu Nov 22 10:38:28 2018 +0000
+++ b/recoge_manzanas.cpp	Thu Nov 22 11:29:25 2018 +0000
@@ -4,7 +4,7 @@
 #include "Ticker.h"
 #include "MPU6050.h"
 
-Serial command(USBTX,USBRX);        //habilitar la comunicacion serial a traves del puerto usb.
+//Serial command(USBTX,USBRX);        //habilitar la comunicacion serial a traves del puerto usb.
 MPU6050 Wire(PB_9 , PB_8 ); 
 
 SPI deviceM(PB_15, PB_14, PB_13);
@@ -34,6 +34,7 @@
 void blink();
 void boton();
 void sendSPI(uint8_t,uint8_t);
+void borrar();
 
 
 //--------------------------------------------------
@@ -41,6 +42,7 @@
 //--------------------------------------------------  
 void cara_feliz()
 {
+    borrar();
     sendSPI(0x02,0b01100110);
     wait(0.2);
     sendSPI(0x03,0b01100110);
@@ -66,6 +68,7 @@
 //--------------------------------------------------  
 void cara_triste()
 {
+    borrar();
     sendSPI(0x02,0b01100110);
     wait(0.2);
     sendSPI(0x03,0b01100110);
@@ -95,8 +98,10 @@
     boton();
     if (com_tar.readable())
     {
+    int x=com_tar.getc();
+    if(x==1)
     cara_triste();
-    command.printf("Button pressed %b\n", _boton);
+    //command.printf("Button pressed %b\n", _boton);
     }
 }; 
 
@@ -107,7 +112,7 @@
 {
     if (pulsador == 0) 
         {
-            command.printf("Button pressed %b\n", _boton);
+            //command.printf("Button pressed %b\n", _boton);
             _boton=!_boton;
         }
 }  
@@ -163,8 +168,8 @@
     int _fil=fil;
     fil= rand() % 7+1;
     int y= rand() % 7+1;
-    command.printf("\n\n Fila: %d",fil); 
-    command.printf("\n Columna:%d",col[y]);
+    //command.printf("\n\n Fila: %d",fil); 
+    //command.printf("\n Columna:%d",col[y]);
     //int time=0;
     //while(time<4)
     //    {
@@ -302,12 +307,12 @@
         {
                 if((acc[0]>(GIRO+x)) || (acc[0]<-(GIRO+x)) || (acc[1]>(GIRO+x)) || (acc[1]<-(GIRO+x)))
                     {
-                        vel=300; 
+                        vel=200; 
                         if((acc[0]>(GIRO+y)) || (acc[0]<-(GIRO+y)) || (acc[1]>(GIRO+y)) || (acc[1]<-(GIRO+y)))
                             vel=100;
                     }
                 else
-                    vel=500;   
+                    vel=300;   
         }
     return vel;
 }
@@ -389,7 +394,7 @@
                         if(manzanas==4)
                         {
                             com_tar.putc(1);
-                            command.printf("Enviado");
+                            //command.printf("Enviado");
                             cara_feliz();
                         }
                         x=1;