Juego de cruzar las calles, el jugador debe llegar hasta el otro punto para ganar

Dependencies:   mbed

Revision:
0:22386e919072
Child:
1:18fff1390131
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calle.cpp	Tue Oct 30 19:50:20 2018 +0000
@@ -0,0 +1,67 @@
+#include "mbed.h"
+#include "avenidas.h"
+
+// Definicion de parametros de comunicacion
+SPI deviceM(PB_15, PB_14, PB_13);
+DigitalOut ssel (PB_12);
+// Definicion de Funciones
+void sendSPI();
+void inicializar_matriz();
+
+// Definicion de Variables
+
+uint16_t* nivel;
+float velocidad = 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 inicializar_matriz(){
+    sendSPI(0x0c,1);    
+    sendSPI(0x0b,7);
+    sendSPI(0x09,0);    //SELECCIONA LA LUMINOSIDAD DE LA MATRIZ
+    sendSPI(0x0A,0x00); //SELECCIONA LA LUMINOSIDAD DE LA MATRIZ
+    
+    int i;
+    for (i=0;i<2;i++){
+        sendSPI(0x0F,1);
+        wait (0.5);
+        sendSPI(0x0F,0);
+        wait (0.5);
+    }
+  
+  }
+
+
+int main() {
+                   
+   inicializar_matriz();
+   nivel= AV_1;
+   
+   while(1){
+      
+      
+      for(int i= 1; i<=8;i++){
+          sendSPI(i, nivel[i-1]);
+          }
+      wait(velocidad);
+      int aux = nivel[0];
+      for(int i= 0; i<8;i++){  
+          nivel[i]=nivel[i+1];
+          }
+      nivel[7] = aux;
+                       
+       }
+       
+       
+
+}
\ No newline at end of file