-
Notifications
You must be signed in to change notification settings - Fork 3
/
370z.h
65 lines (59 loc) · 1.84 KB
/
370z.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef _370Z_H_
#define _370Z_H_
#include "carduino.h"
#include <AnalogMultiButton.h>
class NissanSteeringControl {
public:
NissanSteeringControl(uint8_t pin1, uint8_t pin2) {
int buttonArray1[] = { 0, 210, 416, 620, 830 };
int buttonArray2[] = { 0, 210, 416, 620 };
this->buttons1 = new AnalogMultiButton(pin1, 5, buttonArray1);
this->buttons2 = new AnalogMultiButton(pin2, 4, buttonArray2);
}
void check(Carduino * carduino) {
this->buttons1->update();
// SOURCE
if (this->buttons1->onReleaseBefore(0, 500)) {
carduino->triggerEvent(101);
} else if (buttons1->onPressAfter(0, 500)) {
carduino->triggerEvent(102);
}
// MENU UP
if (this->buttons1->onPressAndAfter(1, 1000, 500)) {
carduino->triggerEvent(103);
}
// MENU DOWN
if (this->buttons1->onPressAndAfter(2, 1000, 500)) {
carduino->triggerEvent(104);
}
// VOICE
if (this->buttons1->onReleaseBefore(3, 500)) {
carduino->triggerEvent(112);
}
// ENTER
if (this->buttons1->onReleaseBefore(4, 500)) {
carduino->triggerEvent(105);
}
this->buttons2->update();
// VOL DOWN
if (this->buttons2->onPressAndAfter(0, 500, 200)) {
carduino->triggerEvent(110);
}
// VOL UP
if (this->buttons2->onPressAndAfter(1, 500, 200)) {
carduino->triggerEvent(111);
}
// PHONE
if (this->buttons2->onReleaseBefore(2, 500)) {
carduino->triggerEvent(113);
}
// BACK
if (this->buttons2->onReleaseBefore(3, 500)) {
carduino->triggerEvent(106);
}
}
private:
AnalogMultiButton * buttons1;
AnalogMultiButton * buttons2;
};
#endif /* _370Z_H_ */