-
Notifications
You must be signed in to change notification settings - Fork 126
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
Clock wrap not catered for and other issues from a code read through #51
Comments
Likewise in int HX711_ADC::startMultiple(unsigned int t, bool dotare) |
uint8_t HX711_ADC::conversion24bit() |
data = data ^ 0x800000; // if the 24th bit is '1', change 24th bit to 0 |
data = data << 1; I would probably have written this as: |
A lot of this, the low/high value code, can be compiled out when not needed and the condition removed from the subtractions. |
smoothedData() |
Many thanks Malcolm! All your suggestions is now implemented in 1.2.4 |
In HX711_ADC::startMultiple(unsigned int t) appears the line
if(millis() < startMultipleTimeStamp + startMultipleWaitTime)
which will fail to work as expected if startMultipleTimeStamp + startMultipleWaitTime wraps around the clock. The fix is to work with durations instead of times.
if ( millis() - startMultipleTimeStamp > startMultipleWaitTime)
See https://www.norwegiancreations.com/2018/10/arduino-tutorial-avoiding-the-overflow-issue-when-using-millis-and-micros/
I will create a PR but it may be a few days before I can do that.
The text was updated successfully, but these errors were encountered: