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_{};
72 using T =
typename C::value_type;
74 TEMPLATABLE_VALUE(
T,
value);
76 void play(Ts... x)
override { this->parent_->value() = this->
value_.value(x...); }
void on_shutdown() override
GlobalsComponent(std::array< typename std::remove_extent< T >::type, std::extent< T >::value > initial_value)
GlobalVarSetAction(C *parent)
ESPPreferences * global_preferences
RestoringGlobalsComponent(T 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.
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
GlobalsComponent(T initial_value)
float get_setup_priority() const override
void play(Ts... x) override
T & id(GlobalsComponent< T > *value)