Characteristic Locus
Inheritance System.Object > Led
Namespace Meadow.Foundation.Leds
Assembly Meadow.Foundation.dll

Syntax

public class Led : ILed

Constructors

Led(IDigitalOutputController, IPin)

Creates a LED through a pin directly from the Digital IO of the board

Declaration
public Led(IDigitalOutputController device, IPin pin)

Parameters

Type Name Description
IDigitalOutputController device
IPin pin

Led(IDigitalOutputPort)

Creates a LED through a DigitalOutPutPort from an IO Expander

Declaration
public Led(IDigitalOutputPort port)

Parameters

Type Name Description
IDigitalOutputPort port

Fields

animationTask

Declaration
protected Task? animationTask

Field Value

Type Description
System.Nullable<Task>

cancellationTokenSource

Declaration
protected CancellationTokenSource? cancellationTokenSource

Field Value

Type Description
System.Nullable<CancellationTokenSource>

isOn

Declaration
protected bool isOn

Field Value

Type Description
System.Boolean

Properties

IsOn

Gets or sets a value indicating whether this Led is on.

Declaration
public bool IsOn { get; set; }

Property Value

Type Description
System.Boolean

true if is on; otherwise, false.

Port

Gets the port that is driving the LED

Declaration
public IDigitalOutputPort Port { get; protected set; }

Property Value

Type Description
IDigitalOutputPort

The port

Methods

Blink animation that turns the LED on and off based on the OnDuration and offDuration values in ms

Declaration
public void StartBlink(int onDuration = 200, int offDuration = 200)

Parameters

Type Name Description
System.Int32 onDuration
System.Int32 offDuration

Blink animation that turns the LED on and off based on the OnDuration and offDuration values in ms

Declaration
public void StartBlink(uint onDuration, uint offDuration)

Parameters

Type Name Description
System.UInt32 onDuration
System.UInt32 offDuration

StartBlinkAsync(Int32, Int32, CancellationToken)

Declaration
protected Task StartBlinkAsync(int onDuration, int offDuration, CancellationToken cancellationToken)

Parameters

Type Name Description
System.Int32 onDuration
System.Int32 offDuration
CancellationToken cancellationToken

Returns

Type Description
Task

Stop()

Stops the LED when its blinking and/or turns it off.

Declaration
public void Stop()