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:
- 45:20f5867f15de
- Parent:
- 43:92c9e58b8a3a
- Child:
- 47:f372ca93d6c1
--- a/main.cpp Wed Apr 08 14:10:12 2015 +0000 +++ b/main.cpp Wed Apr 08 20:21:12 2015 +0000 @@ -44,6 +44,7 @@ RtosTimer *sync; GameMode_e mode = RPS; short PanId; +char GantID; Xbee xbee; Thread *threads[3]; @@ -104,7 +105,7 @@ Thread_Send_Data_To_Fixe = new Thread(Send_Data_To_Fixe); while(true) { - + } } @@ -132,9 +133,13 @@ while(true) { Thread::signal_wait(0x02); flex_data = flexSensors.get_flex_values(); + while(flex_data.index != 0) { + wait(10); + flex_data = flexSensors.get_flex_values(); + } Mobile_Vers_Fixe *mail = mailbox_Mobile_Vers_Fixe.alloc(); mail->flexSensor = flex_data; - mail->gants = 0x01; + mail->gants = GantID; mail->accelData.x = 0x00; mail->accelData.y = 0x00; mail->accelData.z = 0x01; @@ -163,7 +168,7 @@ flex_data = flexSensors.get_flex_values(); Mobile_Vers_Fixe *mail = mailbox_Mobile_Vers_Fixe.alloc(); mail->flexSensor = flex_data; - mail->gants = 'd'; // Gauche ou Droit + mail->gants = GantID; // Gauche ou Droit mail->accelData.x = 0x01; mail->accelData.y = 0x00; mail->accelData.z = 0x00; @@ -183,7 +188,7 @@ 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); - + // Envoyer la structure xbee.EnvoyerStructure(mail); mailbox_Mobile_Vers_Fixe.free(mail); @@ -216,17 +221,13 @@ FILE* file = fopen("/local/config.txt","r"); if (file != NULL) { char buffer[2]; - //char time; - //char selector; - + fscanf(file, "%x", &buffer); //panID = 2 char - //fscanf(file, "%d", &time); //read period = 1 decimal - //fscanf(file, "%d", &selector); //end device selector = 1 decimal - PanId = buffer[1] << 8 | buffer[0]; //set PAN ID global variable - //ReadPeriod = time; //set read period global variable - //EndDeviceSelection = selector; //set end device selection global variable - + + fscanf(file, "%c", &buffer); // + GantID = buffer[0]; //set GantID global variable + fclose(file); //close file } else { //if file is not found m_pc.printf("ERROR AT CONFIG FILE \r\n");