14 #include "LiveWindow/LiveWindowSendable.h"
15 #include "interfaces/Accelerometer.h"
29 static const int kAddress = 0x1D;
30 static const int kPowerCtlRegister = 0x2D;
31 static const int kDataFormatRegister = 0x31;
32 static const int kDataRegister = 0x32;
33 static constexpr
double kGsPerLSB = 0.00390625;
35 kPowerCtl_Link = 0x20,
36 kPowerCtl_AutoSleep = 0x10,
37 kPowerCtl_Measure = 0x08,
38 kPowerCtl_Sleep = 0x04
40 enum DataFormatFields {
41 kDataFormat_SelfTest = 0x80,
42 kDataFormat_SPI = 0x40,
43 kDataFormat_IntInvert = 0x20,
44 kDataFormat_FullRes = 0x08,
45 kDataFormat_Justify = 0x04
49 enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
57 explicit ADXL345_I2C(I2C::Port port, Range range = kRange_2G,
58 int deviceAddress = kAddress);
66 double GetX()
override;
67 double GetY()
override;
68 double GetZ()
override;
74 void InitTable(std::shared_ptr<ITable> subtable)
override;
76 std::shared_ptr<ITable>
GetTable()
const override;
84 std::shared_ptr<ITable> m_table;
void InitTable(std::shared_ptr< ITable > subtable) override
Initializes a table for this sendable object.
Definition: ADXL345_I2C.cpp:87
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: ADXL345_I2C.h:78
ADXL345_I2C(I2C::Port port, Range range=kRange_2G, int deviceAddress=kAddress)
Constructs the ADXL345 Accelerometer over I2C.
Definition: ADXL345_I2C.cpp:29
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
Definition: ADXL345_I2C.h:50
void SetRange(Range range) override
Common interface for setting the measuring range of an accelerometer.
Definition: ADXL345_I2C.cpp:41
ADXL345 Accelerometer on I2C.
Definition: ADXL345_I2C.h:27
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: ADXL345_I2C.h:77
std::string GetSmartDashboardType() const override
Definition: ADXL345_I2C.cpp:83
virtual double GetAcceleration(Axes axis)
Get the acceleration of one axis in Gs.
Definition: ADXL345_I2C.cpp:58
I2C bus interface class.
Definition: I2C.h:23
double GetZ() override
Common interface for getting the z axis acceleration.
Definition: ADXL345_I2C.cpp:50
double GetX() override
Common interface for getting the x axis acceleration.
Definition: ADXL345_I2C.cpp:46
std::shared_ptr< ITable > GetTable() const override
Definition: ADXL345_I2C.cpp:98
Interface for 3-axis accelerometers.
Definition: Accelerometer.h:15
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: ADXL345_I2C.cpp:92
double GetY() override
Common interface for getting the y axis acceleration.
Definition: ADXL345_I2C.cpp:48
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
Definition: ADXL345_I2C.cpp:71