Skip to main content

Class PwmLedBarGraph

Represents an LED bar graph composed on multiple PWM LEDs

Assembly: Meadow.Foundation.dll
View Source
public class PwmLedBarGraph

Properties

Count

The number of the LEDs in the bar graph

View Source
public int Count { get; }

Percentage

A value between 0 and 1 that controls the number of LEDs that are activated

View Source
public float Percentage { get; protected set; }

Fields

pwmLeds

Array to hold pwm leds for bar graph

View Source
protected PwmLed[] pwmLeds

Methods

StopAnimation()

Stops the LED bar graph when its blinking

View Source
public Task StopAnimation()
Returns

System.Threading.Tasks.Task

StopAnimation(int)

Stops the blinking animation on an individual LED

View Source
public Task StopAnimation(int index)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
System.Int32indexIndex of the LED

StartBlink(int, float, float)

Starts a blink animation on an individual LED

View Source
public Task StartBlink(int index, float highBrightness = 1, float lowBrightness = 0)
Returns

System.Threading.Tasks.Task

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

StartBlink(int, TimeSpan, TimeSpan, float, float)

Starts a blink animation on an individual LED

View Source
public Task StartBlink(int index, TimeSpan highBrightnessDuration, TimeSpan lowBrightnessDuration, float highBrightness = 1, float lowBrightness = 0)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
System.Int32indexIndex of the LED
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

StartBlink(float, float)

Start the 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
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
public Task StartBlink(TimeSpan highBrightnessDuration, TimeSpan lowBrightnessDuration, float highBrightness = 1, float lowBrightness = 0)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
System.TimeSpanhighBrightnessDurationOn duration.
System.TimeSpanlowBrightnessDurationOff duration.
System.SinglehighBrightnessHigh brightness.
System.SinglelowBrightnessLow brightness.

StartPulse(int, float, float)

Starts a pulse animation on an individual LED

View Source
public Task StartPulse(int index, float highBrightness = 1, float lowBrightness = 0.15)
Returns

System.Threading.Tasks.Task

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

StartPulse(int, TimeSpan, float, float)

Starts a pulse animation on an individual LED with the specified pulse cycle

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

System.Threading.Tasks.Task

Parameters
TypeNameDescription
System.Int32indexIndex of the LED
System.TimeSpanpulseDurationThe pulse animation duration
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
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
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
protected void ValidateBrightness(float highBrightness, float lowBrightness)
Parameters
TypeNameDescription
System.SinglehighBrightnessThe maximum brightness of the animation
System.SinglelowBrightnessThe minimum brightness of the animation

GetTopLedForPercentage()

Returns the index of the last LED turned on

View Source
public int GetTopLedForPercentage()
Returns

System.Int32

SetLed(int, bool)

Set the LED state

View Source
public Task SetLed(int index, bool isOn)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
System.Int32indexIndex of the LED
System.BooleanisOnTrue for on, False for off

SetLedBrightness(int, float)

Set the brightness of an individual LED when using PWM

View Source
public Task SetLedBrightness(int index, float brightness)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
System.Int32indexIndex of the LED
System.SinglebrightnessValid values are from 0 to 1, inclusive

SetPercentage(float)

Set the percentage of LEDs that are on starting from index 0

View Source
public Task SetPercentage(float percentage)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
System.SinglepercentagePercentage (Range from 0 - 1)

SetBrightness(float)

Set the brightness to the LED bar graph using PWM

View Source
public Task SetBrightness(float brightness)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
System.SinglebrightnessValid values are from 0 to 1, inclusive