Abstraction for the glider class
Diff: Glider.cpp
- Revision:
- 13:d95070aa9140
- Parent:
- 12:ca3e1c6203f7
- Child:
- 14:a226bedae730
diff -r ca3e1c6203f7 -r d95070aa9140 Glider.cpp --- a/Glider.cpp Sat Apr 29 18:49:55 2017 +0000 +++ b/Glider.cpp Sat Apr 29 21:27:57 2017 +0000 @@ -50,8 +50,16 @@ } void Glider::saveTelem() { - FILE *fp = fopen("/telem/telem.txt", "w"); - fprintf(fp, "hello,"); + FILE *fp = fopen("/telem/telem.csv", "a"); + fprintf(fp, "3387, GLIDER, %d, %u, %f, %f, %f, %f, %f, %u\r\n", + this->missionTime, //duration in seconds + this->packetCount, + this->alt, //meters + this->pressure, // + this->temp, //C + this->speed, //m per s + this->heading, //degrees from North + this->state);; fclose(fp); } @@ -109,14 +117,20 @@ switch (command) { case CMD_BUZZER: //'b' was recieved. sound the buzzer this->state = LAND; //set state to land - this->transmitPacket(); //transmit one last packet - this->soundBuzzer(BUZZER_FREQ, 1, true); //sound buzzer forever - while (1); + //this->transmitPacket(); //transmit one last packet + //this->soundBuzzer(BUZZER_FREQ, 1, true); //sound buzzer forever + //while (1); break; case CMD_RESET: //'z' was recieved - this->dev->printf("resetting save file...\r\n"); - remove("/telem/data.txt"); - this->initSaveData(); + xbee->printf("resetting save file...\r\n"); + + state = 0; + packetCount = 0; + startTime = 0; + saveData(); + //remove("/telem/data.txt"); + //this->initSaveData(); + break; } this->cmdFlag = false; //reset the flag so a new command can be recieved @@ -126,3 +140,18 @@ void Glider::soundBuzzer(float freq, float dur, bool infinate) { buzzer.beep(freq, dur, infinate); } + +void Glider::checkForLand() { + xbee->printf("%f\r\n", alt); + if (alt <= ALT_THRESH) { + state = LAND; + } +} + +void Glider::endMission() { + this->transmitPacket(); //transmit one last packet + this->soundBuzzer(BUZZER_FREQ, 1, true); //sound buzzer forever + while (1) { + processCommand(); + } +}