endail / hx711

Raspberry Pi HX711 C++ Library
MIT License
18 stars 10 forks source link

Replace with a virtual waitReady method #40

Open endail opened 2 years ago

endail commented 2 years ago

https://github.com/endail/hx711/blob/de87c5b54282c7e86e214a7ec04d64beda106735/src/HX711.cpp#L257-L265

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 commented 2 years ago

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?