mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	simplify
This commit is contained in:
		| @@ -48,7 +48,7 @@ void DeepSleepComponent::begin_sleep(bool manual) { | |||||||
|  |  | ||||||
|   if (this->prevent_ && !manual) { |   if (this->prevent_ && !manual) { | ||||||
|     // Sleep was prevented |     // Sleep was prevented | ||||||
|     this->sleep_state_ = SLEEP_STATE_BLOCKED; |     this->sleep_state_ = SLEEP_STATE_BLOCKED_BY_PREVENT; | ||||||
|     ESP_LOGD(TAG, "Deep sleep blocked by prevent flag"); |     ESP_LOGD(TAG, "Deep sleep blocked by prevent flag"); | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
| @@ -79,8 +79,8 @@ void DeepSleepComponent::prevent_deep_sleep() { this->prevent_ = true; } | |||||||
|  |  | ||||||
| void DeepSleepComponent::allow_deep_sleep() { | void DeepSleepComponent::allow_deep_sleep() { | ||||||
|   this->prevent_ = false; |   this->prevent_ = false; | ||||||
|   // If sleep was blocked, try to sleep now |   // If sleep was blocked by prevent flag, try to sleep now | ||||||
|   if (this->sleep_state_ == SLEEP_STATE_BLOCKED) { |   if (this->sleep_state_ == SLEEP_STATE_BLOCKED_BY_PREVENT) { | ||||||
|     ESP_LOGD(TAG, "Deep sleep allowed, executing deferred sleep"); |     ESP_LOGD(TAG, "Deep sleep allowed, executing deferred sleep"); | ||||||
|     this->sleep_state_ = SLEEP_STATE_IDLE; |     this->sleep_state_ = SLEEP_STATE_IDLE; | ||||||
|     // Schedule sleep for next loop iteration to avoid potential issues |     // Schedule sleep for next loop iteration to avoid potential issues | ||||||
|   | |||||||
| @@ -124,7 +124,8 @@ class DeepSleepComponent : public Component { | |||||||
| #endif | #endif | ||||||
|   enum SleepState : uint8_t { |   enum SleepState : uint8_t { | ||||||
|     SLEEP_STATE_IDLE, |     SLEEP_STATE_IDLE, | ||||||
|     SLEEP_STATE_BLOCKED, |     SLEEP_STATE_BLOCKED_BY_PREVENT, | ||||||
|  |     SLEEP_STATE_BLOCKED_BY_WAKEUP_PIN, | ||||||
|     SLEEP_STATE_ENTERING_SLEEP, |     SLEEP_STATE_ENTERING_SLEEP, | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -59,8 +59,8 @@ bool DeepSleepComponent::prepare_to_sleep_() { | |||||||
|   if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_KEEP_AWAKE && this->wakeup_pin_ != nullptr && |   if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_KEEP_AWAKE && this->wakeup_pin_ != nullptr && | ||||||
|       this->wakeup_pin_->digital_read()) { |       this->wakeup_pin_->digital_read()) { | ||||||
|     // Defer deep sleep until inactive |     // Defer deep sleep until inactive | ||||||
|     if (this->sleep_state_ != SLEEP_STATE_BLOCKED) { |     if (this->sleep_state_ != SLEEP_STATE_BLOCKED_BY_WAKEUP_PIN) { | ||||||
|       this->sleep_state_ = SLEEP_STATE_BLOCKED; |       this->sleep_state_ = SLEEP_STATE_BLOCKED_BY_WAKEUP_PIN; | ||||||
|       this->status_set_warning(); |       this->status_set_warning(); | ||||||
|       ESP_LOGW(TAG, "Waiting for wakeup pin state change"); |       ESP_LOGW(TAG, "Waiting for wakeup pin state change"); | ||||||
|       // Set up monitoring - check pin state every 100ms |       // Set up monitoring - check pin state every 100ms | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user