mirror of
https://github.com/esphome/esphome.git
synced 2025-10-31 23:21:54 +00:00
[select] Store options in flash to reduce RAM usage
This commit is contained in:
@@ -10,7 +10,7 @@ void CopySelect::setup() {
|
||||
source_->add_on_state_callback([this](const std::string &value, size_t index) { this->publish_state(value); });
|
||||
|
||||
const auto &source_options = source_->traits.get_options();
|
||||
traits.set_options({source_options.begin(), source_options.end()});
|
||||
traits.set_options(source_options);
|
||||
|
||||
if (source_->has_state())
|
||||
this->publish_state(source_->state);
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace select {
|
||||
|
||||
void SelectTraits::set_options(std::initializer_list<const char *> options) { this->options_ = options; }
|
||||
|
||||
void SelectTraits::set_options(const FixedVector<const char *> &options) { this->options_ = options; }
|
||||
|
||||
const FixedVector<const char *> &SelectTraits::get_options() const { return this->options_; }
|
||||
|
||||
} // namespace select
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace select {
|
||||
class SelectTraits {
|
||||
public:
|
||||
void set_options(std::initializer_list<const char *> options);
|
||||
void set_options(const FixedVector<const char *> &options);
|
||||
const FixedVector<const char *> &get_options() const;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user