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

Refactored commit - VL53L4CX default settings #564

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

tyeth
Copy link
Contributor

@tyeth tyeth commented Apr 9, 2024

No description provided.

@tyeth
Copy link
Contributor Author

tyeth commented Apr 10, 2024

@brentru ready for review, release blocked until partition size resolved on some build targets as discussed yesterday

@tyeth tyeth requested a review from brentru April 10, 2024 15:42
@tyeth tyeth force-pushed the add-VL53L4CX branch 2 times, most recently from e0abaf8 to 213fcef Compare April 24, 2024 19:46
@tyeth tyeth marked this pull request as ready for review April 25, 2024 18:39
@tyeth
Copy link
Contributor Author

tyeth commented Apr 25, 2024

@brentru ready for review, tested locally, will retest on staging before merge

@tyeth
Copy link
Contributor Author

tyeth commented May 17, 2024

Re-ready for review @brentru

@tyeth tyeth requested a review from brentru May 17, 2024 16:59
*/
/*******************************************************************************/
void awaitDataReady(int &status, uint8_t &NewDataReady) {
for (uint8_t retries = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Could we return NAN, and return immediately vs retrying three times? These drivers are supposed to be very small and fast, like an interrupt routine.

otherwise.
*/
/*******************************************************************************/
bool getProximity(sensors_event_t *proximityEvent, int index = 0) {
Copy link
Member

Choose a reason for hiding this comment

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

I feel this function is doing many things and it's resulting in a conditional statement that's difficult for me to parse. Could we refactor this a bit?

I'll suggest some ideas below..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's not exactly friendly and easily readable, will have a rethink

if ((status == VL53L4CX_ERROR_NONE) && (NewDataReady != 0)) {
status = _VL53L4CX->VL53L4CX_GetMultiRangingData(pMultiRangingData);
int no_of_object_found = pMultiRangingData->NumberOfObjectsFound;
if (no_of_object_found - 1 < index) {
Copy link
Member

Choose a reason for hiding this comment

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

This index boundary is confusing. Could you either reformat it, or refactor it out into a function that is then checked?

proximityEvent->data[0] = NAN;
return true;
}
bool retVal = updateDataPointIfValid(pMultiRangingData->RangeData[index],
Copy link
Member

Choose a reason for hiding this comment

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

I'm unsure how you'd want to restructure the conditional, but this (L150-L152) is hidden within the nested if statement. It's the code's desired outcome, so, could we make it more visible?

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.

None yet

2 participants