Skip to content

sns/VL53L1X: improve sensor setup and validation#2313

Open
ruimarinho wants to merge 1 commit intoxoseperez:devfrom
ruimarinho:enhancement/vl53l1x-setup
Open

sns/VL53L1X: improve sensor setup and validation#2313
ruimarinho wants to merge 1 commit intoxoseperez:devfrom
ruimarinho:enhancement/vl53l1x-setup

Conversation

@ruimarinho
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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