LedRgb
Usage
erbui
module Example {
control sync_led LedRgb { // 1.
position 19.2mm, 111mm // 2.
style rgb // 3.
label "SYNC" // 4.
pins Pin1, Pin2, Pin3 // 5.
}
}
Creates a LED with name
sync_led
,Sets the control position on the front panel,
Sets the optional style of the control,
Sets the optional label for the control, using its default theme positioning,
Sets the optional physical board pins to use:
First pin denotes the red pin,
Second pin denotes the green pin,
Third pin denotes the blue pin. If not set, the system will choose them automatically.
c++
LedRgb
is a type that abstracts a physical LED.
struct Example
{
ExampleUi ui;
void process () {
if (ui.sync_gate.triggered ()) {
ui.sync_led.pulse (ColorRgb::yellow ()); // 1.
}
}
}
Pulses the led with a yellow color when the associated gate is triggered.
erbui
Control Reference
control
definition
control <name> LedRgb { ... }
Where <name>
is the name of the control.
More details can be found in control
documentation.
position
property
position <x>, <y>
Sets the position of the control, where the axis origin is the top-left corner.
The x
axis is oriented from left to right, and the y
axis is oriented from top to bottom.
The position component values are expressed with their unit, either mm
or hp
.
Example:
position 2hp, 15mm
More details can be found in position
documentation.
style
optional property
style <keywords>
Where <keywords>
can only be (for now):
3mm, rgb
(this is the default if not specified).
More details can be found in style
documentation.
label
optional property
label "<text>"
Where <text>
is the text displayed.
More details can be found in label
documentation.
c++
Member Functions Synopsys
Name |
Synopsys |
---|---|
|
Sets the |
|
Turns the |
|
Turns the |
|
Shortly pulses the |
|
Shortly pulses the |
|
Shortly pulses the |
|
Makes the |
c++
Member Functions
set_brightness
void set_brightness (float brightness);
Sets the maximum brightness the LedRgb
can deliver.
Warning: When using a non-PWM drived pin, any brightness value below 1 won’t allow the LED to turn on.
on
void on (ColorRgb color);
Turns the LedRgb
on with color
. The Color
structure has two fields, one r
representing
the amount of red in the color, one g
representing the amount green in the color, and one
b
representing the amount of blue in the color.
Alternatively, one of the convenient color factory functions can be used:
ColorRgb::none
which represents the absence of color (ie. the LED is off),ColorRgb::red
which represents a red color,ColorRgb::green
which represents a green color,ColorRgb::blue
which represents a blue color.
The color space is unspecified and depends on the physical LED used. Please refer to the LED datasheet for spectrum informations.
Warning: When using a non-PWM drived pin, any brightness value below 1 won’t allow the LED to turn on.
void process ()
{
ui.sync_led.on ({1.f, 0.f, 0.f}); // 1.
ui.sync_led.on (ColorRgb::yellow ()); // 2.
}
Sets the LED to a red color,
Sets the LED to a yellow color.
pulse
void pulse (ColorRgb color, std::chrono::milliseconds duration = 100ms, TransitionFunction transition_function = step);
Pulses the LedRgb
to color
, for duration
time using brightness decay transition_function
.
Warning: When using a non-PWM drived pin, any brightness value below 1 won’t allow the LED to turn on.
transition_function
is one of:
erb::step
: which makes abrupt changes of brightness after the specified duration, this is the default,erb::inverse_step
: which makes abrupt changes of brightness immediatly but runs the specified duration,erb::linear
: which makes linear perceptual changes of brightness,erb::ease_in
: which reaches full brightness late,erb::ease_out
: which reaches full brightness early,erb::ease_in_out
: which produces a breathing effect.
The pulse time can be changed, as shown below in the example:
#include <chrono>
void process ()
{
using namespace std::chrono_literals; // 1.
if (dsp.sync_triggered ()) {
ui.sync_led.pulse (ColorRgb::red (), 500ms); // 2.
}
}
Adds
chrono
duration literals to the current scope,Pulses the
led
for 500ms.
pulse_twice
void pulse_twice (ColorRgb color, std::chrono::milliseconds duration = 400ms, TransitionFunction transition_function = step);
Pulses the LedRgb
to color
twice, for total duration
time using brightness decay transition_function
.
Warning: When using a non-PWM drived pin, any brightness value below 1 won’t allow the LED to turn on.
See transition_function
possible values in pulse
reference above.
The pulse time can be changed, as shown below in the example:
#include <chrono>
void process ()
{
using namespace std::chrono_literals; // 1.
if (dsp.sync_triggered ()) {
ui.sync_led.pulse_twice (ColorRgb::red (), 2s); // 2.
}
}
Adds
chrono
duration literals to the current scope,Pulses the
led
twice for a total duration of 2 seconds.
pulse_thrice
void pulse_thrice (ColorRgb color, std::chrono::milliseconds duration = 700ms, TransitionFunction transition_function = step);
Pulses the LedRgb
to color
3 times, for total duration
time using brightness decay transition_function
.
Warning: When using a non-PWM drived pin, any brightness value below 1 won’t allow the LED to turn on.
See transition_function
possible values in pulse
reference above.
The pulse time can be changed, as shown below in the example:
#include <chrono>
void process ()
{
using namespace std::chrono_literals; // 1.
if (dsp.sync_triggered ()) {
ui.sync_led.pulse_thrice (ColorRgb::red (), 2s); // 2.
}
}
Adds
chrono
duration literals to the current scope,Pulses the
led
3 times for a total duration of 2 seconds.
blink
void blink (ColorRgb color, std::chrono::milliseconds period = 800ms, TransitionFunction transition_function = step);
Blinks the LedRgb
every period
time with color
, 800ms by default.
Warning: When using a non-PWM drived pin, any brightness value below 1 won’t allow the LED to turn on.
period
represents the total cycle on-off time.
The blink time can be changed, as shown below in the example:
#include <chrono>
void process ()
{
using namespace std::chrono_literals; // 1.
if (dsp.sync_triggered ()) {
ui.sync_led.blink (ColorRgb::red (), 200ms); // 2.
}
}
Adds
chrono
duration literals to the current scope,Blinks the
led
for a very fast 200ms period, or 5 times per second.