10 #include "interfaces/Accelerometer.h"
11 #include "SensorBase.h"
13 #include "LiveWindow/LiveWindowSendable.h"
31 static const uint8_t kPowerCtlRegister = 0x2D;
32 static const uint8_t kDataFormatRegister = 0x31;
33 static const uint8_t kDataRegister = 0x32;
34 static constexpr
double kGsPerLSB = 0.00390625;
35 enum SPIAddressFields { kAddress_Read = 0x80, kAddress_MultiByte = 0x40 };
37 kPowerCtl_Link = 0x20,
38 kPowerCtl_AutoSleep = 0x10,
39 kPowerCtl_Measure = 0x08,
40 kPowerCtl_Sleep = 0x04
42 enum DataFormatFields {
43 kDataFormat_SelfTest = 0x80,
44 kDataFormat_SPI = 0x40,
45 kDataFormat_IntInvert = 0x20,
46 kDataFormat_FullRes = 0x08,
47 kDataFormat_Justify = 0x04
51 enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
59 ADXL345_SPI(SPI::Port port, Range range = kRange_2G);
66 virtual void SetRange(Range range)
override;
67 virtual double GetX()
override;
68 virtual double GetY()
override;
69 virtual double GetZ()
override;
75 virtual void InitTable(std::shared_ptr<ITable> subtable)
override;
77 virtual std::shared_ptr<ITable>
GetTable()
const override;
82 std::shared_ptr<ITable> m_table;
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:18
SPI bus interface class.
Definition: SPI.h:23
virtual double GetAcceleration(Axes axis)
Get the acceleration of one axis in Gs.
Definition: ADXL345_SPI.cpp:70
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
Definition: ADXL345_SPI.cpp:88
virtual std::shared_ptr< ITable > GetTable() const override
Definition: ADXL345_SPI.cpp:126
Class to write to digital outputs.
Definition: DigitalOutput.h:22
ADXL345 Accelerometer on SPI.
Definition: ADXL345_SPI.h:27
virtual double GetZ() override
{Common interface for getting the z axis acceleration.The acceleration along the z axis in g-forces} ...
Definition: ADXL345_SPI.cpp:62
virtual std::string GetSmartDashboardType() const override
Definition: ADXL345_SPI.cpp:109
virtual double GetX() override
{Common interface for getting the x axis acceleration.The acceleration along the x axis in g-forces} ...
Definition: ADXL345_SPI.cpp:56
virtual void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: ADXL345_SPI.h:79
Definition: ADXL345_SPI.h:52
virtual void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: ADXL345_SPI.h:78
virtual void InitTable(std::shared_ptr< ITable > subtable) override
Initializes a table for this sendable object.
Definition: ADXL345_SPI.cpp:113
virtual double GetY() override
{Common interface for getting the y axis acceleration.The acceleration along the y axis in g-forces} ...
Definition: ADXL345_SPI.cpp:59
virtual void SetRange(Range range) override
{Common interface for setting the measuring range of an accelerometer.The maximum acceleration...
Definition: ADXL345_SPI.cpp:46
ADXL345_SPI(SPI::Port port, Range range=kRange_2G)
Constructor.
Definition: ADXL345_SPI.cpp:24
Interface for 3-axis accelerometers.
Definition: Accelerometer.h:13
virtual void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: ADXL345_SPI.cpp:118