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

Replace with a virtual waitReady method #40

Open
endail opened this issue Dec 6, 2021 · 1 comment
Open

Replace with a virtual waitReady method #40

endail opened this issue Dec 6, 2021 · 1 comment
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@endail
Copy link
Owner

endail commented Dec 6, 2021

hx711/src/HX711.cpp

Lines 257 to 265 in de87c5b

/**
* A read must take place to set the gain at the
* hardware level. See datasheet pg. 4 "Serial
* Interface".
*
* TODO: this is an inefficient busy-wait. Solutions?
*/
while(!this->isReady());
this->readValue();

The waitReady method should busy-wait for a predefined maximum amount of time. If the amount of time is exceeded, a TimeoutException should be thrown. The try-catch in setConfig can then handle accordingly.

Inheriting classes like AdvancedHX711 can then override with something else as needed.

This will also handle the case where DOUT is never "ready" for some unforeseen reason.

@endail endail added bug Something isn't working enhancement New feature or request labels Dec 6, 2021
@endail endail self-assigned this Dec 15, 2021
@endail
Copy link
Owner Author

endail commented Dec 15, 2021

AdvancedHX711 relies upon Watcher, which - currently - does not easily allow for notifications when data is ready. A rewrite may be in order. Perhaps event-based callbacks?

endail added a commit that referenced this issue Dec 15, 2021
Fixes #40
endail added a commit that referenced this issue Dec 18, 2021
@endail endail closed this as completed in 3c95edc Apr 5, 2022
@endail endail reopened this Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant