-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSimplifiedTapper.h
51 lines (42 loc) · 1.22 KB
/
SimplifiedTapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* SimplifiedTapper.h
*
* Created on: Sep 5, 2014
* Author: bastl
*/
#ifndef SIMPLIFIED_TAPPER_H_
#define SIMPLIFIED_TAPPER_H_
#include "ITapper.h"
class SimplifiedTapper : public ITapper {
public:
SimplifiedTapper();
virtual ~SimplifiedTapper();
virtual void init(unsigned int maxStepLengthInTimeUnits, unsigned int maxStepDeviationInTImeUnits);
virtual void tap(unsigned int tapTime);
virtual void setStepsPerTap(unsigned char stepsPerTap);
virtual unsigned int getTimeUnitsPerStep();
virtual void setStepCallBack(void (*makeStep)());
virtual bool anyStepDetected();
unsigned int lastTapTime;
private:
char stepsInRow_;
unsigned int lastTapTime_;
unsigned int currentTapTime_;
unsigned int stepsPerTap_;
unsigned int maxStepLengthInTimeUnits_;
unsigned int maxStepDeviationInTImeUnits_;
void (*makeStep_)();
};
inline void SimplifiedTapper::setStepsPerTap(unsigned char stepsPerTap) {
stepsPerTap_ = stepsPerTap;
}
inline unsigned int SimplifiedTapper::getTimeUnitsPerStep() {
return currentTapTime_ / stepsPerTap_;
}
inline void SimplifiedTapper::setStepCallBack(void (*makeStep)()) {
makeStep_ = makeStep;
}
inline bool SimplifiedTapper::anyStepDetected() {
return stepsInRow_ > 1;
}
#endif /* TAPPER_H_ */