-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSensorBox.cpp
73 lines (61 loc) · 1.55 KB
/
SensorBox.cpp
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
69
70
71
72
73
// SensorBox.cpp
#include "Hardware.h"
#include "DriverInput.h"
#include "SensorBox.h"
// ADXL345_I2C * SensorBox::m_accel = NULL;
// ADXL345_I2C::AllAxes SensorBox::m_last_accel = {0.0};
Gyro * SensorBox::m_gyro = NULL;
float SensorBox::m_last_heading = 0;
Accelerometer * SensorBox::x_axis = NULL;
Accelerometer * SensorBox::y_axis = NULL;
Accelerometer * SensorBox::z_axis = NULL;
float SensorBox::last_x_accel = 0;
float SensorBox::last_y_accel = 0;
float SensorBox::last_z_accel = 0;
void SensorBox::Init()
{
//m_accel = Hardware::GetAccelerometer();
printf("Initializing gyro, please wait...");
m_gyro = Hardware::GetGyro();
printf("Done.\n");
//m_last_accel.XAxis = 0;
// m_last_accel.YAxis = 0;
// m_last_accel.ZAxis = 0;
m_last_heading = 0;
x_axis = Hardware::GetAccelX();
y_axis = Hardware::GetAccelY();
z_axis = Hardware::GetAccelZ();
}
void SensorBox::Process()
{
if (false) {
m_gyro->Reset();
}
last_x_accel = x_axis->GetAcceleration();
last_y_accel = y_axis->GetAcceleration();
last_z_accel = z_axis->GetAcceleration();
m_last_heading = m_gyro->GetAngle();
}
float SensorBox::Heading()
{
return m_last_heading;
}
float SensorBox::GyroTemperature()
{
return 0;
}
float SensorBox::XAcceleration()
{
//return m_last_accel.XAxis;
return x_axis->GetAcceleration();
}
float SensorBox::YAcceleration()
{
//return m_last_accel.YAxis;
return y_axis->GetAcceleration();
}
float SensorBox::ZAcceleration()
{
//return m_last_accel.ZAxis;
return z_axis->GetAcceleration();
}