Syntax
public abstract class Adxl3xxBase : PollingSensorBase<Acceleration3D>, IObservable<IChangeResult<Acceleration3D>>, IAccelerometer, ISamplingSensor<Acceleration3D>, ISensor<Acceleration3D>, IDisposable
Constructors
Adxl3xxBase(IPin, IPin, IPin, int, Voltage?)
Create a new Adxl3xxBase sensor object
Declaration
protected Adxl3xxBase(IPin xPin, IPin yPin, IPin zPin, int gravityRange, Voltage? supplyVoltage)
Parameters
Type | Name | Description |
---|---|---|
IPin | xPin | Analog pin connected to the X axis output from the ADXL335 sensor. |
IPin | yPin | Analog pin connected to the Y axis output from the ADXL335 sensor. |
IPin | zPin | Analog pin connected to the Z axis output from the ADXL335 sensor. |
int | gravityRange | The gravity rangy |
Voltage? | supplyVoltage | The supply voltage (typically 3.3V) |
Properties
Acceleration3D
The current acceleration value
Declaration
public Acceleration3D? Acceleration3D { get; }
Property Value
Type | Description |
---|---|
Acceleration3D? |
GravityRange
Gravity range
Declaration
protected double GravityRange { get; }
Property Value
Type | Description |
---|---|
double |
IsDisposed
Is the object disposed
Declaration
public bool IsDisposed { get; }
Property Value
Type | Description |
---|---|
bool |
SupplyVoltage
Power supply voltage applied to the sensor - this will be set (in the constructor) to 3.3V by default
Declaration
protected Voltage SupplyVoltage { get; }
Property Value
Type | Description |
---|---|
Voltage |
XAnalogInputPort
The X analog input port
Declaration
protected IAnalogInputPort XAnalogInputPort { get; }
Property Value
Type | Description |
---|---|
IAnalogInputPort |
YAnalogInputPort
The Y analog input port
Declaration
protected IAnalogInputPort YAnalogInputPort { get; }
Property Value
Type | Description |
---|---|
IAnalogInputPort |
ZAnalogInputPort
The Z analog input port
Declaration
protected IAnalogInputPort ZAnalogInputPort { get; }
Property Value
Type | Description |
---|---|
IAnalogInputPort |
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Dispose(bool)
Dispose of the object
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | Is disposing |
RaiseEventsAndNotify(IChangeResult<Acceleration3D>)
Raise events for subscribers and notify of value changes
Declaration
protected override void RaiseEventsAndNotify(IChangeResult<Acceleration3D> changeResult)
Parameters
Type | Name | Description |
---|---|---|
IChangeResult<Acceleration3D> | changeResult | The updated sensor data |
Overrides
ReadSensor()
Reads data from the sensor
Declaration
protected override Task<Acceleration3D> ReadSensor()
Returns
Type | Description |
---|---|
Task<Acceleration3D> | The latest sensor reading |
Overrides
VoltageToGravity(Voltage)
Convert voltage to gravity
Declaration
protected Acceleration VoltageToGravity(Voltage voltage)
Parameters
Type | Name | Description |
---|---|---|
Voltage | voltage | The voltage to convert |
Returns
Type | Description |
---|---|
Acceleration | Acceleration value |
Events
Acceleration3DUpdated
Raised when the acceleration value changes
Declaration
public event EventHandler<IChangeResult<Acceleration3D>> Acceleration3DUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Acceleration3D>> |