Skip to main content

Class PwmLed

Represents an LED whose voltage is limited by the duty-cycle of a PWM signal.

Assembly: Meadow.Foundation.dll
View Source
Declaration
public class PwmLed : IPwmLed, ILed, IDisposable

Implements:
Meadow.Peripherals.Leds.IPwmLed, 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; }

Port

Gets the PwmPort

View Source
Declaration
protected IPwmPort Port { get; set; }

ForwardVoltage

Gets the forward voltage value

View Source
Declaration
public Voltage ForwardVoltage { get; protected set; }

Brightness

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

View Source
Declaration
public float Brightness { 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(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(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, float lowBrightness)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
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 highBrightnessDuration, TimeSpan lowBrightnessDuration, float highBrightness = 1, float lowBrightness = 0)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
System.TimeSpanhighBrightnessDurationThe duration the LED stays in high brightness
System.TimeSpanlowBrightnessDurationThe duration the LED stays in low brightness
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(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)

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

View Source
Declaration
protected void ValidateForwardVoltages(Voltage forwardVoltage)
Parameters
TypeNameDescription
Meadow.Units.VoltageforwardVoltageThe forward voltage for the LED

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

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
protected virtual void Dispose(bool disposing)
Parameters
TypeNameDescription
System.BooleandisposingIs disposing

Implements

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