14 #include "LiveWindow/LiveWindowSendable.h" 15 #include "interfaces/Accelerometer.h" 16 #include "networktables/NetworkTableEntry.h" 30 static const int kAddress = 0x1D;
31 static const int kPowerCtlRegister = 0x2D;
32 static const int kDataFormatRegister = 0x31;
33 static const int kDataRegister = 0x32;
34 static constexpr
double kGsPerLSB = 0.00390625;
36 kPowerCtl_Link = 0x20,
37 kPowerCtl_AutoSleep = 0x10,
38 kPowerCtl_Measure = 0x08,
39 kPowerCtl_Sleep = 0x04
41 enum DataFormatFields {
42 kDataFormat_SelfTest = 0x80,
43 kDataFormat_SPI = 0x40,
44 kDataFormat_IntInvert = 0x20,
45 kDataFormat_FullRes = 0x08,
46 kDataFormat_Justify = 0x04
50 enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
58 explicit ADXL345_I2C(I2C::Port port, Range range = kRange_2G,
59 int deviceAddress = kAddress);
67 double GetX()
override;
68 double GetY()
override;
69 double GetZ()
override;
75 void InitTable(std::shared_ptr<nt::NetworkTable> subtable)
override;
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:30
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
Definition: ADXL345_I2C.h:51
void SetRange(Range range) override
Common interface for setting the measuring range of an accelerometer.
Definition: ADXL345_I2C.cpp:42
ADXL345 Accelerometer on I2C.
Definition: ADXL345_I2C.h:28
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:84
virtual double GetAcceleration(Axes axis)
Get the acceleration of one axis in Gs.
Definition: ADXL345_I2C.cpp:59
I2C bus interface class.
Definition: I2C.h:25
double GetZ() override
Common interface for getting the z axis acceleration.
Definition: ADXL345_I2C.cpp:51
double GetX() override
Common interface for getting the x axis acceleration.
Definition: ADXL345_I2C.cpp:47
NetworkTables Entry.
Definition: NetworkTableEntry.h:30
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:101
double GetY() override
Common interface for getting the y axis acceleration.
Definition: ADXL345_I2C.cpp:49
void InitTable(std::shared_ptr< nt::NetworkTable > subtable) override
Initializes a table for this sendable object.
Definition: ADXL345_I2C.cpp:88
virtual AllAxes GetAccelerations()
Get the acceleration of all axes in Gs.
Definition: ADXL345_I2C.cpp:72