adafruit_msa3xx
CircuitPython library for the MSA301 and MSA311 Accelerometers
Author(s): Bryan Siepert
Implementation Notes
Hardware:
Adafruit MSA301 Triple Axis Accelerometer
Adafruit MSA311 Triple Axis Accelerometer
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
- class adafruit_msa3xx.BandWidth
An enum-like class representing the different bandwidths that the MSA301 can use. The values can be referenced like
BandWidth.WIDTH_1_HZ
orBandWidth.RATE_500_HZ
Possible values areBandWidth.RATE_1_HZ
BandWidth.RATE_1_95_HZ
BandWidth.RATE_3_9_HZ
BandWidth.RATE_7_81_HZ
BandWidth.RATE_15_63_HZ
BandWidth.RATE_31_25_HZ
BandWidth.RATE_62_5_HZ
BandWidth.RATE_125_HZ
BandWidth.RATE_250_HZ
BandWidth.RATE_500_HZ
BandWidth.RATE_1000_HZ
- class adafruit_msa3xx.DataRate
An enum-like class representing the different data rates that the MSA301 can use. The values can be referenced like
DataRate.RATE_1_HZ
orDataRate.RATE_1000_HZ
Possible values areDataRate.RATE_1_HZ
DataRate.RATE_1_95_HZ
DataRate.RATE_3_9_HZ
DataRate.RATE_7_81_HZ
DataRate.RATE_15_63_HZ
DataRate.RATE_31_25_HZ
DataRate.RATE_62_5_HZ
DataRate.RATE_125_HZ
DataRate.RATE_250_HZ
DataRate.RATE_500_HZ
DataRate.RATE_1000_HZ
- class adafruit_msa3xx.MSA301(i2c_bus: I2C)
Driver for the MSA301 Accelerometer.
- Parameters:
i2c_bus (I2C) – The I2C bus the MSA is connected to.
- class adafruit_msa3xx.MSA311(i2c_bus: I2C)
Driver for the MSA311 Accelerometer.
- Parameters:
i2c_bus (I2C) – The I2C bus the MSA is connected to.
- class adafruit_msa3xx.MSA3XX
Base driver class for the MSA301/311 Accelerometers.
- property acceleration: Tuple[float, float, float]
The x, y, z acceleration values returned in a 3-tuple and are in \(m / s ^ 2\)
- enable_tap_detection(*, tap_count: int = 1, threshold: int = 25, long_initial_window: bool = True, long_quiet_window: bool = True, double_tap_window: int = 4) None
Enables tap detection with configurable parameters.
- Parameters:
tap_count (int) – 1 to detect only single taps, or 2 to detect only double taps. default is 1
threshold (int) – A threshold for the tap detection. The higher the value the less sensitive the detection. This changes based on the accelerometer range. Default is 25.
long_initial_window (int) – This sets the length of the window of time where a spike in acceleration must occour in before being followed by a quiet period.
True
(default) sets the value to 70ms, False to 50ms. Default isTrue
long_quiet_window (int) – The length of the “quiet” period after an acceleration spike where no more spikes can occur for a tap to be registered.
True
(default) sets the value to 30ms, False to 20ms. Default isTrue
.double_tap_window (int) – The length of time after an initial tap is registered in which a second tap must be detected to count as a double tap. Setting a lower value will require a faster double tap. The value must be a
TapDuration
. Default isTapDuration.DURATION_250_MS
.
If you wish to set them yourself rather than using the defaults, you must use keyword arguments:
msa.enable_tap_detection(tap_count=2, threshold=25, double_tap_window=TapDuration.DURATION_700_MS)
- class adafruit_msa3xx.Mode
An enum-like class representing the different modes that the MSA301 can use. The values can be referenced like
Mode.NORMAL
orMode.SUSPEND
Possible values areMode.NORMAL
Mode.LOW_POWER
Mode.SUSPEND
- class adafruit_msa3xx.Range
An enum-like class representing the different acceleration measurement ranges that the MSA301 can use. The values can be referenced like
Range.RANGE_2_G
orRange.RANGE_16_G
Possible values areRange.RANGE_2_G
Range.RANGE_4_G
Range.RANGE_8_G
Range.RANGE_16_G
- class adafruit_msa3xx.Resolution
An enum-like class representing the different measurement ranges that the MSA301 can use. The values can be referenced like
Range.RANGE_2_G
orRange.RANGE_16_G
Possible values areResolution.RESOLUTION_14_BIT
Resolution.RESOLUTION_12_BIT
Resolution.RESOLUTION_10_BIT
Resolution.RESOLUTION_8_BIT
- class adafruit_msa3xx.TapDuration
An enum-like class representing the options for the “double_tap_window” parameter of
enable_tap_detection