Skip to content

Commit

Permalink
don't change the local sensor address unless writing to the device re…
Browse files Browse the repository at this point in the history
…gister is successful
  • Loading branch information
devtanc authored Sep 16, 2024
1 parent 4804e21 commit 2dfcc71
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions VL6180X.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -397,4 +399,4 @@ bool VL6180X::timeoutOccurred()
uint8_t VL6180X::readRangeStatus()
{
return (readReg(RESULT__RANGE_STATUS) >> 4);
}
}

0 comments on commit 2dfcc71

Please sign in to comment.