Class PwmLed
Represents an LED whose voltage is limited by the duty-cycle of a PWM signal.
Assembly: Meadow.Foundation.dll
View Source
public class PwmLed : IPwmLed, IDisposable
Implements:
Meadow.Peripherals.Leds.IPwmLed
, System.IDisposable
Properties
MAX_FORWARD_VOLTAGE
Maximum forward voltage (3.3 Volts)
View Source
public Voltage MAX_FORWARD_VOLTAGE { get; }
MIN_FORWARD_VOLTAGE
Minimum forward voltage (0 Volts)
View Source
public Voltage MIN_FORWARD_VOLTAGE { get; }
IsOn
Turns on LED with current color or turns it off
View Source
public bool IsOn { get; set; }
Port
Gets the PwmPort
View Source
protected IPwmPort Port { get; set; }
ForwardVoltage
Gets the forward voltage value
View Source
public Voltage ForwardVoltage { get; protected set; }
Brightness
The brightness value assigned to the LED
View Source
public float Brightness { get; protected set; }
IsDisposed
Is the object disposed
View Source
public bool IsDisposed { get; }
Methods
StopAnimation()
Stops any running animations.
View Source
public Task StopAnimation()
Returns
System.Threading.Tasks.Task
StartBlink(float, float)
Start a Blink animation which sets the brightness of the LED alternating between a low and high brightness setting.
View Source
public Task StartBlink(float highBrightness = 1, float lowBrightness = 0)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
System.Single | highBrightness | The maximum brightness of the animation |
System.Single | lowBrightness | The 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
public Task StartBlink(TimeSpan highBrightnessDuration, TimeSpan lowBrightnessDuration, float highBrightness = 1, float lowBrightness = 0)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | highBrightnessDuration | The duration the LED stays in high brightness |
System.TimeSpan | lowBrightnessDuration | The duration the LED stays in low brightness |
System.Single | highBrightness | The maximum brightness of the animation |
System.Single | lowBrightness | The 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
public Task StartPulse(float highBrightness = 1, float lowBrightness = 0.15)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
System.Single | highBrightness | The maximum brightness of the animation |
System.Single | lowBrightness | The 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
public Task StartPulse(TimeSpan pulseDuration, float highBrightness = 1, float lowBrightness = 0.15)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | pulseDuration | The pulse animation duration |
System.Single | highBrightness | The maximum brightness of the animation |
System.Single | lowBrightness | The 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
protected void ValidateBrightness(float highBrightness, float lowBrightness)
Parameters
Type | Name | Description |
---|---|---|
System.Single | highBrightness | The maximum brightness of the animation |
System.Single | lowBrightness | The 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
protected void ValidateForwardVoltages(Voltage forwardVoltage)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Units.Voltage | forwardVoltage | The forward voltage for the LED |
SetBrightness(float)
Sets the LED to a specific brightness.
View Source
public void SetBrightness(float brightness)
Parameters
Type | Name | Description |
---|---|---|
System.Single | brightness | Valid values are from 0 to 1, inclusive |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
View Source
public void Dispose()
Dispose(bool)
Dispose of the object
View Source
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Is disposing |
Implements
Meadow.Peripherals.Leds.IPwmLed
System.IDisposable