From 8d4b43ab1b634b28cf30ad86c4803e079f258635 Mon Sep 17 00:00:00 2001 From: Thierry DUVERNOY Date: Thu, 16 Jan 2025 06:20:09 +0100 Subject: [PATCH] Formatting corrections (clang-format) --- esphome/components/dallas_pio/dallas_pio.cpp | 21 ++++++++++---------- esphome/components/dallas_pio/dallas_pio.h | 14 ++++--------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/esphome/components/dallas_pio/dallas_pio.cpp b/esphome/components/dallas_pio/dallas_pio.cpp index 3840a0a4a3..499fdbec09 100644 --- a/esphome/components/dallas_pio/dallas_pio.cpp +++ b/esphome/components/dallas_pio/dallas_pio.cpp @@ -34,7 +34,7 @@ void DallasPio::setup() { if (this->is_setup_done_) return; // ESP_LOGD("dallas_pio", "Setting up DallasPio: %s", this->name_.c_str()); - this->initialize_reference_(); + this->initialize_reference(); this->is_setup_done_ = true; } @@ -164,9 +164,9 @@ void DallasPio::ds2413_write_state_(bool state) { uint8_t mask = 1 << (this->pin_ - 1); // If state different than this->pin_inverted_ if (state ^ this->pin_inverted_) { - this->PioOutputRegister_ &= ~mask; // set bit bx to 0 + this->pio_output_register_ &= ~mask; // set bit bx to 0 } else { - this->PioOutputRegister_ |= mask; // set bx to 1 + this->pio_output_register_ |= mask; // set bx to 1 } } else { return; @@ -174,9 +174,9 @@ void DallasPio::ds2413_write_state_(bool state) { { InterruptLock lock; this->send_command_(DALLAS_COMMAND_PIO_ACCESS_WRITE); - this->bus_->write8(this->PioOutputRegister_); // Send data - this->bus_->write8(~this->PioOutputRegister_); // Invert data and resend - ack = this->bus_->read8(); // 0xAA=success, 0xFF=failure + this->bus_->write8(this->pio_output_register_); // Send data + this->bus_->write8(~this->pio_output_register_); // Invert data and resend + ack = this->bus_->read8(); // 0xAA=success, 0xFF=failure } if (ack == DALLAS_COMMAND_PIO_ACK_SUCCESS) { this->bus_->read8(); // Read the PIOA PIOB status byte @@ -218,7 +218,7 @@ bool DallasPio::ds2406_get_state_(uint8_t &state, bool use_crc = false) { uint8_t channel_control_byte_2 = 0xFF; uint8_t channel_info_byte; uint8_t received_crc = 0; - const char *strPIO = nullptr; + const char *str_pio = nullptr; // Initialize One-Wire bus for this device if (!this->check_address_()) { this->status_set_warning(); @@ -278,13 +278,13 @@ bool DallasPio::ds2406_get_state_(uint8_t &state, bool use_crc = false) { pio_flipflop = channel_info_byte & 0x01; pio_sensed_level = channel_info_byte & 0x04; pio_activity_latch = channel_info_byte & 0x10; - strPIO = "PIOA"; + str_pio = "PIOA"; break; case 0x02: // PIOB pio_flipflop = channel_info_byte & 0x02; pio_sensed_level = channel_info_byte & 0x08; pio_activity_latch = channel_info_byte & 0x20; - strPIO = "PIOB"; + str_pio = "PIOB"; break; default: ESP_LOGW(TAG, "DallasPio DS2406 pin %u does not exist !", this->pin_); @@ -293,7 +293,7 @@ bool DallasPio::ds2406_get_state_(uint8_t &state, bool use_crc = false) { break; } if (pio_flipflop == 0) { - ESP_LOGW(TAG, "DallasPio DS2406 PIO flipflop must be 1 to read %s", strPIO); + ESP_LOGW(TAG, "DallasPio DS2406 PIO flipflop must be 1 to read %s", str_pio); this->status_set_warning(); return false; } @@ -385,7 +385,6 @@ bool DallasPio::ds2408_get_state_(uint8_t &state, bool use_crc = false) { void DallasPio::ds2408_write_state_(bool state, bool use_crc = false) { ESP_LOGW(TAG, "DallasPio DS2408 : ds2408_write_state_ to be implemented"); this->status_set_warning(); - return; } void DallasPio::crc_reset_() { this->crc_ = 0x0000; } diff --git a/esphome/components/dallas_pio/dallas_pio.h b/esphome/components/dallas_pio/dallas_pio.h index 3720f78d6c..79768ef558 100644 --- a/esphome/components/dallas_pio/dallas_pio.h +++ b/esphome/components/dallas_pio/dallas_pio.h @@ -23,7 +23,7 @@ class DallasPio : public Component, public one_wire::OneWireDevice { void setup() override; void dump_config() override; - void initialize_reference_() { + void initialize_reference() { this->family_code_ = static_cast(this->address_ & 0xFF); switch (this->family_code_) { case DALLAS_MODEL_DS2413: @@ -39,7 +39,7 @@ class DallasPio : public Component, public one_wire::OneWireDevice { this->reference_from_address_ = "Unknown"; break; } - if (this->reference_ == "") { + if (this->reference_.empty()) { if (this->reference_from_address_ == "Unknown") { this->reference_ = "DS2413"; } else { @@ -48,13 +48,7 @@ class DallasPio : public Component, public one_wire::OneWireDevice { } if (this->reference_ == "DS2413") { - PioOutputRegister_ = 0xFF; - } else if (this->reference_ == "DS2406") { - // Action pour DS2406 - } else if (this->reference_ == "DS2408") { - // Action pour DS2408 - } else { - // Action par défaut + pio_output_register_ = 0xFF; } } @@ -89,7 +83,7 @@ class DallasPio : public Component, public one_wire::OneWireDevice { // uint8_t calculate_crc_(std::initializer_list data); uint8_t pin_; bool pin_inverted_; - uint8_t PioOutputRegister_; + uint8_t pio_output_register_; }; } // namespace dallas_pio