Projet_S5 / Mbed 2 deprecated Repo_Noeud_Mobile_refactor

Dependencies:   mbed-rtos mbed

Fork of Repo_Noeud_Mobile by Projet_S5

Revision:
15:dc18545822b3
Parent:
14:bda91cead7f2
Child:
17:1a634bb615f3
Child:
25:184915935d68
--- a/main.cpp	Sat Mar 21 17:08:29 2015 +0000
+++ b/main.cpp	Sat Mar 21 17:24:38 2015 +0000
@@ -26,6 +26,12 @@
 void rps(void const* args);
 void airGuitar(void const* args);
 void get_sensor_data(void const* args);
+void analyze_sensor_data(void const* args);
+void analyze_GUNNER(uint8_t axe_x);
+void analyze_RPS(uint8_t axe_z);
+void analyze_GUITAR(uint8_t axe_z);
+void etat_de_jeu(void const *args);
+void reception_coord(void const *args);
 
 uint8_t play = 0;
 
@@ -37,8 +43,9 @@
 FlexSensor flex;
 RtosTimer *sync;
 GameMode mode = RPS;
-Thread *threads[2];
+
 
+Thread *threads[3];
 Thread* gunner_thread_ptr = NULL;       // Possiblement mettre dans un tableau
 Thread* rps_thread_ptr = NULL;          // avec des position codees
 Thread* airguitar_thread_ptr = NULL;    // dans des define. guillaume
@@ -50,39 +57,6 @@
 
 Mail<sensors_t, 32> mailbox_sensors;
 
-void etat_de_jeu(void const *args)
-{
-
-    while(true) {
-        Thread::signal_wait(0x1);
-        m_pc.printf("Etat \r\n");
-        switch(play) {
-            case 0:
-                sync->stop();
-                break;
-            case 1:
-                sync->start(250);
-                break;
-            default:
-                break;
-        }
-    }
-}
-
-void reception_coord(void const *args)
-{
-    while(true) {
-        if(play == 0) {
-            play = 1;
-            threads[1]->signal_set(0x1);
-            Thread::wait(2000);
-        } else {
-            play = 0;
-            threads[1]->signal_set(0x1);
-            Thread::wait(2000);
-        }
-    }
-}
 
 int main(void const* args)
 {
@@ -91,7 +65,7 @@
     accel.init_MMA8452();
     RtosTimer timer(get_sensor_data, osTimerPeriodic, (void *)0);
     sync = &timer;
-    
+
     switch(mode) {
         case GUNNER:
             gunner_thread_ptr =  new Thread(gunner);
@@ -163,6 +137,53 @@
     mailbox_sensors.put(mail);
 }
 
+void analyze_GUNNER(uint8_t axe_x)
+{
+}
+
+void analyze_RPS(uint8_t axe_z)
+{
+    
+}
+
+void analyze_GUITAR(uint8_t axe_z)
+{
+}
+
+void etat_de_jeu(void const *args)
+{
+
+    while(true) {
+        Thread::signal_wait(0x1);
+        m_pc.printf("Etat \r\n");
+        switch(play) {
+            case 0:
+                sync->stop();
+                break;
+            case 1:
+                sync->start(250);
+                break;
+            default:
+                break;
+        }
+    }
+}
+
+void reception_coord(void const *args)
+{
+    while(true) {
+        if(play == 0) {
+            play = 1;
+            threads[1]->signal_set(0x1);
+            Thread::wait(2000);
+        } else {
+            play = 0;
+            threads[1]->signal_set(0x1);
+            Thread::wait(2000);
+        }
+    }
+}
+
 void analyze_sensor_data(void const* args)
 {
     while (true) {
@@ -171,16 +192,16 @@
         if (evtD.status == osEventMail) {
             sensors_t *mail = (sensors_t*)evtD.value.p;
             // écriture de l'événement en sortie (port série)
-            pc.printf("Valeur des trois axes de l'accelerometre: %d, %d, %d\r\n" , mail->accel_data.x, mail->accel_data.y, mail->accel_data.z);
+            m_pc.printf("Valeur des trois axes de l'accelerometre: %d, %d, %d\r\n" , mail->accel_data.x, mail->accel_data.y, mail->accel_data.z);
             switch(mode) {
                 case GUNNER:
-                    analyze_GUNNER();
+                    analyze_GUNNER(mail->accel_data.x);
                     break;
                 case RPS:
                     analyze_RPS(mail->accel_data.z);
                     break;
                 case AirGuitar:
-                    analyze_GUITAR();
+                    analyze_GUITAR(mail->accel_data.z);
                     break;
                 default:
                     break;
@@ -188,4 +209,4 @@
             mailbox_sensors.free(mail);
         }
     }
-}
\ No newline at end of file
+}