Abstraction for the glider class
Diff: Glider.cpp
- Revision:
- 11:5e83ff964f5f
- Parent:
- 10:4c4f0ea887a4
- Child:
- 12:ca3e1c6203f7
diff -r 4c4f0ea887a4 -r 5e83ff964f5f Glider.cpp --- a/Glider.cpp Mon Apr 24 21:34:11 2017 +0000 +++ b/Glider.cpp Tue Apr 25 17:18:44 2017 +0000 @@ -1,6 +1,6 @@ #include "Glider.h" -Glider::Glider(Serial* device, PinName sda, PinName scl, PinName tx, PinName rx) : xbeeRxInt(rx), pitot(p15) { +Glider::Glider(Serial* device, PinName sda, PinName scl, PinName tx, PinName rx) : xbeeRxInt(rx), pitot(p15), buzzer(p26) { dev = device; dev->printf("constructing glider..."); initSaveData(); @@ -100,11 +100,12 @@ switch (command) { case CMD_BUZZER: //'b' was recieved. sound the buzzer - this->dev->printf("buzzing...\r\n"); - this->state = LAND; - while(1); + this->state = LAND; //set state to land + this->transmitPacket(); //transmit one last packet + this->soundBuzzer(BUZZER_FREQ, 1, true); //sound buzzer forever + while (1); break; - case CMD_RESET: + case CMD_RESET: //'z' was recieved this->dev->printf("resetting save file...\r\n"); remove("/telem/data.txt"); this->initSaveData(); @@ -113,3 +114,7 @@ this->cmdFlag = false; //reset the flag so a new command can be recieved } } + +void Glider::soundBuzzer(float freq, float dur, bool infinate) { + buzzer.beep(freq, dur, infinate); +}