mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	Streamline setup() logging (c, d) (#8925)
This commit is contained in:
		| @@ -7,7 +7,7 @@ namespace canbus { | |||||||
| static const char *const TAG = "canbus"; | static const char *const TAG = "canbus"; | ||||||
|  |  | ||||||
| void Canbus::setup() { | void Canbus::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up Canbus..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   if (!this->setup_internal()) { |   if (!this->setup_internal()) { | ||||||
|     ESP_LOGE(TAG, "setup error!"); |     ESP_LOGE(TAG, "setup error!"); | ||||||
|     this->mark_failed(); |     this->mark_failed(); | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ namespace cap1188 { | |||||||
| static const char *const TAG = "cap1188"; | static const char *const TAG = "cap1188"; | ||||||
|  |  | ||||||
| void CAP1188Component::setup() { | void CAP1188Component::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up CAP1188..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|  |  | ||||||
|   // Reset device using the reset pin |   // Reset device using the reset pin | ||||||
|   if (this->reset_pin_ != nullptr) { |   if (this->reset_pin_ != nullptr) { | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ static const char *const TAG = "cd74hc4067"; | |||||||
| float CD74HC4067Component::get_setup_priority() const { return setup_priority::DATA; } | float CD74HC4067Component::get_setup_priority() const { return setup_priority::DATA; } | ||||||
|  |  | ||||||
| void CD74HC4067Component::setup() { | void CD74HC4067Component::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up CD74HC4067..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|  |  | ||||||
|   this->pin_s0_->setup(); |   this->pin_s0_->setup(); | ||||||
|   this->pin_s1_->setup(); |   this->pin_s1_->setup(); | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ static const uint8_t CH422G_REG_OUT_UPPER = 0x23;    // write reg for output bit | |||||||
| static const char *const TAG = "ch422g"; | static const char *const TAG = "ch422g"; | ||||||
|  |  | ||||||
| void CH422GComponent::setup() { | void CH422GComponent::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up CH422G..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   // set outputs before mode |   // set outputs before mode | ||||||
|   this->write_outputs_(); |   this->write_outputs_(); | ||||||
|   // Set mode and check for errors |   // Set mode and check for errors | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ namespace esphome { | |||||||
| namespace chsc6x { | namespace chsc6x { | ||||||
|  |  | ||||||
| void CHSC6XTouchscreen::setup() { | void CHSC6XTouchscreen::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up CHSC6X Touchscreen..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   if (this->interrupt_pin_ != nullptr) { |   if (this->interrupt_pin_ != nullptr) { | ||||||
|     this->interrupt_pin_->setup(); |     this->interrupt_pin_->setup(); | ||||||
|     this->attach_interrupt_(this->interrupt_pin_, gpio::INTERRUPT_FALLING_EDGE); |     this->attach_interrupt_(this->interrupt_pin_, gpio::INTERRUPT_FALLING_EDGE); | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ uint8_t cm1106_checksum(const uint8_t *response, size_t len) { | |||||||
| } | } | ||||||
|  |  | ||||||
| void CM1106Component::setup() { | void CM1106Component::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up CM1106..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   uint8_t response[8] = {0}; |   uint8_t response[8] = {0}; | ||||||
|   if (!this->cm1106_write_command_(C_M1106_CMD_GET_CO2, sizeof(C_M1106_CMD_GET_CO2), response, sizeof(response))) { |   if (!this->cm1106_write_command_(C_M1106_CMD_GET_CO2, sizeof(C_M1106_CMD_GET_CO2), response, sizeof(response))) { | ||||||
|     ESP_LOGE(TAG, "Communication with CM1106 failed!"); |     ESP_LOGE(TAG, "Communication with CM1106 failed!"); | ||||||
|   | |||||||
| @@ -52,7 +52,7 @@ bool CS5460AComponent::softreset_() { | |||||||
| } | } | ||||||
|  |  | ||||||
| void CS5460AComponent::setup() { | void CS5460AComponent::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up CS5460A..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|  |  | ||||||
|   float current_full_scale = (pga_gain_ == CS5460A_PGA_GAIN_10X) ? 0.25 : 0.10; |   float current_full_scale = (pga_gain_ == CS5460A_PGA_GAIN_10X) ? 0.25 : 0.10; | ||||||
|   float voltage_full_scale = 0.25; |   float voltage_full_scale = 0.25; | ||||||
|   | |||||||
| @@ -42,7 +42,7 @@ static const uint8_t CSE7761_CMD_ENABLE_WRITE = 0xE5;  // Enable write operation | |||||||
| enum CSE7761 { RMS_IAC, RMS_IBC, RMS_UC, POWER_PAC, POWER_PBC, POWER_SC, ENERGY_AC, ENERGY_BC }; | enum CSE7761 { RMS_IAC, RMS_IBC, RMS_UC, POWER_PAC, POWER_PBC, POWER_SC, ENERGY_AC, ENERGY_BC }; | ||||||
|  |  | ||||||
| void CSE7761Component::setup() { | void CSE7761Component::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up CSE7761..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   this->write_(CSE7761_SPECIAL_COMMAND, CSE7761_CMD_RESET); |   this->write_(CSE7761_SPECIAL_COMMAND, CSE7761_CMD_RESET); | ||||||
|   uint16_t syscon = this->read_(0x00, 2);  // Default 0x0A04 |   uint16_t syscon = this->read_(0x00, 2);  // Default 0x0A04 | ||||||
|   if ((0x0A04 == syscon) && this->chip_init_()) { |   if ((0x0A04 == syscon) && this->chip_init_()) { | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ namespace cst226 { | |||||||
| static const char *const TAG = "cst226.touchscreen"; | static const char *const TAG = "cst226.touchscreen"; | ||||||
|  |  | ||||||
| void CST226Touchscreen::setup() { | void CST226Touchscreen::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up CST226 Touchscreen..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   if (this->reset_pin_ != nullptr) { |   if (this->reset_pin_ != nullptr) { | ||||||
|     this->reset_pin_->setup(); |     this->reset_pin_->setup(); | ||||||
|     this->reset_pin_->digital_write(true); |     this->reset_pin_->digital_write(true); | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ void CST816Touchscreen::continue_setup_() { | |||||||
| } | } | ||||||
|  |  | ||||||
| void CST816Touchscreen::setup() { | void CST816Touchscreen::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up CST816 Touchscreen..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   if (this->reset_pin_ != nullptr) { |   if (this->reset_pin_ != nullptr) { | ||||||
|     this->reset_pin_->setup(); |     this->reset_pin_->setup(); | ||||||
|     this->reset_pin_->digital_write(true); |     this->reset_pin_->digital_write(true); | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ static const uint8_t DAC7678_REG_INTERNAL_REF_0 = 0x80; | |||||||
| static const uint8_t DAC7678_REG_INTERNAL_REF_1 = 0x90; | static const uint8_t DAC7678_REG_INTERNAL_REF_1 = 0x90; | ||||||
|  |  | ||||||
| void DAC7678Output::setup() { | void DAC7678Output::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up DAC7678OutputComponent..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|  |  | ||||||
|   ESP_LOGV(TAG, "Resetting device..."); |   ESP_LOGV(TAG, "Resetting device..."); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -70,7 +70,7 @@ bool DallasTemperatureSensor::read_scratch_pad_() { | |||||||
| } | } | ||||||
|  |  | ||||||
| void DallasTemperatureSensor::setup() { | void DallasTemperatureSensor::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "setting up Dallas temperature sensor..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   if (!this->check_address_()) |   if (!this->check_address_()) | ||||||
|     return; |     return; | ||||||
|   if (!this->read_scratch_pad_()) |   if (!this->read_scratch_pad_()) | ||||||
| @@ -80,7 +80,7 @@ void DallasTemperatureSensor::setup() { | |||||||
|  |  | ||||||
|   if ((this->address_ & 0xff) == DALLAS_MODEL_DS18S20) { |   if ((this->address_ & 0xff) == DALLAS_MODEL_DS18S20) { | ||||||
|     // DS18S20 doesn't support resolution. |     // DS18S20 doesn't support resolution. | ||||||
|     ESP_LOGW(TAG, "DS18S20 doesn't support setting resolution."); |     ESP_LOGW(TAG, "DS18S20 doesn't support setting resolution"); | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -125,7 +125,6 @@ bool DallasTemperatureSensor::check_scratch_pad_() { | |||||||
|             crc8(this->scratch_pad_, 8)); |             crc8(this->scratch_pad_, 8)); | ||||||
| #endif | #endif | ||||||
|   if (!chksum_validity) { |   if (!chksum_validity) { | ||||||
|     ESP_LOGW(TAG, "'%s' - Scratch pad checksum invalid!", this->get_name().c_str()); |  | ||||||
|     this->status_set_warning("scratch pad checksum invalid"); |     this->status_set_warning("scratch pad checksum invalid"); | ||||||
|     ESP_LOGD(TAG, "Scratch pad: %02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X (%02X)", this->scratch_pad_[0], |     ESP_LOGD(TAG, "Scratch pad: %02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X (%02X)", this->scratch_pad_[0], | ||||||
|              this->scratch_pad_[1], this->scratch_pad_[2], this->scratch_pad_[3], this->scratch_pad_[4], |              this->scratch_pad_[1], this->scratch_pad_[2], this->scratch_pad_[3], this->scratch_pad_[4], | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ static const char *const TAG = "deep_sleep"; | |||||||
| bool global_has_deep_sleep = false;  // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) | bool global_has_deep_sleep = false;  // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) | ||||||
|  |  | ||||||
| void DeepSleepComponent::setup() { | void DeepSleepComponent::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up Deep Sleep..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   global_has_deep_sleep = true; |   global_has_deep_sleep = true; | ||||||
|  |  | ||||||
|   const optional<uint32_t> run_duration = get_run_duration_(); |   const optional<uint32_t> run_duration = get_run_duration_(); | ||||||
| @@ -23,7 +23,7 @@ void DeepSleepComponent::setup() { | |||||||
| } | } | ||||||
|  |  | ||||||
| void DeepSleepComponent::dump_config() { | void DeepSleepComponent::dump_config() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up Deep Sleep..."); |   ESP_LOGCONFIG(TAG, "Deep sleep:"); | ||||||
|   if (this->sleep_duration_.has_value()) { |   if (this->sleep_duration_.has_value()) { | ||||||
|     uint32_t duration = *this->sleep_duration_ / 1000; |     uint32_t duration = *this->sleep_duration_ / 1000; | ||||||
|     ESP_LOGCONFIG(TAG, "  Sleep Duration: %" PRIu32 " ms", duration); |     ESP_LOGCONFIG(TAG, "  Sleep Duration: %" PRIu32 " ms", duration); | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ namespace dht { | |||||||
| static const char *const TAG = "dht"; | static const char *const TAG = "dht"; | ||||||
|  |  | ||||||
| void DHT::setup() { | void DHT::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up DHT..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   this->pin_->digital_write(true); |   this->pin_->digital_write(true); | ||||||
|   this->pin_->setup(); |   this->pin_->setup(); | ||||||
|   this->pin_->digital_write(true); |   this->pin_->digital_write(true); | ||||||
|   | |||||||
| @@ -34,7 +34,7 @@ void DHT12Component::update() { | |||||||
|   this->status_clear_warning(); |   this->status_clear_warning(); | ||||||
| } | } | ||||||
| void DHT12Component::setup() { | void DHT12Component::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up DHT12..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   uint8_t data[5]; |   uint8_t data[5]; | ||||||
|   if (!this->read_data_(data)) { |   if (!this->read_data_(data)) { | ||||||
|     this->mark_failed(); |     this->mark_failed(); | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ void DPS310Component::setup() { | |||||||
|   auto timer = DPS310_INIT_TIMEOUT; |   auto timer = DPS310_INIT_TIMEOUT; | ||||||
|   uint8_t reg = 0; |   uint8_t reg = 0; | ||||||
|  |  | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up DPS310..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   // first, reset the sensor |   // first, reset the sensor | ||||||
|   if (!this->write_byte(DPS310_REG_RESET, DPS310_CMD_RESET)) { |   if (!this->write_byte(DPS310_REG_RESET, DPS310_CMD_RESET)) { | ||||||
|     this->mark_failed(); |     this->mark_failed(); | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ namespace ds1307 { | |||||||
| static const char *const TAG = "ds1307"; | static const char *const TAG = "ds1307"; | ||||||
|  |  | ||||||
| void DS1307Component::setup() { | void DS1307Component::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up DS1307..."); |   ESP_LOGCONFIG(TAG, "Running setup"); | ||||||
|   if (!this->read_rtc_()) { |   if (!this->read_rtc_()) { | ||||||
|     this->mark_failed(); |     this->mark_failed(); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ namespace duty_cycle { | |||||||
| static const char *const TAG = "duty_cycle"; | static const char *const TAG = "duty_cycle"; | ||||||
|  |  | ||||||
| void DutyCycleSensor::setup() { | void DutyCycleSensor::setup() { | ||||||
|   ESP_LOGCONFIG(TAG, "Setting up Duty Cycle Sensor '%s'...", this->get_name().c_str()); |   ESP_LOGCONFIG(TAG, "Running setup for '%s'", this->get_name().c_str()); | ||||||
|   this->pin_->setup(); |   this->pin_->setup(); | ||||||
|   this->store_.pin = this->pin_->to_isr(); |   this->store_.pin = this->pin_->to_isr(); | ||||||
|   this->store_.last_level = this->pin_->digital_read(); |   this->store_.last_level = this->pin_->digital_read(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user