Projet_S5 / Mbed 2 deprecated Repo_Noeud_Mobile_refactor

Dependencies:   mbed-rtos mbed

Fork of Repo_Noeud_Mobile by Projet_S5

main.cpp

Committer:
groygirard
Date:
2015-03-05
Revision:
5:2b539028e5a9
Parent:
3:a77d02cb5694
Child:
7:ce6e58c5a119

File content as of revision 5:2b539028e5a9:

/* S5 Projet - Conception d'un systeme embarque reseaute
 * main.cpp
 * 
 * @author Equipe de projet 2
 * 
 */
#include "mbed.h"
#include "rtos.h"
#include "FlexSensor.h"
#include "CountDown.h"
#include "Cible.h"

#define GO 0x01

enum GameMode { GUNNER, RPS, AirGuitar};

//PROTOTYPES DE FONCTION 
void gunner(void const* args);
void rps(void const* args);
void airGuitar(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;

Thread* gunner_thread_ptr = NULL;
Thread* rps_thread_ptr = NULL;
Thread* airguitar_thread_ptr = NULL;

int main(void const* args)
{
    GameMode mode(GUNNER);
    switch(mode)
    {
        case GUNNER:
            gunner_thread_ptr =  new Thread(gunner);
            break;
        case RPS:
            rps_thread_ptr =  new Thread(rps);
            break;
        case AirGuitar:
            airguitar_thread_ptr = new Thread(airGuitar);
            break;
        default:
            break;
    }
    while(1){
        }
}

void gunner(void const* args)
{ 
    // local variables 
    Cible* cible = new Cible();
    countDown.run();
    
    while(true)
    {
        // Thread::signal_wait(GO);
        cible->reset();
        int target = rand() % 3;
            
        cible->set(target);
        countDown.run();
    }
}

void rps(void const* args)
{
    // local variables 
    
    while(true)
    {
        Thread::signal_wait(GO);
        // code...
    }
}

void airGuitar(void const* args)
{
    // local variables 
    
    while(true)
    {
        Thread::signal_wait(GO);
        // code...
    }
}