Log the old and new register value at VERBOSE in update_register

This commit is contained in:
J. Nick Koston
2026-10-15 14:58:00 -10:00
parent 8145b7ae93
commit 053fd535ad
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -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 {
+1 -1
View File
@@ -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);