Abstraction for the glider class

Dependents:   DropTest

Committer:
chasefarmer2808
Date:
Tue May 02 00:38:48 2017 +0000
Revision:
14:a226bedae730
Parent:
13:d95070aa9140
Child:
16:7e1a1cd9f9fb
solar V input

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