Skip to content

Usage of Sleep #11

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

Closed
johnjones4 opened this issue Sep 29, 2020 · 7 comments
Closed

Usage of Sleep #11

johnjones4 opened this issue Sep 29, 2020 · 7 comments

Comments

@johnjones4
Copy link

Is there a reason time.sleep(0.002) is used here rather than just pass? Or is 0.002 seconds specific to the device?

@caternuson
Copy link
Contributor

Nothing specific to the device. Just providing a small wait time for the busy-wait loop.

Is the delay causing issues?

@johnjones4
Copy link
Author

I'm using this to measure altitude from a model rocket, and so I'd like to sample as often as possible on ascent. I changed it to just use pass and it seems to boost performance without any negative impact.

@jposada202020
Copy link
Contributor

@caternuson Do you think is a good Idea to create a parameter in the library to be set and modify this time?

@jposada202020
Copy link
Contributor

Did some test with and without the sleep, the average difference with and without time between reading is 8ms. This was done taking three different readings intervals of [0.3, 0.5 1.0] seconds.

@caternuson
Copy link
Contributor

@jposada202020 sorry, missed your previous mention. yah, that's probably fine. i think just pass in the loop would also work, but have had comments in PRs that say adding a call to sleep() is "better".

"reading as fast as possible" can be slowed down by other things though, like i2c bus speed.

@jposada202020
Copy link
Contributor

will do @caternuson Thanks

@jposada202020
Copy link
Contributor

We added the attribute in the library, following your input @caternuson we keep the time.sleep. this is a private attribute. This will help people in corner cases, and not breaking old code already written. Thanks, closing for now.

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

No branches or pull requests

3 participants