ESPHome  2024.11.1
lvgl_text.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <utility>
4 
9 
10 namespace esphome {
11 namespace lvgl {
12 
13 class LVGLText : public text::Text {
14  public:
15  void set_control_lambda(std::function<void(const std::string)> control_lambda) {
16  this->control_lambda_ = std::move(control_lambda);
17  if (this->initial_state_.has_value()) {
18  this->control_lambda_(this->initial_state_.value());
19  this->initial_state_.reset();
20  }
21  }
22 
23  protected:
24  void control(const std::string &value) override {
25  if (this->control_lambda_ != nullptr) {
26  this->control_lambda_(value);
27  } else {
28  this->initial_state_ = value;
29  }
30  }
31  std::function<void(const std::string)> control_lambda_{};
33 };
34 
35 } // namespace lvgl
36 } // namespace esphome
value_type const & value() const
Definition: optional.h:89
void set_control_lambda(std::function< void(const std::string)> control_lambda)
Definition: lvgl_text.h:15
optional< std::string > initial_state_
Definition: lvgl_text.h:32
bool has_value() const
Definition: optional.h:87
Base-class for all text inputs.
Definition: text.h:24
void control(const std::string &value) override
Definition: lvgl_text.h:24
std::function< void(const std::string)> control_lambda_
Definition: lvgl_text.h:31
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7