Treehopper C# API
LedFadeAnimation Class Reference

An LED fader effect More...

Public Member Functions

 LedFadeAnimation (bool usePrecisionTimer=false)
 Create a new LED fade animation More...
 
Task RunAsync (double from=0, double to=1)
 Run the animation More...
 

Properties

Led Led [get, set]
 Gets or sets the LED to fade. More...
 
double Duration [get, set]
 Gets or sets the duration of the fade, in milliseconds. More...
 

Detailed Description

An LED fader effect

To fade an LED, construct an instance of this class, then set Led to the LED you wish to fade. Set the Duration of the fade, and then call RunAsync(double, double) to actually run the fade. You can switch the fader to use a different LED at any time — there's no need to construct multiple instances of this class if only one LED needs to be faded at any given time.

The fade is performed using a linear interpolation; since Led.Brightness is linearly perceptual, this will create a linear change in brightness during the course of the fade.

Constructor & Destructor Documentation

◆ LedFadeAnimation()

LedFadeAnimation ( bool  usePrecisionTimer = false)

Create a new LED fade animation

Parameters
usePrecisionTimerWhether to use the (CPU-heavy) precision timer

Member Function Documentation

◆ RunAsync()

Task RunAsync ( double  from = 0,
double  to = 1 
)

Run the animation

Parameters
fromThe starting value
toThe finished value
Returns
An awaitable task

Property Documentation

◆ Led

Led Led
getset

Gets or sets the LED to fade.

◆ Duration

double Duration
getset

Gets or sets the duration of the fade, in milliseconds.


The documentation for this class was generated from the following file: