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

sns/VL53L1X: improve sensor setup and validation #2313

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

ruimarinho
Copy link
Contributor

Small improvements to VL53L1X although I am getting more and more inclined to switch to the ultra lite driver version given the difference in accuracy.

Normalizes periods to milliseconds and adds some basic config validation.

Comment on lines +2037 to +2043
#if (VL53L1X_INTER_MEASUREMENT_PERIOD <= (VL53L1X_MEASUREMENT_TIMING_BUDGET + 4))
#error "[VL53L1X] Intermeasurement period must be greater than the timing budget + 4ms"
#endif

#if (VL53L1X_MEASUREMENT_TIMING_BUDGET < 20 || VL53L1X_MEASUREMENT_TIMING_BUDGET > 500)
#error "[VL53L1X] Timing budget is limited to [20, 500]"
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk if this is necessary here

  • looking at the library source, you could just check setMeasurementTimingBudget() boolean result by proxying it via the sensor method and setting internal error
  • this could also happen with setInterMeasurementPeriod(), never allowing startContiniuous in the begin()

thus, replacing #error with debug_msg_p() call

void setMeasurementTimingBudget(uint32_t budget_us) {
_vl53l1x->setMeasurementTimingBudget(budget_us);
void setMeasurementTimingBudget(uint16_t budget_ms) {
_vl53l1x->setMeasurementTimingBudget(budget_ms * 1000);
Copy link
Collaborator

@mcspr mcspr Aug 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to note, this implicitly means:

_vl53l1x->setMeasurementTimingBudget(static_cast<uint32_t>(static_cast<int>(budget_ms) * 1000)));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants