Skip to main content

Class RgbPwmLed

Utility functions to provide blinking and pulsing for RgbPwmLed

Assembly: Meadow.Foundation.dll​
View Source​
Declaration
public class RgbPwmLed : IRgbPwmLed, IPwmLed, IRgbLed, ILed, IDisposable

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

Properties​

MAX_FORWARD_VOLTAGE​

Maximum forward voltage (3.3 Volts)

View Source​
Declaration
public Voltage MAX_FORWARD_VOLTAGE { get; }

MIN_FORWARD_VOLTAGE​

Minimum forward voltage (0 Volts)

View Source​
Declaration
public Voltage MIN_FORWARD_VOLTAGE { get; }

IsOn​

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

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

Color​

The current LED color

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

Brightness​

Gets the brightness of the LED, controlled by a PWM signal

View Source​
Declaration
public float Brightness { get; protected set; }

RedPwm​

The red LED port

View Source​
Declaration
protected IPwmPort RedPwm { get; set; }

BluePwm​

The blue LED port

View Source​
Declaration
protected IPwmPort BluePwm { get; set; }

GreenPwm​

The green LED port

View Source​
Declaration
protected IPwmPort GreenPwm { get; set; }

Common​

The common type (common anode or common cathode)

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

RedForwardVoltage​

The red LED forward voltage

View Source​
Declaration
public Voltage RedForwardVoltage { get; protected set; }

GreenForwardVoltage​

The green LED forward voltage

View Source​
Declaration
public Voltage GreenForwardVoltage { get; protected set; }

BlueForwardVoltage​

The blue LED forward voltage

View Source​
Declaration
public Voltage BlueForwardVoltage { get; protected 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(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

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(float, float)​

Start a Blink animation which sets the brightness of the LED alternating between a low and high brightness setting.

View Source​
Declaration
public Task StartBlink(float highBrightness = 1, float lowBrightness = 0)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeNameDescription
System.SinglehighBrightnessThe maximum brightness of the animation
System.SinglelowBrightnessThe minimum brightness of the animation

StartBlink(Color, float, float)​

Start the Blink animation which sets the brightness of the LED alternating between a low and high brightness on an interval of 1 second (500ms on, 500ms off)

View Source​
Declaration
public Task StartBlink(Color color, float highBrightness = 1, float lowBrightness = 0)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeNameDescription
Meadow.ColorcolorThe LED color
System.SinglehighBrightnessThe maximum brightness of the animation
System.SinglelowBrightnessThe minimum brightness of the animation

StartBlink(TimeSpan, TimeSpan, float, float)​

Start the Blink animation which sets the brightness of the LED alternating between a low and high brightness setting, using the durations provided.

View Source​
Declaration
public Task StartBlink(TimeSpan onDuration, TimeSpan offDuration, float highBrightness = 1, float lowBrightness = 0)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeNameDescription
System.TimeSpanonDuration
System.TimeSpanoffDuration
System.SinglehighBrightnessThe maximum brightness of the animation
System.SinglelowBrightnessThe minimum brightness of the animation

StartBlink(Color, TimeSpan, TimeSpan, float, float)​

Start the Blink animation which sets the brightness of the LED alternating between a low and high brightness setting, using the durations provided

View Source​
Declaration
public Task StartBlink(Color color, TimeSpan onDuration, TimeSpan offDuration, float highBrightness = 1, float lowBrightness = 0)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeNameDescription
Meadow.ColorcolorThe LED color
System.TimeSpanonDurationThe duration the LED stays on
System.TimeSpanoffDurationThe duration the LED stays off
System.SinglehighBrightnessThe maximum brightness of the animation
System.SinglelowBrightnessThe minimum brightness of the animation

StartPulse(float, float)​

Start the Pulse animation which gradually alternates the brightness of the LED between a low and high brightness setting.

View Source​
Declaration
public Task StartPulse(float highBrightness = 1, float lowBrightness = 0.15)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeNameDescription
System.SinglehighBrightnessThe maximum brightness of the animation
System.SinglelowBrightnessThe minimum brightness of the animation

StartPulse(Color, float, float)​

Start the Pulse animation which gradually alternates the brightness of the LED between a low and high brightness setting with a cycle time of 600ms

View Source​
Declaration
public Task StartPulse(Color color, float highBrightness = 1, float lowBrightness = 0.15)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeNameDescription
Meadow.ColorcolorThe LED color
System.SinglehighBrightnessThe maximum brightness of the animation
System.SinglelowBrightnessThe minimum brightness of the animation

StartPulse(Color, TimeSpan, float, float)​

Start the Pulse animation which gradually alternates the brightness of the LED between a low and high brightness setting, using the duration provided and specified color

View Source​
Declaration
public Task StartPulse(Color color, TimeSpan pulseDuration, float highBrightness = 1, float lowBrightness = 0.15)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeNameDescription
Meadow.ColorcolorThe LED color
System.TimeSpanpulseDurationThe pulse animation duration
System.SinglehighBrightnessThe maximum brightness of the animation
System.SinglelowBrightnessThe minimum brightness of the animation

StartPulse(TimeSpan, float, float)​

Start the Pulse animation which gradually alternates the brightness of the LED between a low and high brightness setting, using the durations provided.

View Source​
Declaration
public Task StartPulse(TimeSpan pulseDuration, float highBrightness = 1, float lowBrightness = 0.15)
Returns​

System.Threading.Tasks.Task

Parameters​
TypeNameDescription
System.TimeSpanpulseDurationThe pulse animation duration
System.SinglehighBrightnessThe maximum brightness of the animation
System.SinglelowBrightnessThe minimum brightness of the animation

ValidateBrightness(float, float)​

Validates LED brightness to ensure they're within the range 0 (off) - 1 (full brightness)

View Source​
Declaration
protected void ValidateBrightness(float highBrightness, float lowBrightness)
Parameters​
TypeNameDescription
System.SinglehighBrightnessThe maximum brightness of the animation
System.SinglelowBrightnessThe minimum brightness of the animation

ValidateForwardVoltages(Voltage, Voltage, Voltage)​

Validates forward voltages to ensure they're within the range MIN_FORWARD_VOLTAGE to MAX_FORWARD_VOLTAGE

View Source​
Declaration
protected void ValidateForwardVoltages(Voltage redLedForwardVoltage, Voltage greenLedForwardVoltage, Voltage blueLedForwardVoltage)
Parameters​
TypeNameDescription
Meadow.Units.VoltageredLedForwardVoltageThe forward voltage for the red LED
Meadow.Units.VoltagegreenLedForwardVoltageThe forward voltage for the green LED
Meadow.Units.VoltageblueLedForwardVoltageThe forward voltage for the blue LED

ResetPwmPorts()​

Resets all PWM ports

View Source​
Declaration
protected void ResetPwmPorts()

SetBrightness(float)​

Set the led brightness

View Source​
Declaration
public void SetBrightness(float brightness)
Parameters​
TypeNameDescription
System.SinglebrightnessValid values are from 0 to 1, inclusive

SetColor(Color, float)​

Sets the current color of the LED

View Source​
Declaration
public void SetColor(Color color, float brightness = 1)
Parameters​
TypeNameDescription
Meadow.ColorcolorThe LED color
System.SinglebrightnessValid values are from 0 to 1, inclusive

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

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.IRgbPwmLed
  • Meadow.Peripherals.Leds.IPwmLed
  • Meadow.Peripherals.Leds.IRgbLed
  • Meadow.Peripherals.Leds.ILed
  • System.IDisposable