Abstraction for the glider class

Dependents:   DropTest

Committer:
chasefarmer2808
Date:
Fri Jun 09 01:16:18 2017 +0000
Revision:
21:a1db0106c09a
Parent:
20:d8044cd4819f
yo

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 17:aa62b351af43 11 #define SAVE_DATA_FORMAT "%d %d %d" //string format for the data saved to flash mem
chasefarmer2808 17:aa62b351af43 12 #define PACKET_FORMAT "3387, GLIDER, %d, %u, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d\r\n" //string format for telemetry packet
chasefarmer2808 6:bb82dd1618c2 13
chasefarmer2808 17:aa62b351af43 14 #define CMD_BUZZER 'b' //sound buzzer for 3 seconds
chasefarmer2808 17:aa62b351af43 15 #define CMD_RESET 'z' //zero out packet count, mission time, and state
chasefarmer2808 17:aa62b351af43 16 #define CMD_NEXT_STATE 'n' //increment state
chasefarmer2808 17:aa62b351af43 17 #define CMD_PREV_STATE 'p' //decrement state
chasefarmer2808 13:d95070aa9140 18
chasefarmer2808 17:aa62b351af43 19 #define FREQ 1.0 //frequency of sending a telem packet (1 a second)
chasefarmer2808 17:aa62b351af43 20
chasefarmer2808 17:aa62b351af43 21 #define CRUZE 0 //released from container
chasefarmer2808 17:aa62b351af43 22 #define LAND 1 //on the ground
chasefarmer2808 3:d8932a3036a8 23
chasefarmer2808 9:8e34e713e6ef 24 #define PITO_V_DIVIDER 0.6666
chasefarmer2808 14:a226bedae730 25 #define SOLAR_V_DIVIDER 0.5
chasefarmer2808 9:8e34e713e6ef 26 #define PITO_ADC_RATIO 3.3 / 0xffff
chasefarmer2808 9:8e34e713e6ef 27
chasefarmer2808 9:8e34e713e6ef 28 #define AIR_DENSITY 1.225 //kg per m3
chasefarmer2808 9:8e34e713e6ef 29
chasefarmer2808 11:5e83ff964f5f 30 #define BUZZER_FREQ 700.0
chasefarmer2808 11:5e83ff964f5f 31
chasefarmer2808 21:a1db0106c09a 32 #define ALT_THRESH -1.0 //meters
chasefarmer2808 13:d95070aa9140 33
chasefarmer2808 21:a1db0106c09a 34 #define EMERGENCY_TIMEOUT 60.0 //seconds before buzzer will sound forever no matter what
chasefarmer2808 14:a226bedae730 35
chasefarmer2808 0:4e6b53a7bd38 36 class Glider {
chasefarmer2808 0:4e6b53a7bd38 37 public:
chasefarmer2808 0:4e6b53a7bd38 38 Serial* dev;
chasefarmer2808 17:aa62b351af43 39 Serial* xbee; //xbee radio
chasefarmer2808 17:aa62b351af43 40 double heading; //degrees from north
chasefarmer2808 17:aa62b351af43 41 float pressure; //hpa
chasefarmer2808 17:aa62b351af43 42 float temp; //C
chasefarmer2808 17:aa62b351af43 43 float alt; //m
chasefarmer2808 17:aa62b351af43 44 float speed; //m per s
chasefarmer2808 17:aa62b351af43 45 float solarVoltage; //volts
chasefarmer2808 17:aa62b351af43 46 bool cmdFlag; //goes true when a command is recieved
chasefarmer2808 17:aa62b351af43 47 bool transmitFlag; //goes true once a second
chasefarmer2808 17:aa62b351af43 48 time_t startTime; //saved data
chasefarmer2808 17:aa62b351af43 49 time_t missionTime; //current time - initial time
chasefarmer2808 7:dc93fe573846 50 uint8_t packetCount; //saved data
chasefarmer2808 6:bb82dd1618c2 51 uint8_t state; //saved data
chasefarmer2808 17:aa62b351af43 52 HMC5883L* hmc; //magnetometer object
chasefarmer2808 17:aa62b351af43 53 BMP180* bmp; //pressor sensor object
chasefarmer2808 17:aa62b351af43 54
chasefarmer2808 17:aa62b351af43 55 //constructor for glider object
chasefarmer2808 1:7039ae86fe70 56 Glider(Serial* device, PinName sda, PinName scl, PinName tx, PinName rx);
chasefarmer2808 17:aa62b351af43 57 InterruptIn xbeeRxInt; //ISR for RX external interrupt
chasefarmer2808 9:8e34e713e6ef 58 AnalogIn pitot;
chasefarmer2808 14:a226bedae730 59 AnalogIn solVoltIn;
chasefarmer2808 11:5e83ff964f5f 60 Beep buzzer;
chasefarmer2808 0:4e6b53a7bd38 61 void setHeading();
chasefarmer2808 8:7fc2caa10bbb 62 void setTempPressAlt();
chasefarmer2808 9:8e34e713e6ef 63 void setAirSpeed();
chasefarmer2808 14:a226bedae730 64 void setSolarVoltage();
chasefarmer2808 1:7039ae86fe70 65 void setMissionTime();
chasefarmer2808 4:ff59603d9fb6 66 void setTransmitFlag();
chasefarmer2808 20:d8044cd4819f 67 void forceLandState();
chasefarmer2808 12:ca3e1c6203f7 68 void updateTelem();
chasefarmer2808 5:460412fc4a17 69 void initSaveData();
chasefarmer2808 0:4e6b53a7bd38 70 void saveTelem();
chasefarmer2808 2:cc07e65227ff 71 void saveData();
chasefarmer2808 1:7039ae86fe70 72 void transmitPacket();
chasefarmer2808 3:d8932a3036a8 73 void setCommandFlag();
chasefarmer2808 2:cc07e65227ff 74 void processCommand();
chasefarmer2808 11:5e83ff964f5f 75 void soundBuzzer(float freq, float dur, bool infinate);
chasefarmer2808 13:d95070aa9140 76 void checkForLand();
chasefarmer2808 13:d95070aa9140 77 void endMission();
chasefarmer2808 0:4e6b53a7bd38 78 };
chasefarmer2808 0:4e6b53a7bd38 79
chasefarmer2808 1:7039ae86fe70 80 #endif