Streamline setup() logging (g, h, i) (#8927)

This commit is contained in:
Keith Burzinski 2025-05-28 13:55:02 -05:00 committed by GitHub
parent 18653f8f69
commit 0ce03ae26b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 34 additions and 35 deletions

View File

@ -14,7 +14,7 @@ namespace gcja5 {
static const char *const TAG = "gcja5"; static const char *const TAG = "gcja5";
void GCJA5Component::setup() { ESP_LOGCONFIG(TAG, "Setting up gcja5..."); } void GCJA5Component::setup() { ESP_LOGCONFIG(TAG, "Running setup"); }
void GCJA5Component::loop() { void GCJA5Component::loop() {
const uint32_t now = App.get_loop_component_start_time(); const uint32_t now = App.get_loop_component_start_time();

View File

@ -34,7 +34,7 @@ void GDK101Component::update() {
void GDK101Component::setup() { void GDK101Component::setup() {
uint8_t data[2]; uint8_t data[2];
ESP_LOGCONFIG(TAG, "Setting up GDK101..."); ESP_LOGCONFIG(TAG, "Running setup");
// first, reset the sensor // first, reset the sensor
if (!this->reset_sensor_(data)) { if (!this->reset_sensor_(data)) {
this->status_set_error("Reset failed!"); this->status_set_error("Reset failed!");

View File

@ -8,7 +8,7 @@ namespace gpio {
static const char *const TAG = "gpio.one_wire"; static const char *const TAG = "gpio.one_wire";
void GPIOOneWireBus::setup() { void GPIOOneWireBus::setup() {
ESP_LOGCONFIG(TAG, "Setting up 1-wire bus..."); ESP_LOGCONFIG(TAG, "Running setup");
this->t_pin_->setup(); this->t_pin_->setup();
this->t_pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP); this->t_pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP);
// clear bus with 480µs high, otherwise initial reset in search might fail // clear bus with 480µs high, otherwise initial reset in search might fail

View File

@ -8,7 +8,7 @@ static const char *const TAG = "switch.gpio";
float GPIOSwitch::get_setup_priority() const { return setup_priority::HARDWARE; } float GPIOSwitch::get_setup_priority() const { return setup_priority::HARDWARE; }
void GPIOSwitch::setup() { void GPIOSwitch::setup() {
ESP_LOGCONFIG(TAG, "Setting up GPIO Switch '%s'...", this->name_.c_str()); ESP_LOGCONFIG(TAG, "Running setup for '%s'", this->name_.c_str());
bool initial_state = this->get_initial_state_with_restore_mode().value_or(false); bool initial_state = this->get_initial_state_with_restore_mode().value_or(false);

View File

@ -33,8 +33,7 @@ bool GroveGasMultichannelV2Component::read_sensor_(uint8_t address, sensor::Sens
} }
void GroveGasMultichannelV2Component::setup() { void GroveGasMultichannelV2Component::setup() {
ESP_LOGCONFIG(TAG, "Setting up Grove Multichannel Gas Sensor V2..."); ESP_LOGCONFIG(TAG, "Running setup");
// Before reading sensor values, must preheat sensor // Before reading sensor values, must preheat sensor
if (!(this->write_bytes(GROVE_GAS_MC_V2_HEAT_ON, {}))) { if (!(this->write_bytes(GROVE_GAS_MC_V2_HEAT_ON, {}))) {
this->mark_failed(); this->mark_failed();

View File

@ -24,7 +24,7 @@ void GroveMotorDriveTB6612FNG::dump_config() {
} }
void GroveMotorDriveTB6612FNG::setup() { void GroveMotorDriveTB6612FNG::setup() {
ESP_LOGCONFIG(TAG, "Setting up Grove Motor Drive TB6612FNG ..."); ESP_LOGCONFIG(TAG, "Running setup");
if (!this->standby()) { if (!this->standby()) {
this->mark_failed(); this->mark_failed();
return; return;

View File

@ -25,7 +25,7 @@ static const size_t MAX_BUTTONS = 4; // max number of buttons scanned
void GT911Touchscreen::setup() { void GT911Touchscreen::setup() {
i2c::ErrorCode err; i2c::ErrorCode err;
ESP_LOGCONFIG(TAG, "Setting up GT911 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(false); this->reset_pin_->digital_write(false);

View File

@ -10,7 +10,7 @@ static const char *const TAG = "switch.hbridge";
float HBridgeSwitch::get_setup_priority() const { return setup_priority::HARDWARE; } float HBridgeSwitch::get_setup_priority() const { return setup_priority::HARDWARE; }
void HBridgeSwitch::setup() { void HBridgeSwitch::setup() {
ESP_LOGCONFIG(TAG, "Setting up H-Bridge Switch '%s'...", this->name_.c_str()); ESP_LOGCONFIG(TAG, "Running setup for '%s'", this->name_.c_str());
optional<bool> initial_state = this->get_initial_state_with_restore_mode(); optional<bool> initial_state = this->get_initial_state_with_restore_mode();

View File

@ -13,7 +13,7 @@ static const uint8_t HDC1080_CMD_TEMPERATURE = 0x00;
static const uint8_t HDC1080_CMD_HUMIDITY = 0x01; static const uint8_t HDC1080_CMD_HUMIDITY = 0x01;
void HDC1080Component::setup() { void HDC1080Component::setup() {
ESP_LOGCONFIG(TAG, "Setting up HDC1080..."); ESP_LOGCONFIG(TAG, "Running setup");
const uint8_t data[2] = { const uint8_t data[2] = {
0b00000000, // resolution 14bit for both humidity and temperature 0b00000000, // resolution 14bit for both humidity and temperature

View File

@ -11,7 +11,7 @@ static const uint32_t HLW8012_CLOCK_FREQUENCY = 3579000;
void HLW8012Component::setup() { void HLW8012Component::setup() {
float reference_voltage = 0; float reference_voltage = 0;
ESP_LOGCONFIG(TAG, "Setting up HLW8012..."); ESP_LOGCONFIG(TAG, "Running setup");
this->sel_pin_->setup(); this->sel_pin_->setup();
this->sel_pin_->digital_write(this->current_mode_); this->sel_pin_->digital_write(this->current_mode_);
this->cf_store_.pulse_counter_setup(this->cf_pin_); this->cf_store_.pulse_counter_setup(this->cf_pin_);

View File

@ -11,7 +11,7 @@ static const uint8_t PM_2_5_VALUE_INDEX = 6;
static const uint8_t PM_10_0_VALUE_INDEX = 7; static const uint8_t PM_10_0_VALUE_INDEX = 7;
void HM3301Component::setup() { void HM3301Component::setup() {
ESP_LOGCONFIG(TAG, "Setting up HM3301..."); ESP_LOGCONFIG(TAG, "Running setup");
if (i2c::ERROR_OK != this->write(&SELECT_COMM_CMD, 1)) { if (i2c::ERROR_OK != this->write(&SELECT_COMM_CMD, 1)) {
error_code_ = ERROR_COMM; error_code_ = ERROR_COMM;
this->mark_failed(); this->mark_failed();

View File

@ -22,7 +22,7 @@ static const uint8_t HMC5883L_REGISTER_IDENTIFICATION_B = 0x0B;
static const uint8_t HMC5883L_REGISTER_IDENTIFICATION_C = 0x0C; static const uint8_t HMC5883L_REGISTER_IDENTIFICATION_C = 0x0C;
void HMC5883LComponent::setup() { void HMC5883LComponent::setup() {
ESP_LOGCONFIG(TAG, "Setting up HMC5583L..."); ESP_LOGCONFIG(TAG, "Running setup");
uint8_t id[3]; uint8_t id[3];
if (!this->read_byte(HMC5883L_REGISTER_IDENTIFICATION_A, &id[0]) || if (!this->read_byte(HMC5883L_REGISTER_IDENTIFICATION_A, &id[0]) ||
!this->read_byte(HMC5883L_REGISTER_IDENTIFICATION_B, &id[1]) || !this->read_byte(HMC5883L_REGISTER_IDENTIFICATION_B, &id[1]) ||

View File

@ -7,7 +7,7 @@ namespace hte501 {
static const char *const TAG = "hte501"; static const char *const TAG = "hte501";
void HTE501Component::setup() { void HTE501Component::setup() {
ESP_LOGCONFIG(TAG, "Setting up HTE501..."); ESP_LOGCONFIG(TAG, "Running setup");
uint8_t address[] = {0x70, 0x29}; uint8_t address[] = {0x70, 0x29};
this->write(address, 2, false); this->write(address, 2, false);
uint8_t identification[9]; uint8_t identification[9];

View File

@ -18,7 +18,7 @@ static const uint8_t HTU21D_READHEATER_REG_CMD = 0x11; /**< Read Heater Control
static const uint8_t HTU21D_REG_HTRE_BIT = 0x02; /**< Control Register Heater Bit */ static const uint8_t HTU21D_REG_HTRE_BIT = 0x02; /**< Control Register Heater Bit */
void HTU21DComponent::setup() { void HTU21DComponent::setup() {
ESP_LOGCONFIG(TAG, "Setting up HTU21D..."); ESP_LOGCONFIG(TAG, "Running setup");
if (!this->write_bytes(HTU21D_REGISTER_RESET, nullptr, 0)) { if (!this->write_bytes(HTU21D_REGISTER_RESET, nullptr, 0)) {
this->mark_failed(); this->mark_failed();

View File

@ -75,7 +75,7 @@ uint8_t compute_crc(uint32_t value) {
* I2C. * I2C.
*/ */
void HTU31DComponent::setup() { void HTU31DComponent::setup() {
ESP_LOGCONFIG(TAG, "Setting up esphome/components/htu31d HTU31D..."); ESP_LOGCONFIG(TAG, "Running setup");
if (!this->reset_()) { if (!this->reset_()) {
this->mark_failed(); this->mark_failed();

View File

@ -8,7 +8,7 @@ namespace hx711 {
static const char *const TAG = "hx711"; static const char *const TAG = "hx711";
void HX711Sensor::setup() { void HX711Sensor::setup() {
ESP_LOGCONFIG(TAG, "Setting up HX711 '%s'...", this->name_.c_str()); ESP_LOGCONFIG(TAG, "Running setup for '%s'", this->name_.c_str());
this->sck_pin_->setup(); this->sck_pin_->setup();
this->dout_pin_->setup(); this->dout_pin_->setup();
this->sck_pin_->digital_write(false); this->sck_pin_->digital_write(false);

View File

@ -39,7 +39,7 @@ void HydreonRGxxComponent::dump_config() {
} }
void HydreonRGxxComponent::setup() { void HydreonRGxxComponent::setup() {
ESP_LOGCONFIG(TAG, "Setting up hydreon_rgxx..."); ESP_LOGCONFIG(TAG, "Running setup");
while (this->available() != 0) { while (this->available() != 0) {
this->read(); this->read();
} }

View File

@ -13,6 +13,7 @@ namespace i2c {
static const char *const TAG = "i2c.arduino"; static const char *const TAG = "i2c.arduino";
void ArduinoI2CBus::setup() { void ArduinoI2CBus::setup() {
ESP_LOGCONFIG(TAG, "Running setup");
recover_(); recover_();
#if defined(USE_ESP32) #if defined(USE_ESP32)

View File

@ -18,7 +18,7 @@ namespace i2c {
static const char *const TAG = "i2c.idf"; static const char *const TAG = "i2c.idf";
void IDFI2CBus::setup() { void IDFI2CBus::setup() {
ESP_LOGCONFIG(TAG, "Setting up I2C bus..."); ESP_LOGCONFIG(TAG, "Running setup");
static i2c_port_t next_port = I2C_NUM_0; static i2c_port_t next_port = I2C_NUM_0;
port_ = next_port; port_ = next_port;
#if SOC_HP_I2C_NUM > 1 #if SOC_HP_I2C_NUM > 1

View File

@ -14,18 +14,17 @@ static const uint8_t I2S_NUM_MAX = SOC_I2S_NUM; // because IDF 5+ took this awa
#endif #endif
void I2SAudioComponent::setup() { void I2SAudioComponent::setup() {
static i2s_port_t next_port_num = I2S_NUM_0; ESP_LOGCONFIG(TAG, "Running setup");
static i2s_port_t next_port_num = I2S_NUM_0;
if (next_port_num >= I2S_NUM_MAX) { if (next_port_num >= I2S_NUM_MAX) {
ESP_LOGE(TAG, "Too many I2S Audio components!"); ESP_LOGE(TAG, "Too many I2S Audio components");
this->mark_failed(); this->mark_failed();
return; return;
} }
this->port_ = next_port_num; this->port_ = next_port_num;
next_port_num = (i2s_port_t) (next_port_num + 1); next_port_num = (i2s_port_t) (next_port_num + 1);
ESP_LOGCONFIG(TAG, "Setting up I2S Audio...");
} }
} // namespace i2s_audio } // namespace i2s_audio

View File

@ -120,7 +120,7 @@ void I2SAudioMediaPlayer::set_volume_(float volume, bool publish) {
} }
void I2SAudioMediaPlayer::setup() { void I2SAudioMediaPlayer::setup() {
ESP_LOGCONFIG(TAG, "Setting up Audio..."); ESP_LOGCONFIG(TAG, "Running setup");
this->state = media_player::MEDIA_PLAYER_STATE_IDLE; this->state = media_player::MEDIA_PLAYER_STATE_IDLE;
} }

View File

@ -40,7 +40,7 @@ enum MicrophoneEventGroupBits : uint32_t {
}; };
void I2SAudioMicrophone::setup() { void I2SAudioMicrophone::setup() {
ESP_LOGCONFIG(TAG, "Setting up I2S Audio Microphone..."); ESP_LOGCONFIG(TAG, "Running setup");
#ifdef USE_I2S_LEGACY #ifdef USE_I2S_LEGACY
#if SOC_I2S_SUPPORTS_ADC #if SOC_I2S_SUPPORTS_ADC
if (this->adc_) { if (this->adc_) {

View File

@ -99,7 +99,7 @@ static const std::vector<int16_t> Q15_VOLUME_SCALING_FACTORS = {
19508, 20665, 21891, 23189, 24565, 26022, 27566, 29201, 30933, 32767}; 19508, 20665, 21891, 23189, 24565, 26022, 27566, 29201, 30933, 32767};
void I2SAudioSpeaker::setup() { void I2SAudioSpeaker::setup() {
ESP_LOGCONFIG(TAG, "Setting up I2S Audio Speaker..."); ESP_LOGCONFIG(TAG, "Running setup");
this->event_group_ = xEventGroupCreate(); this->event_group_ = xEventGroupCreate();

View File

@ -34,7 +34,7 @@ static const uint8_t INA219_REGISTER_CURRENT = 0x04;
static const uint8_t INA219_REGISTER_CALIBRATION = 0x05; static const uint8_t INA219_REGISTER_CALIBRATION = 0x05;
void INA219Component::setup() { void INA219Component::setup() {
ESP_LOGCONFIG(TAG, "Setting up INA219..."); ESP_LOGCONFIG(TAG, "Running setup");
// Config Register // Config Register
// 0bx000000000000000 << 15 RESET Bit (1 -> trigger reset) // 0bx000000000000000 << 15 RESET Bit (1 -> trigger reset)
if (!this->write_byte_16(INA219_REGISTER_CONFIG, 0x8000)) { if (!this->write_byte_16(INA219_REGISTER_CONFIG, 0x8000)) {

View File

@ -37,7 +37,7 @@ static const uint16_t INA226_ADC_TIMES[] = {140, 204, 332, 588, 1100, 2116, 4156
static const uint16_t INA226_ADC_AVG_SAMPLES[] = {1, 4, 16, 64, 128, 256, 512, 1024}; static const uint16_t INA226_ADC_AVG_SAMPLES[] = {1, 4, 16, 64, 128, 256, 512, 1024};
void INA226Component::setup() { void INA226Component::setup() {
ESP_LOGCONFIG(TAG, "Setting up INA226..."); ESP_LOGCONFIG(TAG, "Running setup");
ConfigurationRegister config; ConfigurationRegister config;

View File

@ -35,7 +35,7 @@ static const uint8_t INA260_REGISTER_MANUFACTURE_ID = 0xFE;
static const uint8_t INA260_REGISTER_DEVICE_ID = 0xFF; static const uint8_t INA260_REGISTER_DEVICE_ID = 0xFF;
void INA260Component::setup() { void INA260Component::setup() {
ESP_LOGCONFIG(TAG, "Setting up INA260..."); ESP_LOGCONFIG(TAG, "Running setup");
// Reset device on setup // Reset device on setup
if (!this->write_byte_16(INA260_REGISTER_CONFIG, 0x8000)) { if (!this->write_byte_16(INA260_REGISTER_CONFIG, 0x8000)) {

View File

@ -50,7 +50,7 @@ static bool check_model_and_device_match(INAModel model, uint16_t dev_id) {
} }
void INA2XX::setup() { void INA2XX::setup() {
ESP_LOGCONFIG(TAG, "Setting up INA2xx..."); ESP_LOGCONFIG(TAG, "Running setup");
if (!this->reset_config_()) { if (!this->reset_config_()) {
ESP_LOGE(TAG, "Reset failed, check connection"); ESP_LOGE(TAG, "Reset failed, check connection");

View File

@ -22,7 +22,7 @@ static const uint8_t INA3221_REGISTER_CHANNEL3_BUS_VOLTAGE = 0x06;
// A0 = SCL -> 0x43 // A0 = SCL -> 0x43
void INA3221Component::setup() { void INA3221Component::setup() {
ESP_LOGCONFIG(TAG, "Setting up INA3221..."); ESP_LOGCONFIG(TAG, "Running setup");
// Config Register // Config Register
// 0bx000000000000000 << 15 RESET Bit (1 -> trigger reset) // 0bx000000000000000 << 15 RESET Bit (1 -> trigger reset)
if (!this->write_byte_16(INA3221_REGISTER_CONFIG, 0x8000)) { if (!this->write_byte_16(INA3221_REGISTER_CONFIG, 0x8000)) {

View File

@ -66,7 +66,7 @@ void InternalTemperatureSensor::update() {
esp_err_t result = temperature_sensor_get_celsius(tsensNew, &temperature); esp_err_t result = temperature_sensor_get_celsius(tsensNew, &temperature);
success = (result == ESP_OK); success = (result == ESP_OK);
if (!success) { if (!success) {
ESP_LOGE(TAG, "Failed to get temperature: %d", result); ESP_LOGE(TAG, "Reading failed (%d)", result);
} }
#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) #endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
#endif // USE_ESP32_VARIANT #endif // USE_ESP32_VARIANT
@ -103,20 +103,20 @@ void InternalTemperatureSensor::setup() {
(defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S2) || \ (defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S2) || \
defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32H2) || defined(USE_ESP32_VARIANT_ESP32C2) || \ defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32H2) || defined(USE_ESP32_VARIANT_ESP32C2) || \
defined(USE_ESP32_VARIANT_ESP32P4)) defined(USE_ESP32_VARIANT_ESP32P4))
ESP_LOGCONFIG(TAG, "Setting up temperature sensor..."); ESP_LOGCONFIG(TAG, "Running setup");
temperature_sensor_config_t tsens_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(-10, 80); temperature_sensor_config_t tsens_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(-10, 80);
esp_err_t result = temperature_sensor_install(&tsens_config, &tsensNew); esp_err_t result = temperature_sensor_install(&tsens_config, &tsensNew);
if (result != ESP_OK) { if (result != ESP_OK) {
ESP_LOGE(TAG, "Failed to install temperature sensor: %d", result); ESP_LOGE(TAG, "Install failed (%d)", result);
this->mark_failed(); this->mark_failed();
return; return;
} }
result = temperature_sensor_enable(tsensNew); result = temperature_sensor_enable(tsensNew);
if (result != ESP_OK) { if (result != ESP_OK) {
ESP_LOGE(TAG, "Failed to enable temperature sensor: %d", result); ESP_LOGE(TAG, "Enabling failed (%d)", result);
this->mark_failed(); this->mark_failed();
return; return;
} }