Abstraction for the glider class
Diff: Glider.cpp
- Revision:
- 9:8e34e713e6ef
- Parent:
- 8:7fc2caa10bbb
- Child:
- 10:4c4f0ea887a4
diff -r 7fc2caa10bbb -r 8e34e713e6ef Glider.cpp --- a/Glider.cpp Sat Apr 15 00:18:17 2017 +0000 +++ b/Glider.cpp Thu Apr 20 16:39:12 2017 +0000 @@ -1,6 +1,6 @@ #include "Glider.h" -Glider::Glider(Serial* device, PinName sda, PinName scl, PinName tx, PinName rx) : xbeeRxInt(rx) { +Glider::Glider(Serial* device, PinName sda, PinName scl, PinName tx, PinName rx) : xbeeRxInt(rx), pitot(p15) { dev = device; dev->printf("constructing glider..."); initSaveData(); @@ -25,6 +25,14 @@ bmp->ReadData(&this->temp, &this->pressure, &this->alt); } +void Glider::setAirSpeed() { + float vInput = this->pitot.read_u16() * PITO_ADC_RATIO; + vInput = vInput / PITO_V_DIVIDER; + + float diffPressure = (vInput - 0.5) / (0.2 * 5.0); //kPa + this->speed = sqrt((2*diffPressure) / AIR_DENSITY); +} + void Glider::setMissionTime() { //this->dev->printf("current time: %d\r\n", this->missionTime); this->missionTime = time(NULL) - this->startTime; @@ -71,16 +79,17 @@ } void Glider::transmitPacket() { - //TODO: transmit alt, pressure, speed - //temp, voltage + //TODO: transmit speed + // voltage this->packetCount++; - this->xbee->printf("3387, GLIDER, %d, %d, %f, %f, %f, %f, %d\r\n", + this->xbee->printf("3387, GLIDER, %d, %d, %f, %f, %f, %f, %f, %d\r\n", this->missionTime, this->packetCount, this->alt, this->pressure, this->temp, + this->speed, this->heading, this->state); }