10 #include "interfaces/Accelerometer.h"
12 #include "LiveWindow/LiveWindowSendable.h"
27 static const uint8_t kAddress = 0x1D;
28 static const uint8_t kPowerCtlRegister = 0x2D;
29 static const uint8_t kDataFormatRegister = 0x31;
30 static const uint8_t kDataRegister = 0x32;
31 static constexpr
double kGsPerLSB = 0.00390625;
33 kPowerCtl_Link = 0x20,
34 kPowerCtl_AutoSleep = 0x10,
35 kPowerCtl_Measure = 0x08,
36 kPowerCtl_Sleep = 0x04
38 enum DataFormatFields {
39 kDataFormat_SelfTest = 0x80,
40 kDataFormat_SPI = 0x40,
41 kDataFormat_IntInvert = 0x20,
42 kDataFormat_FullRes = 0x08,
43 kDataFormat_Justify = 0x04
47 enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
55 explicit ADXL345_I2C(Port port, Range range = kRange_2G,
int deviceAddress = kAddress);
62 virtual void SetRange(Range range)
override;
63 virtual double GetX()
override;
64 virtual double GetY()
override;
65 virtual double GetZ()
override;
71 virtual void InitTable(std::shared_ptr<ITable> subtable)
override;
73 virtual std::shared_ptr<ITable>
GetTable()
const override;
78 std::shared_ptr<ITable> m_table;
virtual double GetAcceleration(Axes axis)
Get the acceleration of one axis in Gs.
Definition: ADXL345_I2C.cpp:57
Definition: ADXL345_I2C.h:48
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:18
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
Definition: ADXL345_I2C.cpp:69
virtual std::string GetSmartDashboardType() const override
Definition: ADXL345_I2C.cpp:80
virtual void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: ADXL345_I2C.h:74
virtual std::shared_ptr< ITable > GetTable() const override
Definition: ADXL345_I2C.cpp:95
virtual double GetX() override
{Common interface for getting the x axis acceleration.The acceleration along the x axis in g-forces} ...
Definition: ADXL345_I2C.cpp:43
virtual void InitTable(std::shared_ptr< ITable > subtable) override
Initializes a table for this sendable object.
Definition: ADXL345_I2C.cpp:84
virtual void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: ADXL345_I2C.h:75
virtual void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: ADXL345_I2C.cpp:89
virtual void SetRange(Range range) override
{Common interface for setting the measuring range of an accelerometer.The maximum acceleration...
Definition: ADXL345_I2C.cpp:38
ADXL345_I2C(Port port, Range range=kRange_2G, int deviceAddress=kAddress)
Constructs the ADXL345 Accelerometer over I2C.
Definition: ADXL345_I2C.cpp:26
I2C bus interface class.
Definition: I2C.h:19
virtual double GetY() override
{Common interface for getting the y axis acceleration.The acceleration along the y axis in g-forces} ...
Definition: ADXL345_I2C.cpp:46
ADXL345 Accelerometer on I2C.
Definition: ADXL345_I2C.h:23
Interface for 3-axis accelerometers.
Definition: Accelerometer.h:13
virtual double GetZ() override
{Common interface for getting the z axis acceleration.The acceleration along the z axis in g-forces} ...
Definition: ADXL345_I2C.cpp:49