1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-15 15:18:16 +00:00

Formatting corrections (clang-format)

This commit is contained in:
Thierry DUVERNOY 2025-01-16 06:20:09 +01:00
parent 8a29d733a4
commit 8d4b43ab1b
2 changed files with 14 additions and 21 deletions

View File

@ -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,8 +174,8 @@ 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
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) {
@ -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; }

View File

@ -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<uint8_t>(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<uint8_t> data);
uint8_t pin_;
bool pin_inverted_;
uint8_t PioOutputRegister_;
uint8_t pio_output_register_;
};
} // namespace dallas_pio