-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPedal.h
41 lines (30 loc) · 952 Bytes
/
Pedal.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
class Pedal {
private:
typedef void (*PedalPressedHandler)(float force);
PedalPressedHandler pressedHandler;
int inputTopPin;
int inputBottomPin;
public:
float force;
Pedal(int _inputTopPin, int _inputBottomPin, PedalPressedHandler _pressedHandler) {
inputTopPin = _inputTopPin;
inputBottomPin = _inputBottomPin;
pressedHandler = _pressedHandler;
pinMode(inputTopPin,INPUT);
pinMode(inputBottomPin,INPUT);
// enable pull-up resistors
digitalWrite(inputTopPin,HIGH);
digitalWrite(inputBottomPin,HIGH);
}
void update() {
#ifdef DEBUG_PEDAL_VERBOSE
Serial.println(digitalRead(inputTopPin));
//Serial.print('\t');
//Serial.println(digitalRead(inputBottomPin));
#endif
if(digitalRead(inputTopPin) == HIGH) {
force = 1.0f;
pressedHandler(force);
}
}
};