13 #include "LiveWindow/LiveWindowSendable.h" 15 #include "SensorBase.h" 16 #include "interfaces/Accelerometer.h" 17 #include "networktables/NetworkTableEntry.h" 33 static const int kPowerCtlRegister = 0x2D;
34 static const int kDataFormatRegister = 0x31;
35 static const int kDataRegister = 0x32;
36 static constexpr
double kGsPerLSB = 0.00390625;
37 enum SPIAddressFields { kAddress_Read = 0x80, kAddress_MultiByte = 0x40 };
39 kPowerCtl_Link = 0x20,
40 kPowerCtl_AutoSleep = 0x10,
41 kPowerCtl_Measure = 0x08,
42 kPowerCtl_Sleep = 0x04
44 enum DataFormatFields {
45 kDataFormat_SelfTest = 0x80,
46 kDataFormat_SPI = 0x40,
47 kDataFormat_IntInvert = 0x20,
48 kDataFormat_FullRes = 0x08,
49 kDataFormat_Justify = 0x04
53 enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
61 explicit ADXL345_SPI(SPI::Port port, Range range = kRange_2G);
69 double GetX()
override;
70 double GetY()
override;
71 double GetZ()
override;
77 void InitTable(std::shared_ptr<nt::NetworkTable> subtable)
override;
double GetX() override
Common interface for getting the x axis acceleration.
Definition: ADXL345_SPI.cpp:60
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: ADXL345_SPI.h:80
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: ADXL345_SPI.cpp:128
double GetZ() override
Common interface for getting the z axis acceleration.
Definition: ADXL345_SPI.cpp:64
SPI bus interface class.
Definition: SPI.h:28
void InitTable(std::shared_ptr< nt::NetworkTable > subtable) override
Initializes a table for this sendable object.
Definition: ADXL345_SPI.cpp:115
ADXL345_SPI(SPI::Port port, Range range=kRange_2G)
Constructor.
Definition: ADXL345_SPI.cpp:29
Definition: ADXL345_SPI.h:54
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
Definition: ADXL345_SPI.cpp:90
std::string GetSmartDashboardType() const override
Definition: ADXL345_SPI.cpp:111
Class to write to digital outputs.
Definition: DigitalOutput.h:27
ADXL345 Accelerometer on SPI.
Definition: ADXL345_SPI.h:31
NetworkTables Entry.
Definition: NetworkTableEntry.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:72
void SetRange(Range range) override
Common interface for setting the measuring range of an accelerometer.
Definition: ADXL345_SPI.cpp:51
double GetY() override
Common interface for getting the y axis acceleration.
Definition: ADXL345_SPI.cpp:62