Abstraction for the glider class

Dependents:   DropTest

Committer:
chasefarmer2808
Date:
Mon May 15 13:51:30 2017 +0000
Revision:
16:7e1a1cd9f9fb
Parent:
14:a226bedae730
Child:
17:aa62b351af43
packet format

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chasefarmer2808 0:4e6b53a7bd38 1 #ifndef Glider_H
chasefarmer2808 0:4e6b53a7bd38 2 #define Glider_H
chasefarmer2808 0:4e6b53a7bd38 3
chasefarmer2808 0:4e6b53a7bd38 4 #include "mbed.h"
chasefarmer2808 0:4e6b53a7bd38 5 #include <string>
chasefarmer2808 9:8e34e713e6ef 6 #include "math.h"
chasefarmer2808 0:4e6b53a7bd38 7 #include "HMC5883L.h"
chasefarmer2808 0:4e6b53a7bd38 8 #include "BMP180.h"
chasefarmer2808 11:5e83ff964f5f 9 #include "beep.h"
chasefarmer2808 0:4e6b53a7bd38 10
chasefarmer2808 6:bb82dd1618c2 11 #define SAVE_DATA_FORMAT "%d %d %d"
chasefarmer2808 16:7e1a1cd9f9fb 12 #define PACKET_FORMAT "3387, GLIDER, %d, %u, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d\r\n"
chasefarmer2808 6:bb82dd1618c2 13 #define CMD_BUZZER 'b'
chasefarmer2808 10:4c4f0ea887a4 14 #define CMD_RESET 'z'
chasefarmer2808 13:d95070aa9140 15 #define CMD_NEXT_STATE 'n'
chasefarmer2808 13:d95070aa9140 16 #define CMD_PREV_STATE 'p'
chasefarmer2808 6:bb82dd1618c2 17
chasefarmer2808 4:ff59603d9fb6 18 #define FREQ 1.0
chasefarmer2808 13:d95070aa9140 19
chasefarmer2808 6:bb82dd1618c2 20 #define CRUZE 0
chasefarmer2808 6:bb82dd1618c2 21 #define LAND 1
chasefarmer2808 3:d8932a3036a8 22
chasefarmer2808 9:8e34e713e6ef 23 #define PITO_V_DIVIDER 0.6666
chasefarmer2808 14:a226bedae730 24 #define SOLAR_V_DIVIDER 0.5
chasefarmer2808 9:8e34e713e6ef 25 #define PITO_ADC_RATIO 3.3 / 0xffff
chasefarmer2808 9:8e34e713e6ef 26
chasefarmer2808 9:8e34e713e6ef 27 #define AIR_DENSITY 1.225 //kg per m3
chasefarmer2808 9:8e34e713e6ef 28
chasefarmer2808 11:5e83ff964f5f 29 #define BUZZER_FREQ 700.0
chasefarmer2808 11:5e83ff964f5f 30
chasefarmer2808 13:d95070aa9140 31 #define ALT_THRESH 100.0 //meters
chasefarmer2808 13:d95070aa9140 32
chasefarmer2808 14:a226bedae730 33 #define EMERGENCY_TIMEOUT 60.0
chasefarmer2808 14:a226bedae730 34
chasefarmer2808 0:4e6b53a7bd38 35 class Glider {
chasefarmer2808 0:4e6b53a7bd38 36 public:
chasefarmer2808 0:4e6b53a7bd38 37 Serial* dev;
chasefarmer2808 1:7039ae86fe70 38 Serial* xbee;
chasefarmer2808 0:4e6b53a7bd38 39 double heading;
chasefarmer2808 0:4e6b53a7bd38 40 float pressure;
chasefarmer2808 0:4e6b53a7bd38 41 float temp;
chasefarmer2808 0:4e6b53a7bd38 42 float alt;
chasefarmer2808 9:8e34e713e6ef 43 float speed;
chasefarmer2808 14:a226bedae730 44 float solarVoltage;
chasefarmer2808 6:bb82dd1618c2 45 bool cmdFlag;
chasefarmer2808 4:ff59603d9fb6 46 bool transmitFlag;
chasefarmer2808 7:dc93fe573846 47 time_t startTime; //saved data
chasefarmer2808 7:dc93fe573846 48 time_t missionTime;
chasefarmer2808 7:dc93fe573846 49 uint8_t packetCount; //saved data
chasefarmer2808 6:bb82dd1618c2 50 uint8_t state; //saved data
chasefarmer2808 0:4e6b53a7bd38 51 HMC5883L* hmc;
chasefarmer2808 0:4e6b53a7bd38 52 BMP180* bmp;
chasefarmer2808 1:7039ae86fe70 53 Glider(Serial* device, PinName sda, PinName scl, PinName tx, PinName rx);
chasefarmer2808 2:cc07e65227ff 54 InterruptIn xbeeRxInt;
chasefarmer2808 9:8e34e713e6ef 55 AnalogIn pitot;
chasefarmer2808 14:a226bedae730 56 AnalogIn solVoltIn;
chasefarmer2808 11:5e83ff964f5f 57 Beep buzzer;
chasefarmer2808 0:4e6b53a7bd38 58 void setHeading();
chasefarmer2808 8:7fc2caa10bbb 59 void setTempPressAlt();
chasefarmer2808 9:8e34e713e6ef 60 void setAirSpeed();
chasefarmer2808 14:a226bedae730 61 void setSolarVoltage();
chasefarmer2808 1:7039ae86fe70 62 void setMissionTime();
chasefarmer2808 4:ff59603d9fb6 63 void setTransmitFlag();
chasefarmer2808 12:ca3e1c6203f7 64 void updateTelem();
chasefarmer2808 5:460412fc4a17 65 void initSaveData();
chasefarmer2808 0:4e6b53a7bd38 66 void saveTelem();
chasefarmer2808 2:cc07e65227ff 67 void saveData();
chasefarmer2808 1:7039ae86fe70 68 void transmitPacket();
chasefarmer2808 3:d8932a3036a8 69 void setCommandFlag();
chasefarmer2808 2:cc07e65227ff 70 void processCommand();
chasefarmer2808 11:5e83ff964f5f 71 void soundBuzzer(float freq, float dur, bool infinate);
chasefarmer2808 13:d95070aa9140 72 void checkForLand();
chasefarmer2808 13:d95070aa9140 73 void endMission();
chasefarmer2808 0:4e6b53a7bd38 74 };
chasefarmer2808 0:4e6b53a7bd38 75
chasefarmer2808 1:7039ae86fe70 76 #endif