|
Adafruit MSA301 Sensor Library
|
#include <Adafruit_MSA301.h>
Public Member Functions | |
| Adafruit_MSA301 (void) | |
| Instantiates a new MSA301 class. | |
| bool | begin (uint8_t i2c_addr=MSA301_I2CADDR_DEFAULT, TwoWire *wire=&Wire) |
| Sets up the hardware and initializes I2C. More... | |
| void | setDataRate (msa301_dataRate_t dataRate) |
| Sets the data rate for the MSA301 (controls power consumption) from 1 Hz to 1000Hz. More... | |
| msa301_dataRate_t | getDataRate (void) |
| Gets the data rate for the MSA301 (controls power consumption) More... | |
| void | enableAxes (bool x, bool y, bool z) |
| What axes of the accelerometer we want enabled for reading. More... | |
| void | setPowerMode (msa301_powermode_t mode) |
| Set the power mode, MSA301_NORMALMODE, MSA301_LOWPOWERMODE or MSA301_SUSPENDMODE. More... | |
| msa301_powermode_t | getPowerMode (void) |
| Get the power mode. More... | |
| void | setBandwidth (msa301_bandwidth_t bandwidth) |
| Set the bandwidth, ranges from 1.95Hz to 500Hz. More... | |
| msa301_bandwidth_t | getBandwidth (void) |
| Get the bandwidth. More... | |
| void | setRange (msa301_range_t range) |
| Set the resolution range: +-2g, 4g, 8g, or 16g. More... | |
| msa301_range_t | getRange (void) |
| Read the resolution range: +-2g, 4g, 8g, or 16g. More... | |
| void | setResolution (msa301_resolution_t resolution) |
| Set the resolution - 8, 10, 12, or 14bits. More... | |
| msa301_resolution_t | getResolution (void) |
| Read the resolution - 8, 10, 12, or 14bits. More... | |
| void | read () |
| Read the XYZ data from the accelerometer and store in the internal x, y and z (and x_g, y_g, z_g) member variables. | |
| bool | getEvent (sensors_event_t *event) |
| Gets the most recent sensor event, Adafruit Unified Sensor format. More... | |
| void | getSensor (sensor_t *sensor) |
| Gets the sensor_t device data, Adafruit Unified Sensor format. More... | |
| void | enableInterrupts (bool singletap=false, bool doubletap=false, bool activeX=false, bool activeY=false, bool activeZ=false, bool newData=false, bool freefall=false, bool orient=false) |
| Set which interrupts are enabled. More... | |
| void | mapInterruptPin (bool singletap=false, bool doubletap=false, bool activity=false, bool newData=false, bool freefall=false, bool orient=false) |
| Set which interrupts are mapped to the INT pin. More... | |
| uint8_t | getClick (void) |
| Gets the most recent click detect status register value. More... | |
| uint8_t | getMotionInterruptStatus (void) |
| Gets the most recent motion interrupt status register value. More... | |
| uint8_t | getDataInterruptStatus (void) |
| Gets the most recent data interrupt status register value. More... | |
| void | setClick (bool tap_quiet, bool tap_shock, msa301_tapduration_t tapduration, uint8_t tapthresh) |
| Set the click detection register thresholds. More... | |
Public Attributes | |
| int16_t | x |
| The last read X acceleration in raw units. | |
| int16_t | y |
| The last read Y acceleration in raw units. | |
| int16_t | z |
| The last read Z acceleration in raw units. | |
| float | x_g |
| The last read X acceleration in 'g'. | |
| float | y_g |
| The last read Y acceleration in 'g'. | |
| float | z_g |
| The last read X acceleration in 'g'. | |
Class for hardware interfacing with an MSA301 accelerometer
| bool Adafruit_MSA301::begin | ( | uint8_t | i2c_address = MSA301_I2CADDR_DEFAULT, |
| TwoWire * | wire = &Wire |
||
| ) |
Sets up the hardware and initializes I2C.
| i2c_address | The I2C address to be used. |
| wire | The Wire object to be used for I2C connections. |
| void Adafruit_MSA301::setDataRate | ( | msa301_dataRate_t | dataRate | ) |
Sets the data rate for the MSA301 (controls power consumption) from 1 Hz to 1000Hz.
| dataRate | Enumerated msa301_dataRate_t |
| msa301_dataRate_t Adafruit_MSA301::getDataRate | ( | void | ) |
Gets the data rate for the MSA301 (controls power consumption)
| void Adafruit_MSA301::enableAxes | ( | bool | enableX, |
| bool | enableY, | ||
| bool | enableZ | ||
| ) |
What axes of the accelerometer we want enabled for reading.
| enableX | True to enable X axis |
| enableY | True to enable Y axis |
| enableZ | True to enable Z axis |
| void Adafruit_MSA301::setPowerMode | ( | msa301_powermode_t | mode | ) |
Set the power mode, MSA301_NORMALMODE, MSA301_LOWPOWERMODE or MSA301_SUSPENDMODE.
| mode | Enumerated msa301_powermode_t |
| msa301_powermode_t Adafruit_MSA301::getPowerMode | ( | void | ) |
Get the power mode.
| void Adafruit_MSA301::setBandwidth | ( | msa301_bandwidth_t | bandwidth | ) |
Set the bandwidth, ranges from 1.95Hz to 500Hz.
| bandwidth | Enumerated msa301_range_t |
| msa301_bandwidth_t Adafruit_MSA301::getBandwidth | ( | void | ) |
Get the bandwidth.
| void Adafruit_MSA301::setRange | ( | msa301_range_t | range | ) |
Set the resolution range: +-2g, 4g, 8g, or 16g.
| range | Enumerated msa301_range_t |
| msa301_range_t Adafruit_MSA301::getRange | ( | void | ) |
Read the resolution range: +-2g, 4g, 8g, or 16g.
| void Adafruit_MSA301::setResolution | ( | msa301_resolution_t | resolution | ) |
Set the resolution - 8, 10, 12, or 14bits.
| resolution | Enumerated msa301_resolution_t |
| msa301_resolution_t Adafruit_MSA301::getResolution | ( | void | ) |
Read the resolution - 8, 10, 12, or 14bits.
| bool Adafruit_MSA301::getEvent | ( | sensors_event_t * | event | ) |
Gets the most recent sensor event, Adafruit Unified Sensor format.
| event | Pointer to an Adafruit Unified sensor_event_t object that we'll fill in |
| void Adafruit_MSA301::getSensor | ( | sensor_t * | sensor | ) |
Gets the sensor_t device data, Adafruit Unified Sensor format.
| sensor | Pointer to an Adafruit Unified sensor_t object that we'll fill in |
| void Adafruit_MSA301::enableInterrupts | ( | bool | singletap = false, |
| bool | doubletap = false, |
||
| bool | activeX = false, |
||
| bool | activeY = false, |
||
| bool | activeZ = false, |
||
| bool | newData = false, |
||
| bool | freefall = false, |
||
| bool | orient = false |
||
| ) |
Set which interrupts are enabled.
| singletap | Whether to trigger INT on single tap interrupt |
| doubletap | Whether to trigger INT on double tap interrupt |
| activeX | Whether to trigger INT on X axis activity interrupt |
| activeY | Whether to trigger INT on Y axis activity interrupt |
| activeZ | Whether to trigger INT on Z axis activity interrupt |
| newData | Whether to trigger INT on new data available interrupt |
| freefall | Whether to trigger INT on freefall interrupt |
| orient | Whether to trigger INT on orientation interrupt |
| void Adafruit_MSA301::mapInterruptPin | ( | bool | singletap = false, |
| bool | doubletap = false, |
||
| bool | activity = false, |
||
| bool | newData = false, |
||
| bool | freefall = false, |
||
| bool | orient = false |
||
| ) |
Set which interrupts are mapped to the INT pin.
| singletap | Whether to trigger INT on single tap interrupt |
| doubletap | Whether to trigger INT on double tap interrupt |
| activity | Whether to trigger INT on activity interrupt |
| newData | Whether to trigger INT on new data available interrupt |
| freefall | Whether to trigger INT on freefall interrupt |
| orient | Whether to trigger INT on orientation interrupt |
| uint8_t Adafruit_MSA301::getClick | ( | void | ) |
Gets the most recent click detect status register value.
| uint8_t Adafruit_MSA301::getMotionInterruptStatus | ( | void | ) |
Gets the most recent motion interrupt status register value.
| uint8_t Adafruit_MSA301::getDataInterruptStatus | ( | void | ) |
Gets the most recent data interrupt status register value.
| void Adafruit_MSA301::setClick | ( | bool | tap_quiet, |
| bool | tap_shock, | ||
| msa301_tapduration_t | tapduration, | ||
| uint8_t | tapthresh | ||
| ) |
Set the click detection register thresholds.
| tap_quiet | TAP_QUIET flag (check datasheet for details) |
| tap_shock | TAP_SHOCK flag (check datasheet for details) |
| tapduration | How long to listen for a second tap (check datasheet for details) |
| tapthresh | How strong the tap signal has to be (check datasheet for details) |
1.8.13