mirror of
https://github.com/esphome/esphome.git
synced 2024-12-11 16:04:54 +01:00
parent
567256bd62
commit
65a5216d17
2 changed files with 9 additions and 7 deletions
|
@ -34,7 +34,7 @@ void PCA6416AComponent::setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test to see if the device supports pull-up resistors
|
// Test to see if the device supports pull-up resistors
|
||||||
if (this->read_register(PCAL6416A_PULL_EN0, &value, 1, true) == esphome::i2c::ERROR_OK) {
|
if (this->read_register(PCAL6416A_PULL_EN0, &value, 1, true) == i2c::ERROR_OK) {
|
||||||
this->has_pullup_ = true;
|
this->has_pullup_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,8 @@ bool PCA6416AComponent::read_register_(uint8_t reg, uint8_t *value) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((this->last_error_ = this->read_register(reg, value, 1, true)) != esphome::i2c::ERROR_OK) {
|
this->last_error_ = this->read_register(reg, value, 1, true);
|
||||||
|
if (this->last_error_ != i2c::ERROR_OK) {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
ESP_LOGE(TAG, "read_register_(): I2C I/O error: %d", (int) this->last_error_);
|
ESP_LOGE(TAG, "read_register_(): I2C I/O error: %d", (int) this->last_error_);
|
||||||
return false;
|
return false;
|
||||||
|
@ -122,7 +123,8 @@ bool PCA6416AComponent::write_register_(uint8_t reg, uint8_t value) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((this->last_error_ = this->write_register(reg, &value, 1, true)) != esphome::i2c::ERROR_OK) {
|
this->last_error_ = this->write_register(reg, &value, 1, true);
|
||||||
|
if (this->last_error_ != i2c::ERROR_OK) {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
ESP_LOGE(TAG, "write_register_(): I2C I/O error: %d", (int) this->last_error_);
|
ESP_LOGE(TAG, "write_register_(): I2C I/O error: %d", (int) this->last_error_);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -95,8 +95,8 @@ bool PCA9554Component::read_inputs_() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((this->last_error_ = this->read_register(INPUT_REG * this->reg_width_, inputs, this->reg_width_, true)) !=
|
this->last_error_ = this->read_register(INPUT_REG * this->reg_width_, inputs, this->reg_width_, true);
|
||||||
esphome::i2c::ERROR_OK) {
|
if (this->last_error_ != i2c::ERROR_OK) {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
ESP_LOGE(TAG, "read_register_(): I2C I/O error: %d", (int) this->last_error_);
|
ESP_LOGE(TAG, "read_register_(): I2C I/O error: %d", (int) this->last_error_);
|
||||||
return false;
|
return false;
|
||||||
|
@ -113,8 +113,8 @@ bool PCA9554Component::write_register_(uint8_t reg, uint16_t value) {
|
||||||
uint8_t outputs[2];
|
uint8_t outputs[2];
|
||||||
outputs[0] = (uint8_t) value;
|
outputs[0] = (uint8_t) value;
|
||||||
outputs[1] = (uint8_t) (value >> 8);
|
outputs[1] = (uint8_t) (value >> 8);
|
||||||
if ((this->last_error_ = this->write_register(reg * this->reg_width_, outputs, this->reg_width_, true)) !=
|
this->last_error_ = this->write_register(reg * this->reg_width_, outputs, this->reg_width_, true);
|
||||||
esphome::i2c::ERROR_OK) {
|
if (this->last_error_ != i2c::ERROR_OK) {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
ESP_LOGE(TAG, "write_register_(): I2C I/O error: %d", (int) this->last_error_);
|
ESP_LOGE(TAG, "write_register_(): I2C I/O error: %d", (int) this->last_error_);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue