13 #include "LiveWindow/LiveWindowSendable.h"
15 #include "SensorBase.h"
16 #include "interfaces/Accelerometer.h"
32 static const int kPowerCtlRegister = 0x2D;
33 static const int kDataFormatRegister = 0x31;
34 static const int kDataRegister = 0x32;
35 static constexpr
double kGsPerLSB = 0.00390625;
36 enum SPIAddressFields { kAddress_Read = 0x80, kAddress_MultiByte = 0x40 };
38 kPowerCtl_Link = 0x20,
39 kPowerCtl_AutoSleep = 0x10,
40 kPowerCtl_Measure = 0x08,
41 kPowerCtl_Sleep = 0x04
43 enum DataFormatFields {
44 kDataFormat_SelfTest = 0x80,
45 kDataFormat_SPI = 0x40,
46 kDataFormat_IntInvert = 0x20,
47 kDataFormat_FullRes = 0x08,
48 kDataFormat_Justify = 0x04
52 enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
60 explicit ADXL345_SPI(SPI::Port port, Range range = kRange_2G);
68 double GetX()
override;
69 double GetY()
override;
70 double GetZ()
override;
76 void InitTable(std::shared_ptr<ITable> subtable)
override;
78 std::shared_ptr<ITable>
GetTable()
const override;
86 std::shared_ptr<ITable> m_table;
double GetX() override
Common interface for getting the x axis acceleration.
Definition: ADXL345_SPI.cpp:59
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: ADXL345_SPI.h:80
std::shared_ptr< ITable > GetTable() const override
Definition: ADXL345_SPI.cpp:127
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
void InitTable(std::shared_ptr< ITable > subtable) override
Initializes a table for this sendable object.
Definition: ADXL345_SPI.cpp:114
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: ADXL345_SPI.cpp:119
double GetZ() override
Common interface for getting the z axis acceleration.
Definition: ADXL345_SPI.cpp:63
SPI bus interface class.
Definition: SPI.h:26
ADXL345_SPI(SPI::Port port, Range range=kRange_2G)
Constructor.
Definition: ADXL345_SPI.cpp:28
Definition: ADXL345_SPI.h:53
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
Definition: ADXL345_SPI.cpp:89
std::string GetSmartDashboardType() const override
Definition: ADXL345_SPI.cpp:110
Class to write to digital outputs.
Definition: DigitalOutput.h:26
ADXL345 Accelerometer on SPI.
Definition: ADXL345_SPI.h:30
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: ADXL345_SPI.h:79
Interface for 3-axis accelerometers.
Definition: Accelerometer.h:15
virtual double GetAcceleration(Axes axis)
Get the acceleration of one axis in Gs.
Definition: ADXL345_SPI.cpp:71
void SetRange(Range range) override
Common interface for setting the measuring range of an accelerometer.
Definition: ADXL345_SPI.cpp:50
double GetY() override
Common interface for getting the y axis acceleration.
Definition: ADXL345_SPI.cpp:61