mirror of
https://github.com/esphome/esphome.git
synced 2026-10-20 13:06:45 +00:00
Log the old and new register value at VERBOSE in update_register
This commit is contained in:
@@ -62,7 +62,9 @@ bool I2CDevice::update_register(uint8_t a_register, uint8_t mask, uint8_t value)
|
||||
uint8_t data;
|
||||
if (!this->read_byte(a_register, &data))
|
||||
return false;
|
||||
return this->write_byte(a_register, (data & ~mask) | (value & mask));
|
||||
const uint8_t updated = (data & ~mask) | (value & mask);
|
||||
ESP_LOGV(TAG, "Register 0x%02X: 0x%02X -> 0x%02X", a_register, data, updated);
|
||||
return this->write_byte(a_register, updated);
|
||||
}
|
||||
|
||||
bool I2CDevice::write_bytes_16(uint8_t a_register, const uint16_t *data, uint8_t len) const {
|
||||
|
||||
@@ -267,7 +267,7 @@ class I2CDevice {
|
||||
bool write_byte_16(uint8_t a_register, uint16_t data) const { return write_bytes_16(a_register, &data, 1); }
|
||||
|
||||
/// Read a register, replace the bits in @p mask with those of @p value and write it back.
|
||||
/// The write always happens; bits of @p value outside @p mask are ignored.
|
||||
/// The write always happens; bits of @p value outside @p mask are ignored. Logs both values at VERBOSE.
|
||||
/// @return false if the read or the write failed (nothing is written after a failed read)
|
||||
bool update_register(uint8_t a_register, uint8_t mask, uint8_t value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user