mirror of
https://github.com/esphome/esphome.git
synced 2026-08-22 22:26:21 +00:00
[deep_sleep] Inline the trivial DeepSleepComponent setters
This commit is contained in:
@@ -43,10 +43,6 @@ void DeepSleepComponent::loop() {
|
|||||||
this->begin_sleep();
|
this->begin_sleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeepSleepComponent::set_sleep_duration(uint32_t time_ms) { this->sleep_duration_ = uint64_t(time_ms) * 1000; }
|
|
||||||
|
|
||||||
void DeepSleepComponent::set_run_duration(uint32_t time_ms) { this->run_duration_ = time_ms; }
|
|
||||||
|
|
||||||
void DeepSleepComponent::begin_sleep(bool manual) {
|
void DeepSleepComponent::begin_sleep(bool manual) {
|
||||||
if (this->prevent_ && !manual) {
|
if (this->prevent_ && !manual) {
|
||||||
this->next_enter_deep_sleep_ = true;
|
this->next_enter_deep_sleep_ = true;
|
||||||
@@ -76,8 +72,4 @@ void DeepSleepComponent::begin_sleep(bool manual) {
|
|||||||
|
|
||||||
float DeepSleepComponent::get_setup_priority() const { return setup_priority::LATE; }
|
float DeepSleepComponent::get_setup_priority() const { return setup_priority::LATE; }
|
||||||
|
|
||||||
void DeepSleepComponent::prevent_deep_sleep() { this->prevent_ = true; }
|
|
||||||
|
|
||||||
void DeepSleepComponent::allow_deep_sleep() { this->prevent_ = false; }
|
|
||||||
|
|
||||||
} // namespace esphome::deep_sleep
|
} // namespace esphome::deep_sleep
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ template<typename... Ts> class PreventDeepSleepAction;
|
|||||||
class DeepSleepComponent final : public Component {
|
class DeepSleepComponent final : public Component {
|
||||||
public:
|
public:
|
||||||
/// Set the duration in ms the component should sleep once it's in deep sleep mode.
|
/// Set the duration in ms the component should sleep once it's in deep sleep mode.
|
||||||
void set_sleep_duration(uint32_t time_ms);
|
void set_sleep_duration(uint32_t time_ms) { this->sleep_duration_ = uint64_t(time_ms) * 1000; }
|
||||||
#if defined(USE_ESP32)
|
#if defined(USE_ESP32)
|
||||||
/** Set the pin to wake up to on the ESP32 once it's in deep sleep mode.
|
/** Set the pin to wake up to on the ESP32 once it's in deep sleep mode.
|
||||||
* Use the inverted property to set the wakeup level.
|
* Use the inverted property to set the wakeup level.
|
||||||
@@ -157,7 +157,7 @@ class DeepSleepComponent final : public Component {
|
|||||||
#if !defined(USE_ESP32_VARIANT_ESP32C2) && !defined(USE_ESP32_VARIANT_ESP32C3) && \
|
#if !defined(USE_ESP32_VARIANT_ESP32C2) && !defined(USE_ESP32_VARIANT_ESP32C3) && \
|
||||||
!defined(USE_ESP32_VARIANT_ESP32C5) && !defined(USE_ESP32_VARIANT_ESP32C6) && \
|
!defined(USE_ESP32_VARIANT_ESP32C5) && !defined(USE_ESP32_VARIANT_ESP32C6) && \
|
||||||
!defined(USE_ESP32_VARIANT_ESP32C61) && !defined(USE_ESP32_VARIANT_ESP32H2)
|
!defined(USE_ESP32_VARIANT_ESP32C61) && !defined(USE_ESP32_VARIANT_ESP32H2)
|
||||||
void set_touch_wakeup(bool touch_wakeup);
|
void set_touch_wakeup(bool touch_wakeup) { this->touch_wakeup_ = touch_wakeup; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set the duration in ms for how long the code should run before entering
|
// Set the duration in ms for how long the code should run before entering
|
||||||
@@ -166,7 +166,7 @@ class DeepSleepComponent final : public Component {
|
|||||||
#endif // USE_ESP32
|
#endif // USE_ESP32
|
||||||
|
|
||||||
/// Set a duration in ms for how long the code should run before entering deep sleep mode.
|
/// Set a duration in ms for how long the code should run before entering deep sleep mode.
|
||||||
void set_run_duration(uint32_t time_ms);
|
void set_run_duration(uint32_t time_ms) { this->run_duration_ = time_ms; }
|
||||||
|
|
||||||
void setup() override;
|
void setup() override;
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
@@ -176,8 +176,8 @@ class DeepSleepComponent final : public Component {
|
|||||||
/// Helper to enter deep sleep mode
|
/// Helper to enter deep sleep mode
|
||||||
void begin_sleep(bool manual = false);
|
void begin_sleep(bool manual = false);
|
||||||
|
|
||||||
void prevent_deep_sleep();
|
void prevent_deep_sleep() { this->prevent_ = true; }
|
||||||
void allow_deep_sleep();
|
void allow_deep_sleep() { this->prevent_ = false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Returns nullopt if no run duration is set. Otherwise, returns the run
|
// Returns nullopt if no run duration is set. Otherwise, returns the run
|
||||||
|
|||||||
@@ -74,12 +74,6 @@ void DeepSleepComponent::set_wakeup_pin_mode(WakeupPinMode wakeup_pin_mode) {
|
|||||||
void DeepSleepComponent::set_ext1_wakeup(Ext1Wakeup ext1_wakeup) { this->ext1_wakeup_ = ext1_wakeup; }
|
void DeepSleepComponent::set_ext1_wakeup(Ext1Wakeup ext1_wakeup) { this->ext1_wakeup_ = ext1_wakeup; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(USE_ESP32_VARIANT_ESP32C2) && !defined(USE_ESP32_VARIANT_ESP32C3) && \
|
|
||||||
!defined(USE_ESP32_VARIANT_ESP32C5) && !defined(USE_ESP32_VARIANT_ESP32C6) && \
|
|
||||||
!defined(USE_ESP32_VARIANT_ESP32C61) && !defined(USE_ESP32_VARIANT_ESP32H2)
|
|
||||||
void DeepSleepComponent::set_touch_wakeup(bool touch_wakeup) { this->touch_wakeup_ = touch_wakeup; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void DeepSleepComponent::set_run_duration(WakeupCauseToRunDuration wakeup_cause_to_run_duration) {
|
void DeepSleepComponent::set_run_duration(WakeupCauseToRunDuration wakeup_cause_to_run_duration) {
|
||||||
wakeup_cause_to_run_duration_ = wakeup_cause_to_run_duration;
|
wakeup_cause_to_run_duration_ = wakeup_cause_to_run_duration;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user