Adafruit Library
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Adafruit_CPlay_LIS3DH Class Reference

Class that stores state and functions for interacting with Adafruit_LIS3DH. More...

#include <Adafruit_CPlay_LIS3DH.h>

Inheritance diagram for Adafruit_CPlay_LIS3DH:
Adafruit_Sensor

Public Member Functions

 Adafruit_CPlay_LIS3DH (TwoWire *Wi=&Wire)
 Instantiates a new LIS3DH class in I2C. More...
 
 Adafruit_CPlay_LIS3DH (int8_t cspin, SPIClass *theSPI=&SPI)
 Instantiates a new LIS3DH class using hardware SPI. More...
 
 Adafruit_CPlay_LIS3DH (int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin)
 Instantiates a new LIS3DH class using software SPI. More...
 
bool begin (uint8_t addr=LIS3DH_DEFAULT_ADDRESS, uint8_t nWAI=0x33)
 Setups the HW (reads coefficients values, etc.) More...
 
uint8_t getDeviceID ()
 Get Device ID from LIS3DH_REG_WHOAMI. More...
 
bool haveNewData ()
 Check to see if new data available. More...
 
void read ()
 Reads x y z values at once.
 
int16_t readADC (uint8_t a)
 Read the auxilary ADC. More...
 
void setRange (lis3dh_range_t range)
 Sets the g range for the accelerometer. More...
 
lis3dh_range_t getRange (void)
 Gets the g range for the accelerometer. More...
 
void setDataRate (lis3dh_dataRate_t dataRate)
 Sets the data rate for the LIS3DH (controls power consumption) More...
 
lis3dh_dataRate_t getDataRate (void)
 Gets the data rate for the LIS3DH (controls power consumption) More...
 
bool getEvent (sensors_event_t *event)
 Gets the most recent sensor event. More...
 
void getSensor (sensor_t *sensor)
 Gets the sensor_t data. More...
 
void setClick (uint8_t c, uint8_t clickthresh, uint8_t timelimit=10, uint8_t timelatency=20, uint8_t timewindow=255)
 Set INT to output for single or double click. More...
 
uint8_t getClick (void)
 Get uint8_t for single or double click. More...
 
- Public Member Functions inherited from Adafruit_Sensor
virtual void enableAutoRange (bool enabled)
 enable or disable auto-ranging for the sensor More...
 

Public Attributes

int16_t x
 
int16_t y
 
int16_t z
 
float x_g
 
float y_g
 
float z_g
 

Protected Member Functions

uint8_t spixfer (uint8_t x=0xFF)
 Low level SPI. More...
 
void writeRegister8 (uint8_t reg, uint8_t value)
 Writes 8-bits to the specified destination register. More...
 
uint8_t readRegister8 (uint8_t reg)
 Reads 8-bits from the specified register. More...
 

Detailed Description

Class that stores state and functions for interacting with Adafruit_LIS3DH.

Constructor & Destructor Documentation

◆ Adafruit_CPlay_LIS3DH() [1/3]

Adafruit_CPlay_LIS3DH::Adafruit_CPlay_LIS3DH ( TwoWire *  Wi = &Wire)

Instantiates a new LIS3DH class in I2C.

Parameters
Wioptional wire object

◆ Adafruit_CPlay_LIS3DH() [2/3]

Adafruit_CPlay_LIS3DH::Adafruit_CPlay_LIS3DH ( int8_t  cspin,
SPIClass *  theSPI = &SPI 
)

Instantiates a new LIS3DH class using hardware SPI.

Parameters
cspinnumber of CSPIN (Chip Select)
*theSPIoptional parameter contains spi object

◆ Adafruit_CPlay_LIS3DH() [3/3]

Adafruit_CPlay_LIS3DH::Adafruit_CPlay_LIS3DH ( int8_t  cspin,
int8_t  mosipin,
int8_t  misopin,
int8_t  sckpin 
)

Instantiates a new LIS3DH class using software SPI.

Parameters
cspinnumber of CSPIN (Chip Select)
mosipinnumber of pin used for MOSI (Master Out Slave In))
misopinnumber of pin used for MISO (Master In Slave Out)
sckpinnumber of pin used for CLK (clock pin)

Member Function Documentation

◆ begin()

bool Adafruit_CPlay_LIS3DH::begin ( uint8_t  i2caddr = LIS3DH_DEFAULT_ADDRESS,
uint8_t  nWAI = 0x33 
)

Setups the HW (reads coefficients values, etc.)

Parameters
i2caddri2c address (optional, fallback to default)
nWAIWho Am I register value - defaults to 0x33 (LIS3DH)
Returns
true if successful

◆ getDeviceID()

uint8_t Adafruit_CPlay_LIS3DH::getDeviceID ( )

Get Device ID from LIS3DH_REG_WHOAMI.

Returns
WHO AM I value

◆ haveNewData()

bool Adafruit_CPlay_LIS3DH::haveNewData ( )

Check to see if new data available.

Returns
true if there is new data available, false otherwise

◆ readADC()

int16_t Adafruit_CPlay_LIS3DH::readADC ( uint8_t  adc)

Read the auxilary ADC.

Parameters
adcadc index. possible values (1, 2, 3).
Returns
auxilary ADC value

◆ setRange()

void Adafruit_CPlay_LIS3DH::setRange ( lis3dh_range_t  range)

Sets the g range for the accelerometer.

Parameters
rangerange value

◆ getRange()

lis3dh_range_t Adafruit_CPlay_LIS3DH::getRange ( void  )

Gets the g range for the accelerometer.

Returns
Returns g range value

◆ setDataRate()

void Adafruit_CPlay_LIS3DH::setDataRate ( lis3dh_dataRate_t  dataRate)

Sets the data rate for the LIS3DH (controls power consumption)

Parameters
dataRatedata rate value

◆ getDataRate()

lis3dh_dataRate_t Adafruit_CPlay_LIS3DH::getDataRate ( void  )

Gets the data rate for the LIS3DH (controls power consumption)

Returns
Returns Data Rate value

◆ getEvent()

bool Adafruit_CPlay_LIS3DH::getEvent ( sensors_event_t event)
virtual

Gets the most recent sensor event.

Parameters
*eventsensor event that we want to read
Returns
true if successful

Implements Adafruit_Sensor.

◆ getSensor()

void Adafruit_CPlay_LIS3DH::getSensor ( sensor_t sensor)
virtual

Gets the sensor_t data.

Parameters
*sensorsensor that we want to write data into

Implements Adafruit_Sensor.

◆ setClick()

void Adafruit_CPlay_LIS3DH::setClick ( uint8_t  c,
uint8_t  clickthresh,
uint8_t  timelimit = 10,
uint8_t  timelatency = 20,
uint8_t  timewindow = 255 
)

Set INT to output for single or double click.

Parameters
c0 = turn off I1_CLICK 1 = turn on all axes & singletap 2 = turn on all axes & doubletap
clickthreshCLICK threshold value
timelimitsets time limit (default 10)
timelatencysets time latency (default 20)
timewindowsets time window (default 255)

◆ getClick()

uint8_t Adafruit_CPlay_LIS3DH::getClick ( void  )

Get uint8_t for single or double click.

Returns
register LIS3DH_REG_CLICKSRC

◆ spixfer()

uint8_t Adafruit_CPlay_LIS3DH::spixfer ( uint8_t  x = 0xFF)
protected

Low level SPI.

Parameters
xvalue that will be written throught SPI
Returns
reply

◆ writeRegister8()

void Adafruit_CPlay_LIS3DH::writeRegister8 ( uint8_t  reg,
uint8_t  value 
)
protected

Writes 8-bits to the specified destination register.

Parameters
regregister address
valuevalue that will be written into selected register

◆ readRegister8()

uint8_t Adafruit_CPlay_LIS3DH::readRegister8 ( uint8_t  reg)
protected

Reads 8-bits from the specified register.

Parameters
regregister address
Returns
read value

Member Data Documentation

◆ x

int16_t Adafruit_CPlay_LIS3DH::x

x axis value

◆ y

int16_t Adafruit_CPlay_LIS3DH::y

y axis value

◆ z

int16_t Adafruit_CPlay_LIS3DH::z

z axis value

◆ x_g

float Adafruit_CPlay_LIS3DH::x_g

x_g axis value (calculated by selected range)

◆ y_g

float Adafruit_CPlay_LIS3DH::y_g

y_g axis value (calculated by selected range)

◆ z_g

float Adafruit_CPlay_LIS3DH::z_g

z_g axis value (calculated by selected scale)


The documentation for this class was generated from the following files: