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

Update ds248x.cpp

check clang
This commit is contained in:
Iron Man 2024-04-23 19:57:11 +02:00 committed by GitHub
parent 858f5eafcd
commit d0c7709da9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -163,7 +163,6 @@ namespace esphome {
} }
} }
} }
} }
void DS248xComponent::dump_config() { void DS248xComponent::dump_config() {
@ -233,11 +232,9 @@ namespace esphome {
} }
} }
} }
} }
void DS248xComponent::register_sensor(DS248xTemperatureSensor *sensor) { void DS248xComponent::register_sensor(DS248xTemperatureSensor *sensor) {
this->sensors_.push_back(sensor); this->sensors_.push_back(sensor);
// DS2482-100 // DS2482-100
@ -265,7 +262,6 @@ namespace esphome {
} }
for (channel = 0; channel < nbr_channels; channel++) { for (channel = 0; channel < nbr_channels; channel++) {
if (this->ds248x_type_ == DS248xType::DS2482_800) { if (this->ds248x_type_ == DS248xType::DS2482_800) {
ESP_LOGV(TAG, "Channel: %u", channel); ESP_LOGV(TAG, "Channel: %u", channel);
} }
@ -276,7 +272,6 @@ namespace esphome {
this->status_clear_warning(); this->status_clear_warning();
if (nbr_sensors_on_channel && this->set_channel(channel)) { if (nbr_sensors_on_channel && this->set_channel(channel)) {
if (this->enable_bus_sleep_) { if (this->enable_bus_sleep_) {
this->write_config(this->read_config() & ~DS248X_CONFIG_POWER_DOWN); this->write_config(this->read_config() & ~DS248X_CONFIG_POWER_DOWN);
} }
@ -346,9 +341,7 @@ namespace esphome {
}); });
} }
float DS248xComponent::get_setup_priority() const { float DS248xComponent::get_setup_priority() const { return setup_priority::DATA; }
return setup_priority::DATA;
}
uint8_t DS248xComponent::read_config() { uint8_t DS248xComponent::read_config() {
std::array<uint8_t, 2> cmd; std::array<uint8_t, 2> cmd;
@ -384,7 +377,6 @@ namespace esphome {
return status; return status;
} }
void DS248xComponent::reset_hub() { void DS248xComponent::reset_hub() {
if (this->sleep_pin_) { if (this->sleep_pin_) {
this->sleep_pin_->digital_write(true); this->sleep_pin_->digital_write(true);
@ -423,9 +415,7 @@ namespace esphome {
return false; return false;
} }
uint8_t DS248xComponent::get_channel() { uint8_t DS248xComponent::get_channel() { return (this->channel); }
return(this->channel);
}
bool DS248xComponent::reset_devices() { bool DS248xComponent::reset_devices() {
auto status = wait_while_busy(); auto status = wait_while_busy();
@ -476,9 +466,7 @@ namespace esphome {
} }
} }
void DS248xComponent::write_to_wire(uint8_t data) { void DS248xComponent::write_to_wire(uint8_t data) { this->write_command(DS248X_COMMAND_WRITEBYTE, data); }
this->write_command(DS248X_COMMAND_WRITEBYTE, data);
}
uint8_t DS248xComponent::read_from_wire() { uint8_t DS248xComponent::read_from_wire() {
auto status = wait_while_busy(); auto status = wait_while_busy();
@ -508,7 +496,6 @@ namespace esphome {
} }
bool DS248xComponent::search(uint64_t *address) { bool DS248xComponent::search(uint64_t *address) {
if (last_device_found) if (last_device_found)
return false; return false;
@ -542,15 +529,13 @@ namespace esphome {
if (id && comp_id) if (id && comp_id)
return 0; return 0;
else else if (!id && !comp_id && !direction)
if (!id && !comp_id && !direction)
last_zero = i; last_zero = i;
if (direction) if (direction)
searchAddress |= searchBit; searchAddress |= searchBit;
else else
searchAddress &= ~searchBit; searchAddress &= ~searchBit;
} }
searchLastDiscrepancy = last_zero; searchLastDiscrepancy = last_zero;
@ -563,37 +548,21 @@ namespace esphome {
return 1; return 1;
} }
void DS248xTemperatureSensor::set_address(uint64_t address) { void DS248xTemperatureSensor::set_address(uint64_t address) { this->address_ = address; }
this->address_ = address;
}
void DS248xTemperatureSensor::set_channel(uint8_t channel) { void DS248xTemperatureSensor::set_channel(uint8_t channel) { this->channel_ = channel; }
this->channel_ = channel;
}
uint8_t DS248xTemperatureSensor::get_channel() const { uint8_t DS248xTemperatureSensor::get_channel() const { return this->channel_; }
return this->channel_;
}
uint8_t DS248xTemperatureSensor::get_resolution() const { uint8_t DS248xTemperatureSensor::get_resolution() const { return this->resolution_; }
return this->resolution_;
}
void DS248xTemperatureSensor::set_resolution(uint8_t resolution) { void DS248xTemperatureSensor::set_resolution(uint8_t resolution) { this->resolution_ = resolution; }
this->resolution_ = resolution;
}
optional<uint8_t> DS248xTemperatureSensor::get_index() const { optional<uint8_t> DS248xTemperatureSensor::get_index() const { return this->index_; }
return this->index_;
}
void DS248xTemperatureSensor::set_index(uint8_t index) { void DS248xTemperatureSensor::set_index(uint8_t index) { this->index_ = index; }
this->index_ = index;
}
uint8_t *DS248xTemperatureSensor::get_address8() { uint8_t *DS248xTemperatureSensor::get_address8() { return reinterpret_cast<uint8_t *>(&this->address_); }
return reinterpret_cast<uint8_t *>(&this->address_);
}
const std::string &DS248xTemperatureSensor::get_address_name() { const std::string &DS248xTemperatureSensor::get_address_name() {
if (this->address_name_.empty()) { if (this->address_name_.empty()) {
@ -661,7 +630,6 @@ namespace esphome {
break; break;
} }
if (this->scratch_pad_[4] == resolution_register_val) if (this->scratch_pad_[4] == resolution_register_val)
return true; return true;
@ -671,7 +639,6 @@ namespace esphome {
return false; return false;
} }
bool result = this->parent_->reset_devices(); bool result = this->parent_->reset_devices();
if (!result) { if (!result) {
ESP_LOGE(TAG, "Reset failed"); ESP_LOGE(TAG, "Reset failed");