public class ADXL345_I2C extends SendableBase implements Accelerometer
Modifier and Type | Class and Description |
---|---|
static class |
ADXL345_I2C.AllAxes |
static class |
ADXL345_I2C.Axes |
Accelerometer.Range
Constructor and Description |
---|
ADXL345_I2C(I2C.Port port,
Accelerometer.Range range)
Constructs the ADXL345 Accelerometer with I2C address 0x1D.
|
ADXL345_I2C(I2C.Port port,
Accelerometer.Range range,
int deviceAddress)
Constructs the ADXL345 Accelerometer over I2C.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
double |
getAcceleration(ADXL345_I2C.Axes axis)
Get the acceleration of one axis in Gs.
|
ADXL345_I2C.AllAxes |
getAccelerations()
Get the acceleration of all axes in Gs.
|
double |
getX()
Common interface for getting the x axis acceleration.
|
double |
getY()
Common interface for getting the y axis acceleration.
|
double |
getZ()
Common interface for getting the z axis acceleration.
|
void |
initSendable(SendableBuilder builder)
Initializes this
Sendable object. |
void |
setRange(Accelerometer.Range range)
Common interface for setting the measuring range of an accelerometer.
|
addChild, free, getName, getSubsystem, setName, setName, setName, setSubsystem
protected I2C m_i2c
public ADXL345_I2C(I2C.Port port, Accelerometer.Range range)
port
- The I2C port the accelerometer is attached torange
- The range (+ or -) that the accelerometer will measure.public ADXL345_I2C(I2C.Port port, Accelerometer.Range range, int deviceAddress)
port
- The I2C port the accelerometer is attached torange
- The range (+ or -) that the accelerometer will measure.deviceAddress
- I2C address of the accelerometer (0x1D or 0x53)public void close()
close
in interface AutoCloseable
close
in class SendableBase
public void setRange(Accelerometer.Range range)
Accelerometer
setRange
in interface Accelerometer
range
- The maximum acceleration, positive or negative, that the accelerometer will
measure. Not all accelerometers support all ranges.public double getX()
Accelerometer
getX
in interface Accelerometer
public double getY()
Accelerometer
getY
in interface Accelerometer
public double getZ()
Accelerometer
getZ
in interface Accelerometer
public double getAcceleration(ADXL345_I2C.Axes axis)
axis
- The axis to read from.public ADXL345_I2C.AllAxes getAccelerations()
public void initSendable(SendableBuilder builder)
Sendable
Sendable
object.initSendable
in interface Sendable
builder
- sendable builder