Projet_S5 / Mbed 2 deprecated Repo_Noeud_Mobile_refactor

Dependencies:   mbed-rtos mbed

Fork of Repo_Noeud_Mobile by Projet_S5

Revision:
6:fd1bf5563299
Parent:
1:601d2922ff06
Child:
7:ce6e58c5a119
--- a/main.cpp	Wed Mar 04 20:43:18 2015 +0000
+++ b/main.cpp	Thu Mar 05 19:18:53 2015 +0000
@@ -1,38 +1,51 @@
 /* S5 Projet - Conception d'un systeme embarque reseaute
  * main.cpp
- * 
+ *
  * @author Equipe de projet 2
- * 
+ *
  */
+
+// System libraries
 #include "mbed.h"
 #include "rtos.h"
+
+// Proprietary libraries
+#include "CountDown.h"
 #include "FlexSensor.h"
-#include "CountDown.h"
+#include "MMA8452Q.h"
 
 #define GO 0x01
 
 enum GameMode { GUNNER, RPS, AirGuitar};
 
-//PROTOTYPES DE FONCTION 
+//PROTOTYPES DE FONCTION
 void gunner(void const* args);
 void rps(void const* args);
 void airGuitar(void const* args);
+void accelTesting(void const* args);
 
 FlexSensor index(DIGITAL, p15);       // flex sensor 1.
 FlexSensor majeur(DIGITAL, p16);      // flex sensor 2.
 FlexSensor annulaire(DIGITAL, p17);   // flex sensor 3.
 CountDown countDown;
+Accel accel;
 
-Thread* gunner_thread_ptr = NULL;
-Thread* rps_thread_ptr = NULL;
-Thread* airguitar_thread_ptr = NULL;
+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
 
 int main(void const* args)
 {
+    // Initializing the accelerometer
+    accel = Accel();
+    accel.init_MMA8452();
+
+    RtosTimer sync(accelTesting, osTimerPeriodic, (void *)0);
+    
+
     GameMode mode = GUNNER;
     countDown.run();
-    switch(mode)
-    {
+    switch(mode) {
         case GUNNER:
             gunner_thread_ptr =  new Thread(gunner);
             break;
@@ -45,14 +58,16 @@
         default:
             break;
     }
+    sync.start(250);
+    while(1) {
+    }
 }
 
 void gunner(void const* args)
-{ 
-    // local variables 
-    
-    while(true)
-    {
+{
+    // local variables
+
+    while(true) {
         Thread::signal_wait(GO);
         // code...
     }
@@ -60,10 +75,9 @@
 
 void rps(void const* args)
 {
-    // local variables 
-    
-    while(true)
-    {
+    // local variables
+
+    while(true) {
         Thread::signal_wait(GO);
         // code...
     }
@@ -71,13 +85,16 @@
 
 void airGuitar(void const* args)
 {
-    // local variables 
-    
-    while(true)
-    {
+    // local variables
+
+    while(true) {
         Thread::signal_wait(GO);
         // code...
     }
 }
 
+void accelTesting(void const* args)
+{
+    accel.get_axis_values();
+}