diff options
Diffstat (limited to 'arduino/rpmcount/Counter.h')
| -rwxr-xr-x | arduino/rpmcount/Counter.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/arduino/rpmcount/Counter.h b/arduino/rpmcount/Counter.h new file mode 100755 index 0000000..f832023 --- /dev/null +++ b/arduino/rpmcount/Counter.h | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | class Counter | ||
| 4 | { | ||
| 5 | public: | ||
| 6 | |||
| 7 | enum State | ||
| 8 | { | ||
| 9 | READY, | ||
| 10 | WAITING_FOR_TIMEOUT, | ||
| 11 | COUNTING, | ||
| 12 | SIGNALING | ||
| 13 | }; | ||
| 14 | |||
| 15 | public: | ||
| 16 | |||
| 17 | void init (unsigned long startDelay, unsigned long rpmCount, unsigned long signalsPerRPM); | ||
| 18 | |||
| 19 | void setStartDelay (unsigned long); | ||
| 20 | |||
| 21 | void setRPMCount (unsigned long); | ||
| 22 | |||
| 23 | void setSignalsPerRPM (unsigned long); | ||
| 24 | |||
| 25 | void start (unsigned long startTime); | ||
| 26 | |||
| 27 | void reset (); | ||
| 28 | |||
| 29 | void update (unsigned long time, int rpmSignal); | ||
| 30 | |||
| 31 | State getState () const; | ||
| 32 | |||
| 33 | private: | ||
| 34 | |||
| 35 | State state; | ||
| 36 | |||
| 37 | unsigned long startDelay; | ||
| 38 | unsigned long rpmCount; | ||
| 39 | unsigned long signalsPerRPM; | ||
| 40 | unsigned long startTime; | ||
| 41 | |||
| 42 | unsigned long signals; | ||
| 43 | |||
| 44 | bool lastRpmSignal; | ||
| 45 | }; | ||
