diff --git a/VL6180X.cpp b/VL6180X.cpp index d0c9855..8475db0 100644 --- a/VL6180X.cpp +++ b/VL6180X.cpp @@ -27,7 +27,9 @@ VL6180X::VL6180X() void VL6180X::setAddress(uint8_t new_addr) { writeReg(I2C_SLAVE__DEVICE_ADDRESS, new_addr & 0x7F); - address = new_addr; + if (last_status == 0) { + address = new_addr; + } } // Initialize sensor with settings from ST application note AN4545, section @@ -397,4 +399,4 @@ bool VL6180X::timeoutOccurred() uint8_t VL6180X::readRangeStatus() { return (readReg(RESULT__RANGE_STATUS) >> 4); -} \ No newline at end of file +}