ADXL345_SPI¶
- class wpilib.ADXL345_SPI(port, range)[source]¶
Bases: wpilib.SensorBase
ADXL345 accelerometer device via spi
Constructor. Use this when the device is the first/only device on the bus
Parameters: - port – The SPI port that the accelerometer is connected to
- range – The range (+ or -) that the accelerometer will measure.
- ADXL345_SPI.getAcceleration(axis)[source]¶
Get the acceleration of one axis in Gs.
Parameters: axis – The axis to read from. Returns: An object containing the acceleration measured on each axis of the ADXL345 in Gs.
- ADXL345_SPI.getAccelerations()[source]¶
Get the acceleration of all axes in Gs.
Returns: X,Y,Z tuple of acceleration measured on all axes of the ADXL345 in Gs.
- ADXL345_SPI.getX()[source]¶
Get the x axis acceleration
Returns: The acceleration along the x axis in g-forces
- ADXL345_SPI.getY()[source]¶
Get the y axis acceleration
Returns: The acceleration along the y axis in g-forces
- ADXL345_SPI.getZ()[source]¶
Get the z axis acceleration
Returns: The acceleration along the z axis in g-forces
- ADXL345_SPI.kAddress_MultiByte = 64¶
- ADXL345_SPI.kAddress_Read = 128¶
- ADXL345_SPI.kDataFormatRegister = 49¶
- ADXL345_SPI.kDataFormat_FullRes = 8¶
- ADXL345_SPI.kDataFormat_IntInvert = 32¶
- ADXL345_SPI.kDataFormat_Justify = 4¶
- ADXL345_SPI.kDataFormat_SPI = 64¶
- ADXL345_SPI.kDataFormat_SelfTest = 128¶
- ADXL345_SPI.kDataRegister = 50¶
- ADXL345_SPI.kGsPerLSB = 0.00390625¶
- ADXL345_SPI.kPowerCtlRegister = 45¶
- ADXL345_SPI.kPowerCtl_AutoSleep = 16¶
- ADXL345_SPI.kPowerCtl_Link = 32¶
- ADXL345_SPI.kPowerCtl_Measure = 8¶
- ADXL345_SPI.kPowerCtl_Sleep = 4¶
- ADXL345_SPI.setRange(range)[source]¶
Set the measuring range of the accelerometer.
Parameters: range (ADXL345_SPI.Range) – The maximum acceleration, positive or negative, that the accelerometer will measure.