SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
rgb_led.h
Go to the documentation of this file.
1#ifndef SENSESP_SYSTEM_RGB_LED_H
2#define SENSESP_SYSTEM_RGB_LED_H
3
4#include "pwm_output.h"
7#include "valueconsumer.h"
8
9namespace sensesp {
10
29class RgbLed : public FileSystemSaveable {
30 public:
50 RgbLed(int led_r_pin = -1, int led_g_pin = -1, int led_b_pin = -1,
51 String config_path = "", long int led_on_rgb = 0x00FF00,
52 long int led_off_rgb = 0xFF0000, bool common_anode = true);
53
60 LambdaConsumer<long>([this](long new_value) { set_color(new_value); });
61
68 LambdaConsumer<bool>([this](bool new_value) {
69 if (new_value) {
71 } else {
73 }
74 });
75
76 virtual bool to_json(JsonObject& root) override;
77 virtual bool from_json(const JsonObject& config) override;
78
79 protected:
80 std::shared_ptr<PWMOutput> led_r_output_ = nullptr;
81 std::shared_ptr<PWMOutput> led_g_output_ = nullptr;
82 std::shared_ptr<PWMOutput> led_b_output_ = nullptr;
86
87 void set_color(long new_value);
88};
89
90const String ConfigSchema(const RgbLed& obj);
91} // namespace sensesp
92
93#endif
Provides an easy way of calling a function based on the output of any ValueProducer.
A special device object that can be used to control a multi-channel color rgb LED light using up to 3...
Definition rgb_led.h:29
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)
Definition rgb_led.cpp:7
long led_off_rgb_
Definition rgb_led.h:84
LambdaConsumer< long > rgb_consumer_
Definition rgb_led.h:59
long led_on_rgb_
Definition rgb_led.h:83
void set_color(long new_value)
Definition rgb_led.cpp:51
bool common_anode_
Definition rgb_led.h:85
std::shared_ptr< PWMOutput > led_g_output_
Definition rgb_led.h:81
virtual bool from_json(const JsonObject &config) override
Definition rgb_led.cpp:39
virtual bool to_json(JsonObject &root) override
Definition rgb_led.cpp:33
LambdaConsumer< bool > on_off_consumer_
Definition rgb_led.h:67
std::shared_ptr< PWMOutput > led_b_output_
Definition rgb_led.h:82
std::shared_ptr< PWMOutput > led_r_output_
Definition rgb_led.h:80
const String ConfigSchema(const SmartSwitchController &obj)