20 namespace deep_sleep {
66 void set_sleep_duration(uint32_t time_ms);
67 #if defined(USE_ESP32) 76 #if defined(USE_ESP32) 77 #if !defined(USE_ESP32_VARIANT_ESP32C3) 81 void set_touch_wakeup(
bool touch_wakeup);
90 void set_run_duration(uint32_t time_ms);
92 void setup()
override;
93 void dump_config()
override;
95 float get_loop_priority()
const override;
96 float get_setup_priority()
const override;
99 void begin_sleep(
bool manual =
false);
101 void prevent_deep_sleep();
102 void allow_deep_sleep();
118 bool next_enter_deep_sleep_{
false};
119 bool prevent_{
false};
127 TEMPLATABLE_VALUE(uint32_t, sleep_duration);
140 if (this->sleep_duration_.has_value()) {
141 this->deep_sleep_->set_sleep_duration(this->sleep_duration_.value(
x...));
145 if (this->hour_.has_value()) {
146 auto time = this->time_->now();
147 const uint32_t timestamp_now = time.timestamp;
149 bool after_time =
false;
150 if (time.hour > this->hour_) {
153 if (time.hour == this->hour_) {
154 if (time.minute > this->minute_) {
157 if (time.minute == this->minute_) {
158 if (time.second > this->second_) {
166 time.hour = *this->hour_;
167 time.minute = *this->minute_;
168 time.second = *this->second_;
169 time.recalc_timestamp_utc();
174 timestamp += 60 * 60 * 24;
178 const uint32_t ms_left = (timestamp - timestamp_now) * 1000;
179 this->deep_sleep_->set_sleep_duration(ms_left);
182 this->deep_sleep_->begin_sleep(
true);
198 void play(Ts...
x)
override { this->parent_->prevent_deep_sleep(); }
203 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.
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
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.