Skip to main content

Class RgbLed

Utility functions to provide blinking and pulsing for RgbLed

Assembly: Meadow.Foundation.dll
View Source
Declaration
public class RgbLed : IRgbLed, ILed, IDisposable

Implements:
Meadow.Peripherals.Leds.IRgbLed, Meadow.Peripherals.Leds.ILed, System.IDisposable

Properties

Color

The current LED color

View Source
Declaration
public RgbLedColors Color { get; protected set; }

RedPort

The red LED port

View Source
Declaration
protected IDigitalOutputPort RedPort { get; set; }

GreenPort

The green LED port

View Source
Declaration
protected IDigitalOutputPort GreenPort { get; set; }

BluePort

The blue LED port

View Source
Declaration
protected IDigitalOutputPort BluePort { get; set; }

Common

The common type (common anode or common cathode)

View Source
Declaration
public CommonType Common { get; protected set; }

IsOn

Gets or sets a value indicating whether the LED is on.

View Source
Declaration
public bool IsOn { get; set; }

IsDisposed

Is the object disposed

View Source
Declaration
public bool IsDisposed { get; }

Methods

StopAnimation()

Stops blink animation.

View Source
Declaration
public Task StopAnimation()
Returns

System.Threading.Tasks.Task

Blink animation that turns the LED on (500ms) and off (500ms)

View Source
Declaration
public Task StartBlink()
Returns

System.Threading.Tasks.Task

StartBlink(RgbLedColors)

Start the Blink animation which sets turns the LED on and off on an interval of 1 second (500ms on, 500ms off)

View Source
Declaration
public Task StartBlink(RgbLedColors color)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
Meadow.Peripherals.Leds.RgbLedColorscolorThe LED color

StartBlink(RgbLedColors, TimeSpan, TimeSpan)

Start the Blink animation which sets turns the LED on and off with the specified durations and color

View Source
Declaration
public Task StartBlink(RgbLedColors color, TimeSpan onDuration, TimeSpan offDuration)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
Meadow.Peripherals.Leds.RgbLedColorscolorThe LED color
System.TimeSpanonDurationThe duration the LED stays on
System.TimeSpanoffDurationThe duration the LED stays off

StartBlink(TimeSpan, TimeSpan)

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

View Source
Declaration
public Task StartBlink(TimeSpan onDuration, TimeSpan offDuration)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
System.TimeSpanonDuration
System.TimeSpanoffDuration

SetColor(RgbLedColors)

Sets the current color of the LED.

View Source
Declaration
public void SetColor(RgbLedColors color)
Parameters
TypeNameDescription
Meadow.Peripherals.Leds.RgbLedColorscolorThe color value

UpdateLed(bool)

Turns on LED with current color or LED off

View Source
Declaration
protected void UpdateLed(bool isOn)
Parameters
TypeNameDescription
System.BooleanisOnTrue for on, False for off

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

View Source
Declaration
public void Dispose()

Dispose(bool)

Dispose of the object

View Source
Declaration
public virtual void Dispose(bool disposing)
Parameters
TypeNameDescription
System.BooleandisposingIs disposing

Implements

  • Meadow.Peripherals.Leds.IRgbLed
  • Meadow.Peripherals.Leds.ILed
  • System.IDisposable