BastatDoreau / Mbed 2 deprecated MoveYourTetris

Dependencies:   mbed APDS_9960 mbed-rtos

Dependents:   MoveYourTetris_OK

Revision:
35:7aef0bbdf335
Parent:
34:3f8df7ccfcbc
Child:
36:f58a566595ad
--- a/src/main.cpp	Fri Apr 22 11:28:37 2016 +0000
+++ b/src/main.cpp	Fri Apr 22 13:49:03 2016 +0000
@@ -16,25 +16,21 @@
 
 void detectionMouvement(void const *args)
 {
-
-
-
-    //Serial pc(USBTX, USBRX);
+    Serial pc(USBTX, USBRX);
     if ( GSensor.ginit() ) {
-        //pc.printf("APDS-9960 initialization complete\n\r");
+        pc.printf("APDS-9960 initialization complete\n\r");
     } else {
-        //pc.printf("Something went wrong during APDS-9960 init\n\r");
+        pc.printf("Something went wrong during APDS-9960 init\n\r");
     }
 
     //Start running the APDS-9960 gesture sensor engine
     if ( GSensor.enableGestureSensor(true) ) {
-        //pc.printf("Gesture sensor is now running\n\r");
+        pc.printf("Gesture sensor is now running\n\r");
     } else {
-        //pc.printf("Something went wrong during gesture sensor init!\n\r");
+        pc.printf("Something went wrong during gesture sensor init!\n\r");
     }
 
     while(1) {
-        
         if(GSensor.isGestureAvailable()) {
             message_t *message = (message_t*)osPoolAlloc(mpool);
             message->val = 0;
@@ -66,34 +62,27 @@
                 }
             }
             osMessagePut(queue, (uint32_t)message, osWaitForever);
-
             osDelay(10);
         }
     }
 }
 
-osThreadDef(detectionMouvement, osPriorityNormal, DEFAULT_STACK_SIZE);
+//osThreadDef(detectionMouvement, osPriorityNormal, DEFAULT_STACK_SIZE);
 
 int main()
-{
+{   
+    // CREATION DU THREAD PARALLELE DE LECTURE DE MOUVEMENT
+    Thread thread(detectionMouvement);
+    // CREATION DE LA MESSAGE QUEUE
     mpool = osPoolCreate(osPool(mpool));
     queue = osMessageCreate(osMessageQ(queue), NULL);
-    Serial pc(USBTX, USBRX);
-    osThreadCreate(osThread(detectionMouvement), NULL);
-    Thread thread(detectionMouvement); // Lancement du thread
-    
-    cJeu jeu(8,8);
-    //Serial pc(USBTX, USBRX);
-    jeu.initialiser();
-    jeu.setQueue(&queue, &mpool);
-
-
-
-    while (!jeu.partieEnCours()) {
+    // GESTION D'UN JEU
+    cJeu* jeu = new cJeu(8,8);  // Creation d'un pointeur sur une classe jeu
+    jeu->initialiser(); // Initialisation des réglages principaux
+    jeu->setQueue(&queue, &mpool);  // Affectation des pointeurs vers la queue
+    while (!jeu->partieEnCours()) {  // Partie en cours
     }
-    ///////////////////////////////
-    ///A VOIR
-    jeu.fin();
+    delete jeu; // Fin du jeu ==> Destruction de l'espace pointé