wasteful loop in now()
pidloop opened this issue · 0 comments
pidloop commented
In Time.cpp, the loop at the beginning of now() is wasteful. It could be replaced with:
uint32_t n_secs = (millis() - prevMillis)/1000U;
sysTime += n_secs;
prevMillis += n_secs * 1000U;
Also, the nearby comment about subtracting unsigned values is wrong. Assuming the expression A-B, it's not the absolute value that is the same, it's that the distance from B towards A correctly accounts for overflow when A < B.
Cheers!