adafruit / Adafruit_BME680

127 stars 76 forks source link

Fix remaining time bug #22

Closed kvc0 closed 5 years ago

kvc0 commented 5 years ago

In the recent update to fix uint32 millis rollover, I backwardsed math. When your loop is slow, the calculation reaches 0, then counts up forever. When your loop is fast, it lies and says the result is ready immediately (causing blocking, but no other ill effect).

This change subtracts elapsed time from measure period - as is intuitively necessary.

The beginReading, poll remainingReadMillis, endReading strategy now blocks a Particle Photon for 0.25ms on average when checking remainingReadMillis correctly.