Adds timing macro

This commit is contained in:
Rune Harlyk
2024-07-14 23:14:07 +02:00
committed by Rune Harlyk
parent c783793b5c
commit 200ea62d95
11 changed files with 41 additions and 62 deletions
+1 -5
View File
@@ -210,10 +210,7 @@ class ServoController : public Adafruit_PWMServoDriver, public StatefulService<S
}
void loop() {
if (int currentMillis = millis(); !_lastUpdate || (currentMillis - _lastUpdate) >= ServoInterval) {
_lastUpdate = currentMillis;
updateServoState();
}
EXECUTE_EVERY_N_MS(ServoInterval, { updateServoState(); });
}
private:
@@ -223,6 +220,5 @@ class ServoController : public Adafruit_PWMServoDriver, public StatefulService<S
FSPersistence<ServoConfiguration> _fsPersistence;
bool is_active {true};
unsigned long _lastUpdate;
constexpr static int ServoInterval = 2;
};