Syntax
public abstract class Adxl3xxBase : PollingSensorBase<Acceleration3D>, ISamplingSensor<Acceleration3D>, ISamplingSensor<Acceleration3D>, IAccelerometer
Constructors
Adxl3xxBase(IPin, IPin, IPin, Int32, Nullable<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. |
System.Int32 | gravityRange | The gravity rangy |
System.Nullable<Voltage> | supplyVoltage | The supply voltage (typically 3.3V) |
Properties
Acceleration3D
The current acceration value
Declaration
public Acceleration3D? Acceleration3D { get; }
Property Value
Type | Description |
---|---|
System.Nullable<Acceleration3D> |
GravityRange
Gravity range
Declaration
protected double GravityRange { get; }
Property Value
Type | Description |
---|---|
System.Double |
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 |
XAnalogIn
The X analog input port
Declaration
protected IAnalogInputPort XAnalogIn { get; }
Property Value
Type | Description |
---|---|
IAnalogInputPort |
YAnalogIn
The Y analog input port
Declaration
protected IAnalogInputPort YAnalogIn { get; }
Property Value
Type | Description |
---|---|
IAnalogInputPort |
ZAnalogIn
The Z analog input port
Declaration
protected IAnalogInputPort ZAnalogIn { get; }
Property Value
Type | Description |
---|---|
IAnalogInputPort |
Methods
RaiseEventsAndNotify(IChangeResult<Acceleration3D>)
Raise events for subcribers and notify of value changes
Declaration
protected override void RaiseEventsAndNotify(IChangeResult<Acceleration3D> changeResult)
Parameters
Type | Name | Description |
---|---|---|
IChangeResult<Acceleration3D> | changeResult | The updated sensor data |
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>> |