Treehopper C# API
Adxl345 Class Reference

Analog Devices ADXL345 three-axis accelerometer More...

Inheritance diagram for Adxl345:
AccelerometerBase IAccelerometer IPollable

Classes

class  Adxl345Registers
 

Public Member Functions

 Adxl345 (I2C i2c, bool altAddressPin=false, int rate=100)
 Construct a new Analog Devices ADXL345. More...
 
override async Task UpdateAsync ()
 Requests a reading from the sensor and updates its data properties with the gathered values. More...
 

Static Public Member Functions

static async Task< IList< Adxl345 > > ProbeAsync (I2C i2c, int rate=100)
 

Protected Member Functions

void RaisePropertyChanged (object sender)
 
void RaisePropertyChanged (object sender, string property)
 

Protected Attributes

Vector3 _accelerometer
 

Properties

Vector3 Accelerometer [get]
 Gets a vector with the three-dimensional acceleration data, in g. More...
 
bool AutoUpdateWhenPropertyRead = true [get, set]
 Gets or sets whether reading from the sensor's properties should request updates from the sensor automatically (defaults to true). More...
 

Events

PropertyChangedEventHandler PropertyChanged
 

Detailed Description

Analog Devices ADXL345 three-axis accelerometer

Constructor & Destructor Documentation

◆ Adxl345()

Adxl345 ( I2C  i2c,
bool  altAddressPin = false,
int  rate = 100 
)

Construct a new Analog Devices ADXL345.

Parameters
i2cThe I2C bus to use.
altAddressPinThe state of the address pin.
rateThe rate, in kHz, to use.

Member Function Documentation

◆ ProbeAsync()

static async Task<IList<Adxl345> > ProbeAsync ( I2C  i2c,
int  rate = 100 
)
static

◆ UpdateAsync()

override async Task UpdateAsync ( )
virtual

Requests a reading from the sensor and updates its data properties with the gathered values.

Returns
An awaitable Task

Note that when AutoUpdateWhenPropertyRead is true (which it is, by default), this method is implicitly called when any sensor data property is read from — there's no need to call this method unless you set AutoUpdateWhenPropertyRead to false.

Unless otherwise noted, this method updates all sensor data simultaneously, which can often lead to more efficient bus usage (as well as reducing USB chattiness).

Implements AccelerometerBase.

◆ RaisePropertyChanged() [1/2]

void RaisePropertyChanged ( object  sender)
protectedinherited

◆ RaisePropertyChanged() [2/2]

void RaisePropertyChanged ( object  sender,
string  property 
)
protectedinherited

Member Data Documentation

◆ _accelerometer

Vector3 _accelerometer
protectedinherited

Property Documentation

◆ Accelerometer

Vector3 Accelerometer
getinherited

Gets a vector with the three-dimensional acceleration data, in g.

\(1\, \text{g} = 9.8\, \text{m}/\text{s}^2\)

◆ AutoUpdateWhenPropertyRead

bool AutoUpdateWhenPropertyRead = true
getsetinherited

Gets or sets whether reading from the sensor's properties should request updates from the sensor automatically (defaults to true).

By default, whenever you access one of the properties of this sensor, a new reading will be fetched. If this property is set to false, you must manually call the UpdateAsync() method to retrieve a new sensor reading.

Event Documentation

◆ PropertyChanged

PropertyChangedEventHandler PropertyChanged
inherited

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