17 memcpy(this->
value_, initial_value.data(),
sizeof(T));
34 memcpy(this->
value_, initial_value.data(),
sizeof(T));
42 memcpy(&this->prev_value_, &this->
value_,
sizeof(T));
47 void loop()
override { store_value_(); }
51 void set_name_hash(uint32_t name_hash) { this->name_hash_ = name_hash; }
55 int diff = memcmp(&this->
value_, &this->prev_value_,
sizeof(T));
57 this->rtc_.save(&this->
value_);
58 memcpy(&this->prev_value_, &this->
value_,
sizeof(T));
64 uint32_t name_hash_{};
76 memcpy(this->
value_, initial_value.data(),
sizeof(T));
84 bool hasdata = this->rtc_.
load(&temp);
86 this->
value_.assign(temp + 1, temp[0]);
88 this->prev_value_.assign(this->
value_);
93 void loop()
override { store_value_(); }
97 void set_name_hash(uint32_t name_hash) { this->name_hash_ = name_hash; }
101 int diff = this->
value_.compare(this->prev_value_);
104 unsigned char temp[SZ];
108 int size = this->
value_.size();
111 memcpy(temp + 1, this->
value_.c_str(), size);
113 temp[0] = ((
unsigned char) size);
114 this->rtc_.save(&temp);
115 this->prev_value_.assign(this->
value_);
122 uint32_t name_hash_{};
130 using T =
typename C::value_type;
132 TEMPLATABLE_VALUE(
T,
value);
134 void play(Ts...
x)
override { this->parent_->value() = this->
value_.value(
x...); }
void on_shutdown() override
float get_setup_priority() const override
GlobalsComponent(std::array< typename std::remove_extent< T >::type, std::extent< T >::value > initial_value)
GlobalVarSetAction(C *parent)
void on_shutdown() override
ESPPreferences * global_preferences
RestoringGlobalsComponent(T initial_value)
RestoringGlobalStringComponent(std::array< typename std::remove_extent< T >::type, std::extent< T >::value > initial_value)
void set_name_hash(uint32_t name_hash)
GlobalsComponent()=default
RestoringGlobalsComponent(std::array< typename std::remove_extent< T >::type, std::extent< T >::value > initial_value)
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
RestoringGlobalStringComponent(T initial_value)
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
GlobalsComponent(T initial_value)
Implementation of SPI Controller mode.
void set_name_hash(uint32_t name_hash)
float get_setup_priority() const override
void play(Ts... x) override
T & id(GlobalsComponent< T > *value)