mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/dev' into integration
This commit is contained in:
		| @@ -13,14 +13,13 @@ void PowerSupply::setup() { | ||||
|     this->request_high_power(); | ||||
| } | ||||
| void PowerSupply::dump_config() { | ||||
|   ESP_LOGCONFIG(TAG, "Power Supply:"); | ||||
|   LOG_PIN("  Pin: ", this->pin_); | ||||
|   ESP_LOGCONFIG(TAG, | ||||
|                 "Power Supply:\n" | ||||
|                 "  Time to enable: %" PRIu32 " ms\n" | ||||
|                 "  Keep on time: %.1f s", | ||||
|                 this->enable_time_, this->keep_on_time_ / 1000.0f); | ||||
|   if (this->enable_on_boot_) | ||||
|     ESP_LOGCONFIG(TAG, "  Enabled at startup: True"); | ||||
|                 "  Keep on time: %" PRIu32 " s\n" | ||||
|                 "  Enable at startup: %s", | ||||
|                 this->enable_time_, this->keep_on_time_ / 1000u, YESNO(this->enable_on_boot_)); | ||||
|   LOG_PIN("  Pin: ", this->pin_); | ||||
| } | ||||
|  | ||||
| float PowerSupply::get_setup_priority() const { return setup_priority::IO; } | ||||
| @@ -30,7 +29,7 @@ bool PowerSupply::is_enabled() const { return this->active_requests_ != 0; } | ||||
| void PowerSupply::request_high_power() { | ||||
|   if (this->active_requests_ == 0) { | ||||
|     this->cancel_timeout("power-supply-off"); | ||||
|     ESP_LOGD(TAG, "Enabling power supply."); | ||||
|     ESP_LOGV(TAG, "Enabling"); | ||||
|     this->pin_->digital_write(true); | ||||
|     delay(this->enable_time_); | ||||
|   } | ||||
| @@ -45,7 +44,7 @@ void PowerSupply::unrequest_high_power() { | ||||
|   this->active_requests_--; | ||||
|   if (this->active_requests_ == 0) { | ||||
|     this->set_timeout("power-supply-off", this->keep_on_time_, [this]() { | ||||
|       ESP_LOGD(TAG, "Disabling power supply."); | ||||
|       ESP_LOGV(TAG, "Disabling"); | ||||
|       this->pin_->digital_write(false); | ||||
|     }); | ||||
|   } | ||||
|   | ||||
| @@ -36,10 +36,10 @@ class PowerSupply : public Component { | ||||
|  | ||||
|  protected: | ||||
|   GPIOPin *pin_; | ||||
|   bool enable_on_boot_{false}; | ||||
|   uint32_t enable_time_; | ||||
|   uint32_t keep_on_time_; | ||||
|   int16_t active_requests_{0};  // use signed integer to make catching negative requests easier. | ||||
|   bool enable_on_boot_{false}; | ||||
| }; | ||||
|  | ||||
| class PowerSupplyRequester { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user