-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathg_IRremote.ino
68 lines (58 loc) · 1.32 KB
/
g_IRremote.ino
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
// IR remote controller
#ifdef USE_IR_REMOTE
IRrecv irrecv(IRRECV_PIN);
decode_results results;
boolean powerStatus = false;
void IRcommand()
{
// Example values are from the accessory controller of
// DFRobot Digital IR Receiver Module (Arduino), DFR0094
// ( http://www.dfrobot.com/index.php?route=product/product&product_id=351 )
switch (results.value) {
case 0xFD00FF: // power
// surprisingly it is difficult to tell the camera is ON or OFF, so we just toggle.
if (powerStatus) {
queueIn(F("PW0")); // SET_CAMERA_POWER_STATE off
} else {
powerOn();
}
powerStatus = !powerStatus;
break;
case 0xFD08F7: // 1 key
startRecording();
break;
case 0xFD30CF: // 0 key
stopRecording();
break;
case 0xFD40BF: // func/stop key
roleChange(); // role change
break;
case 0xFFFFFFFF: // previous key repeated
break;
default: // unsupported controller key depressed
__debug(F("IR: "));
if (debug) {
Serial_println(results.value, HEX);
}
break;
}
}
void setupIRremote()
{
irrecv.enableIRIn();
}
void checkIRremote()
{
if (irrecv.decode(&results)) {
IRcommand();
irrecv.resume(); // Receive the next value
}
}
#else
void setupIRremote()
{
}
void checkIRremote()
{
}
#endif