20 namespace deep_sleep {
37 #if defined(USE_ESP32) && !defined(USE_ESP32_VARIANT_ESP32C3) 68 void set_sleep_duration(uint32_t time_ms);
69 #if defined(USE_ESP32) 78 #if defined(USE_ESP32) 79 #if !defined(USE_ESP32_VARIANT_ESP32C3) 83 void set_touch_wakeup(
bool touch_wakeup);
92 void set_run_duration(uint32_t time_ms);
94 void setup()
override;
95 void dump_config()
override;
97 float get_loop_priority()
const override;
98 float get_setup_priority()
const override;
101 void begin_sleep(
bool manual =
false);
103 void prevent_deep_sleep();
104 void allow_deep_sleep();
111 void dump_config_platform_();
112 bool prepare_to_sleep_();
120 #if !defined(USE_ESP32_VARIANT_ESP32C3) 128 bool next_enter_deep_sleep_{
false};
129 bool prevent_{
false};
137 TEMPLATABLE_VALUE(uint32_t, sleep_duration);
150 if (this->sleep_duration_.has_value()) {
151 this->deep_sleep_->set_sleep_duration(this->sleep_duration_.value(
x...));
155 if (this->hour_.has_value()) {
156 auto time = this->time_->now();
157 const uint32_t timestamp_now = time.timestamp;
159 bool after_time =
false;
160 if (time.hour > this->hour_) {
163 if (time.hour == this->hour_) {
164 if (time.minute > this->minute_) {
167 if (time.minute == this->minute_) {
168 if (time.second > this->second_) {
176 time.hour = *this->hour_;
177 time.minute = *this->minute_;
178 time.second = *this->second_;
179 time.recalc_timestamp_utc();
184 timestamp += 60 * 60 * 24;
188 const uint32_t ms_left = (timestamp - timestamp_now) * 1000;
189 this->deep_sleep_->set_sleep_duration(ms_left);
192 this->deep_sleep_->begin_sleep(
true);
208 void play(Ts...
x)
override { this->parent_->prevent_deep_sleep(); }
213 void play(Ts...
x)
override { this->parent_->allow_deep_sleep(); }
void play(Ts... x) override
void set_until(uint8_t hour, uint8_t minute, uint8_t second)
void play(Ts... x) override
optional< bool > touch_wakeup_
static int32_t timezone_offset()
optional< WakeupCauseToRunDuration > wakeup_cause_to_run_duration_
bool global_has_deep_sleep
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock...
WakeupPinMode
The values of this enum define what should be done if deep sleep is set up with a wakeup pin on the E...
optional< uint64_t > sleep_duration_
This component allows setting up the node to go into deep sleep mode to conserve battery.
time::RealTimeClock * time_
DeepSleepComponent * deep_sleep_
optional< uint32_t > run_duration_
optional< Ext1Wakeup > ext1_wakeup_
optional< uint8_t > minute_
Ignore the fact that we will wake up when going into deep sleep.
void play(Ts... x) override
InternalGPIOPin * wakeup_pin_
optional< uint8_t > second_
optional< uint8_t > hour_
void set_time(time::RealTimeClock *time)
EnterDeepSleepAction(DeepSleepComponent *deep_sleep)
As long as the wakeup pin is still in the wakeup state, keep awake.
Implementation of SPI Controller mode.
Automatically invert the wakeup level.
esp_sleep_ext1_wakeup_mode_t wakeup_mode
Helper class to easily give an object a parent of type T.
void set_wakeup_pin(InternalGPIOPin *pin)
Set the pin to wake up to on the ESP32 once it's in deep sleep mode.