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

Class that stores state and functions for LIS3DH accelerometer on the circuitPlayground board. More...

#include <Adafruit_CPlay_LIS3DH.h>

Inheritance diagram for Adafruit_CPlay_LIS3DH:
Adafruit_Sensor

Public Member Functions

 Adafruit_CPlay_LIS3DH (void)
 Instantiates a new LIS3DH class in I2C mode.
 
 Adafruit_CPlay_LIS3DH (int8_t cspin)
 Instantiates a new LIS3DH class in hardware SPI mode. More...
 
 Adafruit_CPlay_LIS3DH (int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin)
 Instantiates a new LIS3DH class in software SPI mode. More...
 
bool begin (uint8_t addr=LIS3DH_DEFAULT_ADDRESS)
 Setups the HW (reads coefficients values, etc.) More...
 
void read ()
 read x, y, and z axis data and store in class variables.
 
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)
 Sets 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)
 Sets 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 a tap reading 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
 integer axis readings
 
int16_t y
 

integer x-axis reading


 
int16_t z
 

integer y-axis reading


 
float x_g
 

integer z-axis reading

More...
 
float y_g
 

floating point G reading for x axis


 
float z_g
 

floating point G reading for y axis


 

Detailed Description

Class that stores state and functions for LIS3DH accelerometer on the circuitPlayground board.

Constructor & Destructor Documentation

◆ Adafruit_CPlay_LIS3DH() [1/2]

Adafruit_CPlay_LIS3DH::Adafruit_CPlay_LIS3DH ( int8_t  cspin)

Instantiates a new LIS3DH class in hardware SPI mode.

Parameters
cspinthe pin used as a chip select

◆ Adafruit_CPlay_LIS3DH() [2/2]

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

Instantiates a new LIS3DH class in software SPI mode.

Parameters
cspinthe pin used as a chip select
mosipinthe pin used as master-out-slave-in
misopinthe pin used as master-in-slave-out
sckpinthe pin used as SPI serial clock

Member Function Documentation

◆ begin()

bool Adafruit_CPlay_LIS3DH::begin ( uint8_t  i2caddr = LIS3DH_DEFAULT_ADDRESS)

Setups the HW (reads coefficients values, etc.)

Parameters
i2caddrthe I2C address the device can be found on. defaults to 0x18
Returns
true on success, false on any failure

◆ readADC()

int16_t Adafruit_CPlay_LIS3DH::readADC ( uint8_t  adc)

Read the auxilary ADC.

Parameters
adcthe adc number to read. Valid adc numbers are 1, 2, and 3.
Returns
the measured value

◆ setRange()

void Adafruit_CPlay_LIS3DH::setRange ( lis3dh_range_t  range)

Sets the g range for the accelerometer.

Parameters
rangethe desired range of the device. Pass LIS3DH_RANGE_2_G for highest sensitivity and lowest max/min value (+-2G), LIS3DH_RANGE_16_G for lowest sensitivity and highest max/min value (+-16G). Other acceptable values are LIS3DH_RANGE_4_G and LIS3DH_RANGE_8_G.

◆ getRange()

lis3dh_range_t Adafruit_CPlay_LIS3DH::getRange ( void  )

Sets the g range for the accelerometer.

Returns
the range reading from the sensor.

◆ setDataRate()

void Adafruit_CPlay_LIS3DH::setDataRate ( lis3dh_dataRate_t  dataRate)

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

Parameters
dataRatethe desired datarate.

◆ getDataRate()

lis3dh_dataRate_t Adafruit_CPlay_LIS3DH::getDataRate ( void  )

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

Returns
the data rate reading from the sensor.

◆ getEvent()

bool Adafruit_CPlay_LIS3DH::getEvent ( sensors_event_t event)
virtual

Gets the most recent sensor event.

Parameters
eventthe pointer to place the event reading in
Returns
none

Implements Adafruit_Sensor.

◆ getSensor()

void Adafruit_CPlay_LIS3DH::getSensor ( sensor_t sensor)
virtual

Gets the sensor_t data.

Parameters
sensorthe pointer to place sensor information 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
cthe number of taps to detect. pass 1 for single tap on all axis, 2 for double tap on all axis. Pass 0 to disable taps.
clickthreshthe threshold over which to register a tap.
timelimitOptional time limit for a tap. Defaults to 10
timelatencyOptional tap latency. defaults to 20
timewindowOptional time window. defaults to 255

◆ getClick()

uint8_t Adafruit_CPlay_LIS3DH::getClick ( void  )

get a tap reading

Returns
the tap reading

Member Data Documentation

◆ x_g

float Adafruit_CPlay_LIS3DH::x_g

integer z-axis reading

floating point axis readings


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