From 22d498ffb5e5aea13fc152e37ad1ac1da6b5660f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 5 Jun 2023 17:23:58 -0500 Subject: [PATCH] fix --- components/ratgdo/ratgdo.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index fd3542c..aacf876 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -100,11 +100,13 @@ namespace ratgdo { // RPM2: __|--|___ void IRAM_ATTR HOT RATGDOStore::isrRPM2(RATGDOStore *arg) { + unsigned long currentMillis = millis(); + // The encoder updates faster than the ESP wants to process, so by sampling // every 5ms we get a more reliable curve The counter is behind the actual // pulse counter, but it doesn't matter since we only need a reliable linear // counter to determine the door direction - if (millis() - arg->lastPulse < 5) { + if (currentMillis - arg->lastPulse < 5) { return; } @@ -118,7 +120,7 @@ namespace ratgdo { return; } - arg->lastPulse = millis(); + arg->lastPulse = currentMillis; // If the RPM1 state is different from the RPM2 state, then the door is // opening