SensESP 3.0.1
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>
Public Member Functions | |
RgbLed (int led_r_pin=-1, int led_g_pin=-1, int led_b_pin=-1, String config_path="", long int led_on_rgb=0x00FF00, long int led_off_rgb=0xFF0000, bool common_anode=true) | |
virtual bool | to_json (JsonObject &root) override |
virtual bool | from_json (const JsonObject &config) override |
Public Member Functions inherited from sensesp::FileSystemSaveable | |
FileSystemSaveable (const String &config_path) | |
virtual bool | load () override |
Load and populate the object from a persistent storage. | |
virtual bool | save () override |
Save the object to a persistent storage. | |
virtual bool | clear () override |
Delete the data from a persistent storage. | |
bool | find_config_file (const String &config_path, String &filename) |
Public Member Functions inherited from sensesp::Saveable | |
Saveable (const String &config_path) | |
virtual bool | refresh () |
Refresh the object. This may or may not access the persistent storage but is not expected to overwrite the object's state. | |
const String & | get_config_path () const |
Public Member Functions inherited from sensesp::Serializable |
Public Attributes | |
LambdaConsumer< long > | rgb_consumer_ |
LambdaConsumer< bool > | on_off_consumer_ |
Protected Member Functions | |
void | set_color (long new_value) |
Protected Attributes | |
std::shared_ptr< PWMOutput > | led_r_output_ = nullptr |
std::shared_ptr< PWMOutput > | led_g_output_ = nullptr |
std::shared_ptr< PWMOutput > | led_b_output_ = nullptr |
long | led_on_rgb_ |
long | led_off_rgb_ |
bool | common_anode_ |
Protected Attributes inherited from sensesp::Saveable | |
const String | config_path_ |
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(long), or by setting the on/off state via set(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 int | led_on_rgb = 0x00FF00, | ||
long int | 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 |
Deserializes the current object data from a JsonObject.
Reimplemented from sensesp::Serializable.
Definition at line 39 of file rgb_led.cpp.
|
protected |
Definition at line 51 of file rgb_led.cpp.
|
overridevirtual |
Serializes the current object data into a JsonObject.
Reimplemented from sensesp::Serializable.
Definition at line 33 of file rgb_led.cpp.
|
protected |
|
protected |
|
protected |
LambdaConsumer<bool> sensesp::RgbLed::on_off_consumer_ |
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.
LambdaConsumer<long> sensesp::RgbLed::rgb_consumer_ |