Files
esphome-lsm6ds/esphome/components/lvgl/text/lvgl_text.h
T
2341d510d3 [lvgl] Migrate to library v9.5.0 (#12312)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
2026-03-19 20:31:33 +13:00

34 lines
840 B
C++

#pragma once
#include "esphome/components/text/text.h"
#include "esphome/core/automation.h"
#include "esphome/core/component.h"
namespace esphome {
namespace lvgl {
class LVGLText : public text::Text {
public:
void set_control_lambda(const std::function<void(std::string)> &control_lambda) {
this->control_lambda_ = control_lambda;
if (this->initial_state_.has_value()) {
this->control_lambda_(this->initial_state_.value());
this->initial_state_.reset();
}
}
protected:
void control(const std::string &value) override {
if (this->control_lambda_ != nullptr) {
this->control_lambda_(value);
} else {
this->initial_state_ = value;
}
}
std::function<void(std::string)> control_lambda_{};
optional<std::string> initial_state_{};
};
} // namespace lvgl
} // namespace esphome