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:
- 53:7b15fe4c9edf
- Parent:
- 51:299408ceee3a
- Child:
- 54:8709cb24abe3
--- a/main.cpp Sat Apr 11 19:30:24 2015 +0000 +++ b/main.cpp Sat Apr 11 21:57:12 2015 +0000 @@ -46,6 +46,7 @@ flex_t flex_data; //RtosTimer *sync; GameMode_e mode = RPS; +AirGuitar_opMode_e opMode; short PanId; char GantID; Xbee xbee; @@ -255,12 +256,49 @@ } void airGuitar(void const* args) -{ - // local variables - - while(true) { - Thread::signal_wait(GO); - // code... +{ + Mobile_Vers_Fixe *mailAirGuitar = new Mobile_Vers_Fixe; + mailAirGuitar->flexSensor.index = true; + mailAirGuitar->flexSensor.annulaire = true; + mailAirGuitar->flexSensor.majeur = true; + if(opMode == PICK) + { + mailAirGuitar->gants = 'D'; // Droit + } + else if(opMode == FRET) + { + mailAirGuitar->gants = 'G'; // Gauche + } + mailAirGuitar->accelData.x = 0x00; + mailAirGuitar->accelData.y = 0x00; + mailAirGuitar->accelData.z = 0x00; + + flex_t flex_data; + + switch(opMode) + { + case PICK: + while(true) + { + Thread::signal_wait(0x02); + mailAirGuitar->accelData.x = 0x01; + xbee.EnvoyerStructure(mailAirGuitar); + } + break; //unreachable. + case FRET: + while(true) + { + flex_data = flexSensors.get_flex_values(); + if(flex_data != mailAirGuitar->flexSensor) + { + mailAirGuitar->flexSensor = flex_data; + xbee.EnvoyerStructure(mailAirGuitar); + } + Thread::wait(50); + } + break; //unreachable. + default: + break; } } @@ -281,7 +319,14 @@ fscanf(file, "%x", &buffer); GantID = buffer[0]; - + + char mode[4]; + fscanf(file, "%x", mode); + if(mode == "FRET") + opMode = FRET; + if(mode == "PICK") + opMode = PICK; + fclose(file); //close file } else { //if file is not found m_pc.printf("ERROR AT CONFIG FILE \r\n");