endail/hx711

HX711::powerDown should not block by sleeping for timeout duration

endail opened this issue · 1 comments

hx711/src/HX711.cpp

Lines 344 to 365 in 42d6305

void HX711::powerDown() {
std::lock_guard<std::mutex> lock(this->_commLock);
/**
* The delay between low to high is probably not necessary, but it
* should help to keep the underlying code from optimising it away -
* if does at all.
*/
Utility::writeGpio(this->_gpioHandle, this->_clockPin, GpioLevel::LOW);
Utility::delay(std::chrono::microseconds(1));
Utility::writeGpio(this->_gpioHandle, this->_clockPin, GpioLevel::HIGH);
/**
* "When PD_SCK pin changes from low to high
* and stays at high for longer than 60µs, HX711
* enters power down mode (Fig.3)."
* Datasheet pg. 5
*/
Utility::sleep(_POWER_DOWN_TIMEOUT);
}

Timeout should be separate from powering down to allow other/concurrent code to run.

Accidentally fixed in #68