SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
|
A special device object that can be used to control a multi-channel color rgb LED light using up to 3 digital output channels. A "color" is defined using the standard 24 bit color depth numbers composed of three 8 bit channels for Red, Green, and Blue (see https://techterms.com/definition/rgb) More...
#include <sensesp/system/rgb_led.h>
Protected Attributes | |
int | led_r_channel_ |
int | led_g_channel_ |
int | led_b_channel_ |
long | led_on_rgb_ |
long | led_off_rgb_ |
bool | common_anode_ |
Protected Attributes inherited from sensesp::Configurable | |
String | description_ = "" |
int | sort_order_ = 1000 |
Additional Inherited Members | |
Public Attributes inherited from sensesp::Configurable | |
const String | config_path_ |
Protected Member Functions inherited from sensesp::Configurable | |
virtual void | load_configuration () |
A special device object that can be used to control a multi-channel color rgb LED light using up to 3 digital output channels. A "color" is defined using the standard 24 bit color depth numbers composed of three 8 bit channels for Red, Green, and Blue (see https://techterms.com/definition/rgb)
Color LEDs can be controlled by either setting the specific color to be displayed via the set_input(long), or by setting the on/off state via set_input(bool). When specifying a simple on/off via the the bool input, the default ON or OFF colors specified in the constructor are used.
You do not have to define all three channels (for example, if you are short on output pins, or if you happen to be using a two channel color led). Specify -1 for any pin for that channel to be ignored. The color values used still have to adhere to the 24 bit color definition however.
sensesp::RgbLed::RgbLed | ( | int | led_r_pin = -1 , |
int | led_g_pin = -1 , |
||
int | led_b_pin = -1 , |
||
String | config_path = "" , |
||
long | led_on_rgb = 0x00FF00 , |
||
long | led_off_rgb = 0xFF0000 , |
||
bool | common_anode = true |
||
) |
The constructor
led_r_pin | the digital output pin that controls the red element of an RGB LED. Specify -1 if there is no red channel connected. |
led_g_pin | the digital output pin that controls the green element of an RGB LED. Specify -1 if there is no green channel connected. |
led_b_pin | the digital output pin that controls the blue element of an RGB LED. Specify -1 if there is no blue channel connected. |
config_path | The configuration path to use to load and save the user configurable values of this device. Use BLANK if this device can not have user configurable values. |
led_on_rgb | The RGB color to use when the switch is in the "on" state. The default value is 0x00FF00, which is RGB for "green" |
led_off_rgb | The RGB color to use when the switch is in the "off" state. The default value is 0xFF0000, which is RGB red |
common_anode | TRUE if the led being used is a common_anode version (which inverts the PWM signal to obtain the necessary color). FALSE if the led is a common cathode |
Definition at line 7 of file rgb_led.cpp.
|
overridevirtual |
Returns a configuration schema that specifies the key/value pairs that can be expected when calling get_configuration(), or are expected by set_configuration(). The schema will be in JSON Schema format
Reimplemented from sensesp::Configurable.
Definition at line 73 of file rgb_led.cpp.
|
overridevirtual |
Returns the current configuration data as a JsonObject. In general, the current state of local member variables are saved to a new object created with JsonDocument::as<JsonObject>() and returned.
Reimplemented from sensesp::Configurable.
Definition at line 60 of file rgb_led.cpp.
|
overridevirtual |
Sets the current state of local member variables using the data stored in config.
Reimplemented from sensesp::Configurable.
Definition at line 75 of file rgb_led.cpp.
Used to set the current display state of the LED with a simple on/off boolean value. Using TRUE for new_value sets the color to the ON color. Using FALSE uses the OFF color.
Reimplemented from sensesp::ValueConsumer< bool >.
Definition at line 52 of file rgb_led.cpp.
Used to set the current display state of the LED.
new_value | The RGB color to display. |
Reimplemented from sensesp::ValueConsumer< long >.
Definition at line 35 of file rgb_led.cpp.