Abstraction for the glider class
Glider.h@13:d95070aa9140, 2017-04-29 (annotated)
- Committer:
- chasefarmer2808
- Date:
- Sat Apr 29 21:27:57 2017 +0000
- Revision:
- 13:d95070aa9140
- Parent:
- 12:ca3e1c6203f7
- Child:
- 14:a226bedae730
save csv
Who changed what in which revision?
User | Revision | Line number | New 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 | 9:8e34e713e6ef | 23 | #define PITO_ADC_RATIO 3.3 / 0xffff |
chasefarmer2808 | 9:8e34e713e6ef | 24 | |
chasefarmer2808 | 9:8e34e713e6ef | 25 | #define AIR_DENSITY 1.225 //kg per m3 |
chasefarmer2808 | 9:8e34e713e6ef | 26 | |
chasefarmer2808 | 11:5e83ff964f5f | 27 | #define BUZZER_FREQ 700.0 |
chasefarmer2808 | 11:5e83ff964f5f | 28 | |
chasefarmer2808 | 13:d95070aa9140 | 29 | #define ALT_THRESH 100.0 //meters |
chasefarmer2808 | 13:d95070aa9140 | 30 | |
chasefarmer2808 | 0:4e6b53a7bd38 | 31 | class Glider { |
chasefarmer2808 | 0:4e6b53a7bd38 | 32 | public: |
chasefarmer2808 | 0:4e6b53a7bd38 | 33 | Serial* dev; |
chasefarmer2808 | 1:7039ae86fe70 | 34 | Serial* xbee; |
chasefarmer2808 | 0:4e6b53a7bd38 | 35 | double heading; |
chasefarmer2808 | 0:4e6b53a7bd38 | 36 | float pressure; |
chasefarmer2808 | 0:4e6b53a7bd38 | 37 | float temp; |
chasefarmer2808 | 0:4e6b53a7bd38 | 38 | float alt; |
chasefarmer2808 | 9:8e34e713e6ef | 39 | float speed; |
chasefarmer2808 | 6:bb82dd1618c2 | 40 | bool cmdFlag; |
chasefarmer2808 | 4:ff59603d9fb6 | 41 | bool transmitFlag; |
chasefarmer2808 | 7:dc93fe573846 | 42 | time_t startTime; //saved data |
chasefarmer2808 | 7:dc93fe573846 | 43 | time_t missionTime; |
chasefarmer2808 | 7:dc93fe573846 | 44 | uint8_t packetCount; //saved data |
chasefarmer2808 | 6:bb82dd1618c2 | 45 | uint8_t state; //saved data |
chasefarmer2808 | 0:4e6b53a7bd38 | 46 | HMC5883L* hmc; |
chasefarmer2808 | 0:4e6b53a7bd38 | 47 | BMP180* bmp; |
chasefarmer2808 | 1:7039ae86fe70 | 48 | Glider(Serial* device, PinName sda, PinName scl, PinName tx, PinName rx); |
chasefarmer2808 | 2:cc07e65227ff | 49 | InterruptIn xbeeRxInt; |
chasefarmer2808 | 9:8e34e713e6ef | 50 | AnalogIn pitot; |
chasefarmer2808 | 11:5e83ff964f5f | 51 | Beep buzzer; |
chasefarmer2808 | 0:4e6b53a7bd38 | 52 | void setHeading(); |
chasefarmer2808 | 8:7fc2caa10bbb | 53 | void setTempPressAlt(); |
chasefarmer2808 | 9:8e34e713e6ef | 54 | void setAirSpeed(); |
chasefarmer2808 | 1:7039ae86fe70 | 55 | void setMissionTime(); |
chasefarmer2808 | 4:ff59603d9fb6 | 56 | void setTransmitFlag(); |
chasefarmer2808 | 12:ca3e1c6203f7 | 57 | void updateTelem(); |
chasefarmer2808 | 5:460412fc4a17 | 58 | void initSaveData(); |
chasefarmer2808 | 0:4e6b53a7bd38 | 59 | void saveTelem(); |
chasefarmer2808 | 2:cc07e65227ff | 60 | void saveData(); |
chasefarmer2808 | 1:7039ae86fe70 | 61 | void transmitPacket(); |
chasefarmer2808 | 3:d8932a3036a8 | 62 | void setCommandFlag(); |
chasefarmer2808 | 2:cc07e65227ff | 63 | void processCommand(); |
chasefarmer2808 | 11:5e83ff964f5f | 64 | void soundBuzzer(float freq, float dur, bool infinate); |
chasefarmer2808 | 13:d95070aa9140 | 65 | void checkForLand(); |
chasefarmer2808 | 13:d95070aa9140 | 66 | void endMission(); |
chasefarmer2808 | 0:4e6b53a7bd38 | 67 | }; |
chasefarmer2808 | 0:4e6b53a7bd38 | 68 | |
chasefarmer2808 | 1:7039ae86fe70 | 69 | #endif |