puzzle-box/pulse.h

23 lines
476 B
C
Raw Normal View History

2020-12-06 18:36:12 -07:00
#pragma once
2020-12-13 21:07:20 -07:00
#define MILLISECOND 1L
#define SECOND (1000 * MILLISECOND)
#define MINUTE (60 * SECOND)
#define HOUR (60 * MINUTE)
#define DAY (24 * HOUR)
2020-12-06 18:36:12 -07:00
class Pulse {
public:
Pulse(unsigned long period);
/** Tick tells you if a period has elapsed. */
bool Tick();
2020-12-13 21:07:20 -07:00
/** Until sets the duration of the next period. */
void Until(unsigned long next);
void Until(unsigned long next, unsigned long now);
2020-12-06 18:36:12 -07:00
unsigned long period;
unsigned long nextEventMillis;
};