Characteristic Locus
Inheritance System.Object PortBase<IAnalogChannelInfo> AnalogPortBase AnalogInputPortBase > AnalogInputPort
Implements IAnalogInputPort IAnalogPort IPort<IAnalogChannelInfo> System.IDisposable System.IObservable<FloatChangeResult>
Inherited Members AnalogInputPortBase.Changed AnalogInputPortBase.VoltageSampleBuffer AnalogInputPortBase.ReferenceVoltage AnalogInputPortBase.Voltage AnalogInputPortBase._observers AnalogInputPortBase.RaiseChangedAndNotify(FloatChangeResult) AnalogInputPortBase.Subscribe(IObserver<FloatChangeResult>) AnalogPortBase.Channel PortBase<IAnalogChannelInfo>.disposed PortBase<IAnalogChannelInfo>.Pin System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace Meadow.Hardware
Assembly Meadow.dll

Syntax

public class AnalogInputPort : AnalogInputPortBase, IAnalogInputPort, IAnalogPort, IPort<IAnalogChannelInfo>, IDisposable, IObservable<FloatChangeResult>

Constructors

View Source

AnalogInputPort(IPin, IIOController, IAnalogChannelInfo, Single)

Declaration
protected AnalogInputPort(IPin pin, IIOController ioController, IAnalogChannelInfo channel, float referenceVoltage)

Parameters

Type Name Description
IPin pin
IIOController ioController
IAnalogChannelInfo channel
System.Single referenceVoltage

Fields

View Source

_previousVoltageReading

Declaration
protected float _previousVoltageReading

Field Value

Type Description
System.Single

Properties

View Source

IOController

Declaration
protected IIOController IOController { get; }

Property Value

Type Description
IIOController
View Source

IsSampling

Gets a value indicating whether the analog input port is currently sampling the ADC. Call StartSampling() to spin up the sampling process.

Declaration
public bool IsSampling { get; protected set; }

Property Value

Type Description
System.Boolean

true if sampling; otherwise, false.

Methods

View Source

Dispose()

Declaration
public override void Dispose()

Overrides

Meadow.Hardware.PortBase<Meadow.Hardware.IAnalogChannelInfo>.Dispose()
View Source

Read(Int32, Int32)

Convenience method to get the voltage value. For frequent reads, use StartSampling() and StopSampling() in conjunction with the SampleBuffer.

Declaration
public override Task<float> Read(int sampleCount = 10, int sampleInterval = 40)

Parameters

Type Name Description
System.Int32 sampleCount

The number of sample readings to take. must be greater than 0.

System.Int32 sampleInterval

The interval, in milliseconds, between sample readings.

Returns

Type Description
System.Threading.Tasks.Task<System.Single>

The raw value between 0 and x. TODO: @Ctacke 0 and what? Int.Max?

Overrides

View Source

StartSampling(Int32, Int32, Int32)

Starts sampling the ADC and populating the sample buffer with values.

When sampling, the AnalogInputPort will take multiple readings (samples); waiting for the sampleIntervalDuration in between them, and fill the sample buffer with those values, then sleep for the duration specified in readIntervalDuration.

This method also starts the raising of events and IObservable subscribers to get notified. Use the readIntervalDuration parameter to specify how often events and notifications are raised/sent.

Declaration
public override void StartSampling(int sampleCount = 10, int sampleIntervalDuration = 40, int standbyDuration = 100)

Parameters

Type Name Description
System.Int32 sampleCount

The number of samples to take within any given reading. If 0, it will sample forever.

System.Int32 sampleIntervalDuration

The interval, in milliseconds, between sample readings.

System.Int32 standbyDuration

The time, in milliseconds, to wait between sets of sample readings. This value determines how often Changed events are raised and IObservable consumers are notified.

Overrides

View Source

StopSampling()

Spins down the process sampling the ADC. Any values in the SampleBuffer will become stale after calling this method.

Declaration
public override void StopSampling()

Overrides