ESPHome
2026.6.0-dev
Loading...
Searching...
No Matches
esphome
components
lvgl
switch
lvgl_switch.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <utility>
4
5
#include "
esphome/components/switch/switch.h
"
6
#include "
esphome/core/automation.h
"
7
#include "
esphome/core/component.h
"
8
#include "
esphome/core/preferences.h
"
9
10
namespace
esphome::lvgl
{
11
12
class
LVGLSwitch
:
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->
write_state
(this->
get_initial_state_with_restore_mode
().value_or(
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
esphome::Component
Definition
component.h:145
esphome::lvgl::LVGLSwitch
Definition
lvgl_switch.h:12
esphome::lvgl::LVGLSwitch::setup
void setup() override
Definition
lvgl_switch.h:16
esphome::lvgl::LVGLSwitch::state_lambda_
std::function< void(bool)> state_lambda_
Definition
lvgl_switch.h:20
esphome::lvgl::LVGLSwitch::LVGLSwitch
LVGLSwitch(std::function< void(bool)> state_lambda)
Definition
lvgl_switch.h:14
esphome::lvgl::LVGLSwitch::write_state
void write_state(bool value) override
Definition
lvgl_switch.h:19
esphome::switch_::Switch
Base class for all switches.
Definition
switch.h:38
esphome::switch_::Switch::get_initial_state_with_restore_mode
optional< bool > get_initial_state_with_restore_mode()
Returns the initial state of the switch, after applying restore mode rules.
Definition
switch.cpp:42
component.h
automation.h
preferences.h
esphome::lvgl
Definition
lvgl_light.h:7
switch.h
Generated by
1.12.0