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

Fix timers for initial conversions in start() #132

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/HX711_ADC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ void HX711_ADC::begin(uint8_t gain)
void HX711_ADC::start(unsigned long t)
{
t += 400;
unsigned long startTime = millis();
lastDoutLowTime = millis();
while(millis() < t)
while(millis() < startTime + t)
{
update();
yield();
Expand All @@ -63,8 +64,9 @@ void HX711_ADC::start(unsigned long t)
void HX711_ADC::start(unsigned long t, bool dotare)
{
t += 400;
unsigned long startTime = millis();
lastDoutLowTime = millis();
while(millis() < t)
while(millis() < startTime + t)
{
update();
yield();
Expand Down
4 changes: 2 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ Note that you can also overide (reducing) the number of samples in use at any ti
//microsecond delay after writing sck pin high or low. This delay could be required for faster mcu's.
//So far the only mcu reported to need this delay is the ESP32 (issue #35), both the Arduino Due and ESP8266 seems to run fine without it.
//Change the value to '1' to enable the delay.
#define SCK_DELAY 0 //default value: 0
#define SCK_DELAY 1 //default value: 0

//if you have some other time consuming (>60μs) interrupt routines that trigger while the sck pin is high, this could unintentionally set the HX711 into "power down" mode
//if required you can change the value to '1' to disable interrupts when writing to the sck pin.
#define SCK_DISABLE_INTERRUPTS 0 //default value: 0
#define SCK_DISABLE_INTERRUPTS 1 //default value: 0

#endif