11 namespace deep_sleep {
13 static const char *
const TAG =
"deep_sleep";
20 esp_sleep_wakeup_cause_t wakeup_cause = esp_sleep_get_wakeup_cause();
21 switch (wakeup_cause) {
22 case ESP_SLEEP_WAKEUP_EXT0:
23 case ESP_SLEEP_WAKEUP_EXT1:
24 case ESP_SLEEP_WAKEUP_GPIO:
26 case ESP_SLEEP_WAKEUP_TOUCHPAD:
37 ESP_LOGCONFIG(TAG,
"Setting up Deep Sleep...");
38 global_has_deep_sleep =
true;
42 ESP_LOGI(TAG,
"Scheduling Deep Sleep to start in %" PRIu32
" ms", *run_duration);
45 ESP_LOGD(TAG,
"Not scheduling Deep Sleep, as no run duration is configured.");
49 ESP_LOGCONFIG(TAG,
"Setting up Deep Sleep...");
52 ESP_LOGCONFIG(TAG,
" Sleep Duration: %" PRIu32
" ms", duration);
55 ESP_LOGCONFIG(TAG,
" Run Duration: %" PRIu32
" ms", *this->
run_duration_);
62 ESP_LOGCONFIG(TAG,
" Default Wakeup Run Duration: %" PRIu32
" ms",
77 #if defined(USE_ESP32) 83 #if defined(USE_ESP32) 84 #if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) 110 ESP_LOGW(TAG,
"Waiting for pin_ to switch state to enter deep sleep...");
117 ESP_LOGI(TAG,
"Beginning Deep Sleep");
123 #if defined(USE_ESP32) 124 #if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) 135 esp_sleep_enable_ext1_wakeup(this->
ext1_wakeup_->mask, this->ext1_wakeup_->wakeup_mode);
139 esp_sleep_enable_touchpad_wakeup();
140 esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
143 #if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) 152 static_cast<esp_deepsleep_gpio_wake_up_mode_t
>(level));
155 esp_deep_sleep_start();
optional< uint32_t > get_run_duration_() const
optional< bool > touch_wakeup_
optional< WakeupCauseToRunDuration > wakeup_cause_to_run_duration_
void set_sleep_duration(uint32_t time_ms)
Set the duration in ms the component should sleep once it's in deep sleep mode.
void status_set_warning(const char *message="unspecified")
bool global_has_deep_sleep
WakeupPinMode
The values of this enum define what should be done if deep sleep is set up with a wakeup pin on the E...
void prevent_deep_sleep()
void set_ext1_wakeup(Ext1Wakeup ext1_wakeup)
optional< uint64_t > sleep_duration_
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
const float LATE
For components that should be initialized at the very end of the setup process.
bool next_enter_deep_sleep_
float get_setup_priority() const override
optional< uint32_t > run_duration_
void set_wakeup_pin_mode(WakeupPinMode wakeup_pin_mode)
optional< Ext1Wakeup > ext1_wakeup_
void run_safe_shutdown_hooks()
void set_run_duration(WakeupCauseToRunDuration wakeup_cause_to_run_duration)
void set_touch_wakeup(bool touch_wakeup)
void begin_sleep(bool manual=false)
Helper to enter deep sleep mode.
virtual uint8_t get_pin() const =0
Application App
Global storage of Application pointer - only one Application can exist.
InternalGPIOPin * wakeup_pin_
virtual bool digital_read()=0
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.
WakeupPinMode wakeup_pin_mode_
float get_loop_priority() const override
void dump_config() override
virtual bool is_inverted() const =0