Class RgbPwmLed
Utility functions to provide blinking and pulsing for RgbPwmLed
Assembly: Meadow.Foundation.dll
View Source
public class RgbPwmLed : IRgbPwmLed, IDisposable
Implements:
Meadow.Peripherals.Leds.IRgbPwmLed
, 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
Gets or sets a value indicating whether the LED is on.
View Source
public bool IsOn { get; set; }
Color
The current LED color
View Source
public Color Color { get; protected set; }
Brightness
The brightness value assigned to the LED
View Source
public float Brightness { get; protected set; }
RedPwm
The red LED port
View Source
protected IPwmPort RedPwm { get; set; }
BluePwm
The blue LED port
View Source
protected IPwmPort BluePwm { get; set; }
GreenPwm
The green LED port
View Source
protected IPwmPort GreenPwm { get; set; }
Common
The common type (common anode or common cathode)
View Source
public CommonType Common { get; protected set; }
RedForwardVoltage
The red LED forward voltage
View Source
public Voltage RedForwardVoltage { get; protected set; }
GreenForwardVoltage
The green LED forward voltage
View Source
public Voltage GreenForwardVoltage { get; protected set; }
BlueForwardVoltage
The blue LED forward voltage
View Source
public Voltage BlueForwardVoltage { get; protected set; }
IsDisposed
Is the object disposed
View Source
public bool IsDisposed { get; }
Methods
StopAnimation()
Stops the current LED animation
View Source
public Task StopAnimation()
Returns
System.Threading.Tasks.Task
StartBlink(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
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(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
public Task StartBlink(Color color, float highBrightness = 1, float lowBrightness = 0)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
Meadow.Color | color | The LED color |
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 onDuration, TimeSpan offDuration, float highBrightness = 1, float lowBrightness = 0)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | onDuration | The duration the LED stays on |
System.TimeSpan | offDuration | The duration the LED stays off |
System.Single | highBrightness | The maximum brightness of the animation |
System.Single | lowBrightness | The 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
public Task StartBlink(Color color, TimeSpan onDuration, TimeSpan offDuration, float highBrightness = 1, float lowBrightness = 0)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
Meadow.Color | color | The LED color |
System.TimeSpan | onDuration | The duration the LED stays on |
System.TimeSpan | offDuration | The duration the LED stays off |
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 with a cycle time of 600ms
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(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
public Task StartPulse(Color color, float highBrightness = 1, float lowBrightness = 0.15)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
Meadow.Color | color | The LED color |
System.Single | highBrightness | The maximum brightness of the animation |
System.Single | lowBrightness | The 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 especified color
View Source
public Task StartPulse(Color color, TimeSpan pulseDuration, float highBrightness = 1, float lowBrightness = 0.15)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
Meadow.Color | color | The LED color |
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 |
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 duration 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, Voltage, Voltage)
Validates forward voltages to ensure they're within the range MIN_FORWARD_VOLTAGE to MAX_FORWARD_VOLTAGE
View Source
protected void ValidateForwardVoltages(Voltage redLedForwardVoltage, Voltage greenLedForwardVoltage, Voltage blueLedForwardVoltage)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Units.Voltage | redLedForwardVoltage | The forward voltage for the red LED |
Meadow.Units.Voltage | greenLedForwardVoltage | The forward voltage for the green LED |
Meadow.Units.Voltage | blueLedForwardVoltage | The forward voltage for the blue LED |
ResetPwmPorts()
Resets all PWM ports
View Source
protected void ResetPwmPorts()
SetBrightness(float)
Set the led brightness
View Source
public void SetBrightness(float brightness)
Parameters
Type | Name | Description |
---|---|---|
System.Single | brightness | Valid values are from 0 to 1, inclusive |
SetColor(Color, float)
Sets the current color of the LED
View Source
public void SetColor(Color color, float brightness = 1)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Color | color | The LED color |
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
public virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Is disposing |
Implements
Meadow.Peripherals.Leds.IRgbPwmLed
System.IDisposable