Skip to main content

Class Mcp3xxx.AnalogInputPort

Represents an Mcp3xxx analog input port

Assembly: Mcp3xxx.dll
View Source
Declaration
public class Mcp3xxx.AnalogInputPort : AnalogPortBase, IAnalogInputPort, IAnalogPort, IPort<IAnalogChannelInfo>, IDisposable, IObservable<IChangeResult<Voltage>>

Inheritance: System.Object -> Meadow.Hardware.PortBase<Meadow.Hardware.IAnalogChannelInfo> -> Meadow.Hardware.AnalogPortBase

Implements:
Meadow.Hardware.IAnalogInputPort, Meadow.Hardware.IAnalogPort, Meadow.Hardware.IPort<Meadow.Hardware.IAnalogChannelInfo>, System.IDisposable, System.IObservable<Meadow.IChangeResult<Meadow.Units.Voltage>>

Properties

Observers

Collection of event observers for the Updated event

View Source
Declaration
protected List<IObserver<IChangeResult<Voltage>>> Observers { get; set; }

IsSampling

Is the port sampling

View Source
Declaration
public bool IsSampling { get; protected set; }

Voltage

Current port voltage

View Source
Declaration
public Voltage Voltage { get; }

ReferenceVoltage

Port reference voltage

View Source
Declaration
public Voltage ReferenceVoltage { get; }

SampleCount

The sample count

View Source
Declaration
public int SampleCount { get; }

UpdateInterval

The update interval

View Source
Declaration
public TimeSpan UpdateInterval { get; }

VoltageSampleBuffer

The voltage sampling buffer

View Source
Declaration
public Voltage[] VoltageSampleBuffer { get; }

SampleInterval

The sampling interval

View Source
Declaration
public TimeSpan SampleInterval { get; }

ChannelInputType

The channel input type

View Source
Declaration
public Mcp3xxx.InputType ChannelInputType { get; protected set; }

Methods

Read()

Take a reading

View Source
Declaration
public Task<Voltage> Read()
Returns

System.Threading.Tasks.Task<Meadow.Units.Voltage>

StartUpdating(TimeSpan?)

Start updating

View Source
Declaration
public void StartUpdating(TimeSpan? updateInterval = null)
Parameters
TypeName
System.Nullable<System.TimeSpan>updateInterval

StopUpdating()

Stop updating the port

View Source
Declaration
public void StopUpdating()

RaiseChangedAndNotify(IChangeResult<Voltage>)

Raise change events for subscribers

View Source
Declaration
protected void RaiseChangedAndNotify(IChangeResult<Voltage> changeResult)
Parameters
TypeNameDescription
Meadow.IChangeResult<Meadow.Units.Voltage>changeResultThe change result with the current sensor data

Subscribe(IObserver<IChangeResult<Voltage>>)

Subscribe an observer for update events

View Source
Declaration
public IDisposable Subscribe(IObserver<IChangeResult<Voltage>> observer)
Returns

System.IDisposable

Parameters
TypeName
System.IObserver<Meadow.IChangeResult<Meadow.Units.Voltage>>observer

Events

Updated

Raised when the port voltage value changes

View Source
Declaration
public event EventHandler<IChangeResult<Voltage>> Updated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.Voltage>>

Implements

  • Meadow.Hardware.IAnalogInputPort
  • Meadow.Hardware.IAnalogPort
  • Meadow.Hardware.IPort<Meadow.Hardware.IAnalogChannelInfo>
  • System.IDisposable
  • System.IObservable<Meadow.IChangeResult<Meadow.Units.Voltage>>