|
Adafruit LIS3MDL Arduino Library
|
#include <Adafruit_LIS3MDL.h>
Public Member Functions | |
| Adafruit_LIS3MDL (void) | |
| Instantiates a new LIS3MDL class. | |
| bool | begin_I2C (uint8_t i2c_addr=LIS3MDL_I2CADDR_DEFAULT, TwoWire *wire=&Wire) |
| Sets up the hardware and initializes I2C. More... | |
| bool | begin_SPI (uint8_t cs_pin, SPIClass *theSPI=&SPI, uint32_t frequency=1000000) |
| Sets up the hardware and initializes hardware SPI. More... | |
| bool | begin_SPI (int8_t cs_pin, int8_t sck_pin, int8_t miso_pin, int8_t mosi_pin, uint32_t frequency=1000000) |
| Sets up the hardware and initializes software SPI. More... | |
| void | reset (void) |
| Performs a software reset. | |
| void | setPerformanceMode (lis3mdl_performancemode_t mode) |
| Set the performance mode, LIS3MDL_LOWPOWERMODE, LIS3MDL_MEDIUMMODE, LIS3MDL_HIGHMODE or LIS3MDL_ULTRAHIGHMODE. More... | |
| lis3mdl_performancemode_t | getPerformanceMode (void) |
| Get the performance mode. More... | |
| void | setOperationMode (lis3mdl_operationmode_t mode) |
| Set the operation mode, LIS3MDL_CONTINUOUSMODE, LIS3MDL_SINGLEMODE or LIS3MDL_POWERDOWNMODE. More... | |
| lis3mdl_operationmode_t | getOperationMode (void) |
| Get the operation mode. More... | |
| void | setDataRate (lis3mdl_dataRate_t dataRate) |
| Sets the data rate for the LIS3MDL (controls power consumption) from 0.625 Hz to 80Hz. More... | |
| lis3mdl_dataRate_t | getDataRate (void) |
| Gets the data rate for the LIS3MDL (controls power consumption) More... | |
| void | setRange (lis3mdl_range_t range) |
| Set the resolution range: +-4 gauss, 8 gauss, 12 gauss, or 16 gauss. More... | |
| lis3mdl_range_t | getRange (void) |
| Read the resolution range: +-4 gauss, 8 gauss, 12 gauss, or 16 gauss. More... | |
| void | setIntThreshold (uint16_t value) |
| Set the interrupt threshold value. More... | |
| uint16_t | getIntThreshold (void) |
| Get the interrupt threshold value. More... | |
| void | configInterrupt (bool enableX, bool enableY, bool enableZ, bool polarity, bool latch, bool enableInt) |
| Configure INT_CFG. More... | |
| void | selfTest (bool flag) |
| Enable or disable self-test. More... | |
| void | read () |
| Read the XYZ data from the magnetometer 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... | |
| int | readMagneticField (float &x, float &y, float &z) |
| Read magnetic data. More... | |
| float | magneticFieldSampleRate (void) |
| Get the magnetic data rate. More... | |
| int | magneticFieldAvailable (void) |
| Check for available data from magnetic. More... | |
Public Attributes | |
| int16_t | x |
| The last read X mag in raw units. | |
| int16_t | y |
| The last read Y mag in raw units. | |
| int16_t | z |
| The last read Z mag in raw units. | |
| float | x_gauss |
| The last read X mag in 'gauss'. | |
| float | y_gauss |
| The last read Y mag in 'gauss'. | |
| float | z_gauss |
| The last read Z mag in 'gauss'. | |
| lis3mdl_range_t | rangeBuffered = LIS3MDL_RANGE_4_GAUSS |
| buffer for the magnetometer range | |
Class for hardware interfacing with an LIS3MDL magnetometer
| bool Adafruit_LIS3MDL::begin_I2C | ( | uint8_t | i2c_address = LIS3MDL_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. |
| boolean Adafruit_LIS3MDL::begin_SPI | ( | uint8_t | cs_pin, |
| SPIClass * | theSPI = &SPI, |
||
| uint32_t | frequency = 1000000 |
||
| ) |
Sets up the hardware and initializes hardware SPI.
| cs_pin | The arduino pin # connected to chip select |
| theSPI | The SPI object to be used for SPI connections. |
| frequency | The SPI bus frequency |
| bool Adafruit_LIS3MDL::begin_SPI | ( | int8_t | cs_pin, |
| int8_t | sck_pin, | ||
| int8_t | miso_pin, | ||
| int8_t | mosi_pin, | ||
| uint32_t | frequency = 1000000 |
||
| ) |
Sets up the hardware and initializes software SPI.
| cs_pin | The arduino pin # connected to chip select |
| sck_pin | The arduino pin # connected to SPI clock |
| miso_pin | The arduino pin # connected to SPI MISO |
| mosi_pin | The arduino pin # connected to SPI MOSI |
| frequency | The SPI bus frequency |
| void Adafruit_LIS3MDL::setPerformanceMode | ( | lis3mdl_performancemode_t | mode | ) |
Set the performance mode, LIS3MDL_LOWPOWERMODE, LIS3MDL_MEDIUMMODE, LIS3MDL_HIGHMODE or LIS3MDL_ULTRAHIGHMODE.
| mode | Enumerated lis3mdl_performancemode_t |
| lis3mdl_performancemode_t Adafruit_LIS3MDL::getPerformanceMode | ( | void | ) |
Get the performance mode.
| void Adafruit_LIS3MDL::setOperationMode | ( | lis3mdl_operationmode_t | mode | ) |
Set the operation mode, LIS3MDL_CONTINUOUSMODE, LIS3MDL_SINGLEMODE or LIS3MDL_POWERDOWNMODE.
| mode | Enumerated lis3mdl_operationmode_t |
| lis3mdl_operationmode_t Adafruit_LIS3MDL::getOperationMode | ( | void | ) |
Get the operation mode.
| void Adafruit_LIS3MDL::setDataRate | ( | lis3mdl_dataRate_t | dataRate | ) |
Sets the data rate for the LIS3MDL (controls power consumption) from 0.625 Hz to 80Hz.
| dataRate | Enumerated lis3mdl_dataRate_t |
| lis3mdl_dataRate_t Adafruit_LIS3MDL::getDataRate | ( | void | ) |
Gets the data rate for the LIS3MDL (controls power consumption)
| void Adafruit_LIS3MDL::setRange | ( | lis3mdl_range_t | range | ) |
Set the resolution range: +-4 gauss, 8 gauss, 12 gauss, or 16 gauss.
| range | Enumerated lis3mdl_range_t |
| lis3mdl_range_t Adafruit_LIS3MDL::getRange | ( | void | ) |
Read the resolution range: +-4 gauss, 8 gauss, 12 gauss, or 16 gauss.
| void Adafruit_LIS3MDL::setIntThreshold | ( | uint16_t | value | ) |
Set the interrupt threshold value.
| value | 16-bit unsigned raw value |
| uint16_t Adafruit_LIS3MDL::getIntThreshold | ( | void | ) |
Get the interrupt threshold value.
| void Adafruit_LIS3MDL::configInterrupt | ( | bool | enableX, |
| bool | enableY, | ||
| bool | enableZ, | ||
| bool | polarity, | ||
| bool | latch, | ||
| bool | enableInt | ||
| ) |
Configure INT_CFG.
| enableX | Enable interrupt generation on X-axis |
| enableY | Enable interrupt generation on Y-axis |
| enableZ | Enable interrupt generation on Z-axis |
| polarity | Sets the polarity of the INT output logic |
| latch | If true (latched) the INT pin remains in the same state until INT_SRC is read. |
| enableInt | Interrupt enable on INT pin |
| void Adafruit_LIS3MDL::selfTest | ( | bool | flag | ) |
Enable or disable self-test.
| flag | If true, enable self-test |
| bool Adafruit_LIS3MDL::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_LIS3MDL::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 |
| int Adafruit_LIS3MDL::readMagneticField | ( | float & | x, |
| float & | y, | ||
| float & | z | ||
| ) |
Read magnetic data.
| x | reference to x axis |
| y | reference to y axis |
| z | reference to z axis |
| float Adafruit_LIS3MDL::magneticFieldSampleRate | ( | void | ) |
Get the magnetic data rate.
| int Adafruit_LIS3MDL::magneticFieldAvailable | ( | void | ) |
Check for available data from magnetic.
1.8.13