Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Repo_Noeud_Mobile by
Diff: main.cpp
- Revision:
- 48:bc531288c220
- Parent:
- 47:f372ca93d6c1
- Child:
- 51:299408ceee3a
--- a/main.cpp Wed Apr 08 20:29:22 2015 +0000 +++ b/main.cpp Sat Apr 11 00:03:49 2015 +0000 @@ -19,6 +19,7 @@ #define GO 0x01 #define ACTIVATE_ACCEL 0 +#define ACTIVATE_FLEX 1 Serial m_pc(USBTX, USBRX); LocalFileSystem local("local"); // file system for config.txt @@ -28,6 +29,7 @@ void rps(void const* args); void airGuitar(void const* args); void flex(void const* args); +void test(void const* args); void analyze_sensor_data(void const* args); void configure_GUNNER(); void configure_RPS(); @@ -38,11 +40,17 @@ uint8_t play = 0; -FlexSensor flexSensors(p18, p19, p20); // flex sensor 1. +FlexSensor flexSensors(p18, p19, p20, p17); // flex sensor 1. Accel accel; flex_t flex_data; RtosTimer *sync; -GameMode_e mode = WAITING; + +#if ACTIVATE_ACCEL +GameMode_e mode = RPS; +#else +GameMode_e mode = RPS; +#endif + short PanId; char GantID; Xbee xbee; @@ -53,6 +61,7 @@ Thread* airguitar_thread_ptr = NULL; // dans des define. guillaume Thread* flex_thread_ptr = NULL; // Lecture des entrées analogiques Thread* Thread_Send_Data_To_Fixe = NULL;// Thread pour envoyer les données des sensors au fixe +Thread* test_thread_ptr = NULL; Mail<Mobile_Vers_Fixe, 32> mailbox_Mobile_Vers_Fixe; @@ -88,13 +97,17 @@ m_pc.printf("gunner mode started\r\n"); break; case RPS: - flex_thread_ptr = new Thread(flex); - rps_thread_ptr = new Thread(rps); + #if ACTIVATE_FLEX + flex_thread_ptr = new Thread(flex); + #endif + //rps_thread_ptr = new Thread(rps); m_pc.printf("rps mode started\r\n"); break; case AirGuitar: airguitar_thread_ptr = new Thread(airGuitar); break; + case TEST: + test_thread_ptr = new Thread(test); default: break; } @@ -112,6 +125,7 @@ void timer2_init(void) { LPC_PINCON->PINSEL0 |= 0xc00; // set P0.5 to CAP2.1 + LPC_PINCON->PINMODE0 |= 0xc00; // pull-down enable LPC_SC->PCONP |= (1 << 22); // Timer2 power on LPC_SC->PCLKSEL1 |= (1 << 12); // Divide CCLK by 1 for Timer2 LPC_TIM2->CCR |= 0x30; // set cap2.1 rising-edge/falling-edge and interrupt @@ -189,7 +203,26 @@ mailbox_Mobile_Vers_Fixe.put(mail); // send data frame to the fixed mbed for analyze } - accel.clear_TRANSIENT_INTERRUPT(); + accel.clear_TRANSIENT_INTERRUPT(); + } +} + +void test(void const* args) +{ + m_pc.printf("TEST Thread\r\n"); + flex_t flex_data = {0,1,0}; + + Mobile_Vers_Fixe *mail = mailbox_Mobile_Vers_Fixe.alloc(); + mail->flexSensor = flex_data; + mail->gants = GantID; + mail->accelData.x = 0x01; + mail->accelData.y = 0x00; + mail->accelData.z = 0x00; + while(1) + { + m_pc.printf("send\r\n"); + mailbox_Mobile_Vers_Fixe.put(mail); + wait(1); } } @@ -201,7 +234,7 @@ if (evtD.status == osEventMail) { Mobile_Vers_Fixe *mail = (Mobile_Vers_Fixe*)evtD.value.p; // écriture de l'événement en sortie (port série) - //m_pc.printf("Valeur des flex : %d, %d, %d\r\n" , mail->flexSensor.index, mail->flexSensor.majeur, mail->flexSensor.annulaire); + m_pc.printf("mail trouve"); // Envoyer la structure xbee.EnvoyerStructure(mail);