-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsensorsWrapper.h
68 lines (57 loc) · 1.52 KB
/
sensorsWrapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef _SENSORSWRAPPER_H_
#define _SENSORSWRAPPER_H_ 1
#define SENSOR_BATT_ANALOGPIN A0
#define SENSORS_SONAR_TRIGGER_PIN 4
#define SENSORS_SONAR_ECHO_PIN 2
#define SENSORS_SONAR_MAX_DISTANCE 350
#include <I2Cdev.h>
#include <NewPing.h>
#include <SFE_BMP180.h>
#include <mpu.h>
class sensorsWrapper
{
public:
void installIn(void* mcp){copterPointer = mcp;};
void init();
void update();
void calibration();
float getPitch(){return pitch;};
float getRoll(){return roll;};
float getRotation(){return zRotation;};
double getHeight(){return (sonarAlt < 5.0 && sonarAlt > 0.0)?sonarAlt:baroAlt;};
double getBatteryStatus(){return batteryStatus;};
double* getRollPointer(){return (double*)&roll;}
double* getPitchPointer(){return (double*)&pitch;}
double* getYawPointer(){return (double*)&zRotation;}
double* getAltChangePointer(){return (double*)&altChange;}
private:
float roll;
float pitch;
float zRotation;
double altChange;
uint8_t tmp;
void* copterPointer;
/* IMU */
inline void imuInit();
inline void imuUpdate();
/* Battery status */
double batteryStatus;
inline void batteryInit();
inline void batteryUpdate();
/* Sonar */
NewPing* sonar;
uint16_t sonarAlt;
inline void sonarInit();
inline void sonarUpdate();
/* Barometer */
SFE_BMP180 pressure;
double baselinePressureValue;
double pressureValue;
double baselineTemperatureValue;
double temperatureValue;
double baroAlt;
double getPressure();
inline void baroInit();
inline void baroUpdate();
};
#endif