Loading [MathJax]/jax/input/TeX/config.js
SensESP 3.1.0
Universal Signal K sensor toolkit ESP32
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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#include "esp_arduino_version.h"
9
10namespace sensesp {
11
12constexpr int kPWMResolution = 13;
13
31class RgbLed : public FileSystemSaveable {
32 public:
52 RgbLed(int led_r_pin = -1, int led_g_pin = -1, int led_b_pin = -1,
53 String config_path = "", long int led_on_rgb = 0x00FF00,
54 long int led_off_rgb = 0xFF0000, bool common_anode = true);
55
62 LambdaConsumer<long>([this](long new_value) { set_color(new_value); });
63
70 LambdaConsumer<bool>([this](bool new_value) {
71 if (new_value) {
73 } else {
75 }
76 });
77
78 virtual bool to_json(JsonObject& root) override;
79 virtual bool from_json(const JsonObject& config) override;
80
81 protected:
82
89#if ESP_ARDUINO_VERSION_MAJOR < 3
93#endif
94
95 void set_color(long new_value);
96};
97
98const String ConfigSchema(const RgbLed& obj);
99} // namespace sensesp
100
101#endif
Provides an easy way of calling a function based on the output of any ValueProducer.
DEPRECATED. Use Android native ledcAttach and ledcWrite instead.
Definition pwm_output.h:33
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:31
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
PWMOutput pwm_output_g_
Definition rgb_led.h:91
long led_off_rgb_
Definition rgb_led.h:87
LambdaConsumer< long > rgb_consumer_
Definition rgb_led.h:61
long led_on_rgb_
Definition rgb_led.h:86
void set_color(long new_value)
Definition rgb_led.cpp:57
bool common_anode_
Definition rgb_led.h:88
virtual bool from_json(const JsonObject &config) override
Definition rgb_led.cpp:45
PWMOutput pwm_output_r_
Definition rgb_led.h:90
virtual bool to_json(JsonObject &root) override
Definition rgb_led.cpp:39
LambdaConsumer< bool > on_off_consumer_
Definition rgb_led.h:69
PWMOutput pwm_output_b_
Definition rgb_led.h:92
const String ConfigSchema(const SmartSwitchController &obj)
constexpr int kPWMResolution
Definition rgb_led.h:12