ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
lvgl_switch.h
Go to the documentation of this file.
1#pragma once
2
3#include <utility>
4
9
10namespace esphome::lvgl {
11
12class LVGLSwitch final : public switch_::Switch, public Component {
13 public:
14 LVGLSwitch(std::function<void(bool)> state_lambda) : state_lambda_(std::move(state_lambda)) {}
15
16 void setup() override { this->restore(false); }
17
18 protected:
19 void write_state(bool value) override { this->state_lambda_(value); }
20 std::function<void(bool)> state_lambda_{};
21};
22
23} // namespace esphome::lvgl
void setup() override
Definition lvgl_switch.h:16
std::function< void(bool)> state_lambda_
Definition lvgl_switch.h:20
LVGLSwitch(std::function< void(bool)> state_lambda)
Definition lvgl_switch.h:14
void write_state(bool value) override
Definition lvgl_switch.h:19
Base class for all switches.
Definition switch.h:43
void restore()
Drive the switch to the state its restore mode yields, through control(), so inversion and write_stat...
Definition switch.cpp:68
uint32_t value
Definition hal.cpp:41
STL namespace.