Skip to content

Commit

Permalink
Merge pull request #18 from devtanc/patch-1
Browse files Browse the repository at this point in the history
only change sensor address if the device register updated
  • Loading branch information
kevin-pololu authored Sep 25, 2024
2 parents 4804e21 + 2dfcc71 commit 669b4a9
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 669b4a9

Please sign in to comment.