stepcompress: Improve numerical stability of step+dir+step filter

Apply the step+dir+step filter even if, for some reason, a negative
time is found.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-04-11 12:11:03 -04:00
parent a93d09cdf4
commit dce9971aa9
1 changed files with 1 additions and 1 deletions

View File

@ -499,7 +499,7 @@ stepcompress_append(struct stepcompress *sc, int sdir
// Flush previous pending step (if any)
if (sc->next_step_clock) {
if (unlikely(sdir != sc->next_step_dir)) {
double diff = step_clock - sc->next_step_clock;
double diff = (int64_t)(step_clock - sc->next_step_clock);
if (diff < SDS_FILTER_TIME * sc->mcu_freq) {
// Rollback last step to avoid rapid step+dir+step
sc->next_step_clock = 0;