This commit is contained in:
J. Nick Koston 2023-06-05 17:23:58 -05:00
parent fa336f60e3
commit 22d498ffb5
No known key found for this signature in database
1 changed files with 4 additions and 2 deletions

View File

@ -100,11 +100,13 @@ namespace ratgdo {
// RPM2: __|--|___ // RPM2: __|--|___
void IRAM_ATTR HOT RATGDOStore::isrRPM2(RATGDOStore *arg) 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 // 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 // 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 // pulse counter, but it doesn't matter since we only need a reliable linear
// counter to determine the door direction // counter to determine the door direction
if (millis() - arg->lastPulse < 5) { if (currentMillis - arg->lastPulse < 5) {
return; return;
} }
@ -118,7 +120,7 @@ namespace ratgdo {
return; return;
} }
arg->lastPulse = millis(); arg->lastPulse = currentMillis;
// If the RPM1 state is different from the RPM2 state, then the door is // If the RPM1 state is different from the RPM2 state, then the door is
// opening // opening