Test time difference in safe way

This commit is contained in:
Scott Lahteine
2016-04-10 15:55:12 -07:00
parent 562e281c73
commit 386140f361
9 changed files with 60 additions and 57 deletions

View File

@ -77,12 +77,12 @@ void TWIBus::reqbytes(uint8_t bytes) {
SERIAL_EOL;
}
millis_t t = millis();
millis_t t = millis() + this->timeout;
Wire.requestFrom(this->addr, bytes);
// requestFrom() is a blocking function
while (Wire.available() < bytes) {
if (millis() - t >= this->timeout) break;
if (ELAPSED(millis(), t)) break;
else continue;
}