mirror of
https://github.com/esphome/esphome.git
synced 2025-03-14 06:38:17 +00:00
Added support for ESP32-H2. Since the -H2 variant does not support the gpio wakeup method the ext1 wakeup reason was added to be able to specify a distinct run duration.
This commit is contained in:
parent
31e90e5544
commit
ce978b644c
@ -157,6 +157,7 @@ CONF_TOUCH_WAKEUP = "touch_wakeup"
|
||||
CONF_DEFAULT = "default"
|
||||
CONF_GPIO_WAKEUP_REASON = "gpio_wakeup_reason"
|
||||
CONF_TOUCH_WAKEUP_REASON = "touch_wakeup_reason"
|
||||
CONF_EXT1_WAKEUP_REASON = "ext1_wakeup_reason"
|
||||
CONF_UNTIL = "until"
|
||||
|
||||
WAKEUP_CAUSES_SCHEMA = cv.Schema(
|
||||
@ -164,6 +165,7 @@ WAKEUP_CAUSES_SCHEMA = cv.Schema(
|
||||
cv.Required(CONF_DEFAULT): cv.positive_time_period_milliseconds,
|
||||
cv.Optional(CONF_TOUCH_WAKEUP_REASON): cv.positive_time_period_milliseconds,
|
||||
cv.Optional(CONF_GPIO_WAKEUP_REASON): cv.positive_time_period_milliseconds,
|
||||
cv.Optional(CONF_EXT1_WAKEUP_REASON): cv.positive_time_period_milliseconds,
|
||||
}
|
||||
)
|
||||
|
||||
@ -234,6 +236,12 @@ async def to_code(config):
|
||||
CONF_GPIO_WAKEUP_REASON, default_run_duration
|
||||
),
|
||||
),
|
||||
(
|
||||
"ext1_cause",
|
||||
run_duration_config.get(
|
||||
CONF_EXT1_WAKEUP_REASON, default_run_duration
|
||||
),
|
||||
),
|
||||
)
|
||||
cg.add(var.set_run_duration(wakeup_cause_to_run_duration))
|
||||
|
||||
|
@ -48,6 +48,8 @@ struct WakeupCauseToRunDuration {
|
||||
uint32_t touch_cause;
|
||||
// Run duration if woken up by GPIO pins.
|
||||
uint32_t gpio_cause;
|
||||
// Run duration if woken up by ext1 pins.
|
||||
uint32_t ext1_cause;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -13,6 +13,7 @@ optional<uint32_t> DeepSleepComponent::get_run_duration_() const {
|
||||
switch (wakeup_cause) {
|
||||
case ESP_SLEEP_WAKEUP_EXT0:
|
||||
case ESP_SLEEP_WAKEUP_EXT1:
|
||||
return this->wakeup_cause_to_run_duration_->ext1_cause;
|
||||
case ESP_SLEEP_WAKEUP_GPIO:
|
||||
return this->wakeup_cause_to_run_duration_->gpio_cause;
|
||||
case ESP_SLEEP_WAKEUP_TOUCHPAD:
|
||||
@ -30,7 +31,9 @@ void DeepSleepComponent::set_wakeup_pin_mode(WakeupPinMode wakeup_pin_mode) {
|
||||
|
||||
#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6)
|
||||
void DeepSleepComponent::set_ext1_wakeup(Ext1Wakeup ext1_wakeup) { this->ext1_wakeup_ = ext1_wakeup; }
|
||||
#endif
|
||||
|
||||
#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) && !defined(USE_ESP32_VARIANT_ESP32H2)
|
||||
void DeepSleepComponent::set_touch_wakeup(bool touch_wakeup) { this->touch_wakeup_ = touch_wakeup; }
|
||||
#endif
|
||||
|
||||
@ -47,6 +50,7 @@ void DeepSleepComponent::dump_config_platform_() {
|
||||
this->wakeup_cause_to_run_duration_->default_cause);
|
||||
ESP_LOGCONFIG(TAG, " Touch Wakeup Run Duration: %" PRIu32 " ms", this->wakeup_cause_to_run_duration_->touch_cause);
|
||||
ESP_LOGCONFIG(TAG, " GPIO Wakeup Run Duration: %" PRIu32 " ms", this->wakeup_cause_to_run_duration_->gpio_cause);
|
||||
ESP_LOGCONFIG(TAG, " EXT1 Wakeup Run Duration: %" PRIu32 " ms", this->wakeup_cause_to_run_duration_->ext1_cause);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +69,7 @@ bool DeepSleepComponent::prepare_to_sleep_() {
|
||||
}
|
||||
|
||||
void DeepSleepComponent::deep_sleep_() {
|
||||
#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6)
|
||||
#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) && !defined(USE_ESP32_VARIANT_ESP32H2)
|
||||
if (this->sleep_duration_.has_value())
|
||||
esp_sleep_enable_timer_wakeup(*this->sleep_duration_);
|
||||
if (this->wakeup_pin_ != nullptr) {
|
||||
@ -84,6 +88,14 @@ void DeepSleepComponent::deep_sleep_() {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
}
|
||||
#endif
|
||||
#if defined(USE_ESP32_VARIANT_ESP32H2)
|
||||
if (this->sleep_duration_.has_value())
|
||||
esp_sleep_enable_timer_wakeup(*this->sleep_duration_);
|
||||
|
||||
if (this->ext1_wakeup_.has_value()) {
|
||||
esp_sleep_enable_ext1_wakeup(this->ext1_wakeup_->mask, this->ext1_wakeup_->wakeup_mode);
|
||||
}
|
||||
#endif
|
||||
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6)
|
||||
if (this->sleep_duration_.has_value())
|
||||
esp_sleep_enable_timer_wakeup(*this->sleep_duration_);
|
||||
|
Loading…
x
Reference in New Issue
Block a user