12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #ifndef TIMERREMAINING_H
- #define TIMERREMAINING_H
- #include "Timer.h"
- #include "Arduino.h"
- #include <limits.h>
- class TimerRemaining : public LongTimer
- {
- public:
- TimerRemaining() : m_period(){}
- void start() = delete;
- bool expired(unsigned long msPeriod) = delete;
-
- void start(unsigned long msPeriod)
- {
- m_period = msPeriod;
- LongTimer::start();
- }
-
- unsigned long remaining()
- {
- if (!running()) return 0;
- if (expired()) return 0;
- const unsigned long now = millis();
- return (started() + m_period - now);
- }
-
- bool expired()
- {
- return LongTimer::expired(m_period);
- }
- private:
- unsigned long m_period;
- };
- #endif
|