-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSonyRemote_RMD420.h
154 lines (145 loc) · 4.98 KB
/
SonyRemote_RMD420.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef SonyRemote_RMD420_h
#define SonyRemote_RMD420_h
#include "remote/IRRemote.h"
class SonyRemote_RMD420 : public IRRemote {
private:
static const uint16_t CMD_CONTINUE = 29;
static const uint16_t CMD_SHUFFLE = 53;
static const uint16_t CMD_PROGRAM = 31;
static const uint16_t CMD_1 = 0;
static const uint16_t CMD_2 = 1;
static const uint16_t CMD_3 = 2;
static const uint16_t CMD_4 = 3;
static const uint16_t CMD_5 = 4;
static const uint16_t CMD_6 = 5;
static const uint16_t CMD_7 = 6;
static const uint16_t CMD_8 = 7;
static const uint16_t CMD_9 = 8;
static const uint16_t CMD_10PLUS = 39;
static const uint16_t CMD_10 = 32;
static const uint16_t CMD_CLEAR = 15;
static const uint16_t CMD_TIME = 40;
static const uint16_t CMD_CHECK = 13;
static const uint16_t CMD_REPEAT = 44;
static const uint16_t CMD_FADER = 95;
static const uint16_t CMD_PLAY = 50;
static const uint16_t CMD_PAUSE = 57;
static const uint16_t CMD_STOP = 56;
static const uint16_t CMD_PREVIOUS = 48;
static const uint16_t CMD_NEXT = 49;
static const uint16_t CMD_PLUS = 18;
static const uint16_t CMD_BACKWARD = 51;
static const uint16_t CMD_FORWARD = 52;
static const uint16_t CMD_MINUS = 19;
bool tenPlus = false;
void handleCommand(uint8_t protocol, uint16_t command, bool repeated) override {
if (protocol == 1) { // P=SIRCS A=0x0)
if (!repeated) {
handleNonRepeatableKey(command);
}
handleRepeatableKey(command);
}
}
void handleNumericKey(int numKey) {
int num = numKey;
if (tenPlus) {
num += 10;
tenPlus = false;
}
controller->setParam(num);
};
void handleRepeatableKey(uint16_t key) {
switch(key) {
case CMD_PLUS:
controller->increaseBrightness();
break;
case CMD_MINUS:
controller->decreaseBrightness();
break;
case CMD_BACKWARD:
controller->decreaseParam();
break;
case CMD_FORWARD:
controller->increaseParam();
break;
}
};
void handleNonRepeatableKey(uint16_t key) {
switch(key) {
case CMD_CONTINUE:
controller->sequential();
break;
case CMD_SHUFFLE:
controller->shuffle();
break;
case CMD_PROGRAM:
break;
case CMD_1:
handleNumericKey(1);
break;
case CMD_2:
handleNumericKey(2);
break;
case CMD_3:
handleNumericKey(3);
break;
case CMD_4:
handleNumericKey(4);
break;
case CMD_5:
handleNumericKey(5);
break;
case CMD_6:
handleNumericKey(6);
break;
case CMD_7:
handleNumericKey(7);
break;
case CMD_8:
handleNumericKey(8);
break;
case CMD_9:
handleNumericKey(9);
break;
case CMD_10:
handleNumericKey(10);
break;
case CMD_10PLUS:
tenPlus = true;
break;
case CMD_CLEAR:
controller->setMode();
break;
case CMD_TIME:
controller->cycleSpeed();
break;
case CMD_CHECK:
controller->toggleInput();
break;
case CMD_REPEAT:
controller->reset();
break;
case CMD_FADER:
controller->toggleAudio();
break;
case CMD_PLAY:
controller->play();
break;
case CMD_PAUSE:
controller->pause();
break;
case CMD_STOP:
controller->stop();
break;
case CMD_PREVIOUS:
controller->selectPreviousFx();
break;
case CMD_NEXT:
controller->selectNextFx();
break;
}
}
public:
SonyRemote_RMD420(Controller *controller) : IRRemote(controller) {};
};
#endif