Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only change sensor address if the device register updated #18

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading