-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMD_learn.ino
More file actions
58 lines (51 loc) · 1.63 KB
/
CMD_learn.ino
File metadata and controls
58 lines (51 loc) · 1.63 KB
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
void CMD_learn() {
unsigned long irCodes[5];
Serial.print(F("Press the key you want to assing to slot #"));
Serial.println(cOutput + 1);
unsigned int i = 0;
// read the IR codes
while (i < 5) {
if (myReceiver.getResults()) {
myDecoder.decode(); //Decode it
if ( myDecoder.value && (myDecoder.value < 0xFFFFFFFF)) {
if (cDevice.Debug) {
Serial.print(F("IR: received signal "));
Serial.print(F("[0x"));
Serial.print(myDecoder.value, HEX);
Serial.println(F("]"));
//myDecoder.dumpResults(true); //Now print results. Use false for less detail
myDecoder.dumpResults(false);
if (haveLCD) {
lcd.clear();//Clean the screen
lcd.setCursor(1, 0);
lcd.print(F("Received:"));
lcd.setCursor(0, 1);
lcd.print(F("[0x"));
lcd.print(myDecoder.value, HEX);
lcd.print(F("]"));
}
}
if (i) {
if (irCodes[i - 1] == myDecoder.value) {
irCodes[i] = myDecoder.value;
}
} else {
irCodes[i] = myDecoder.value;
}
}
Serial.print(F("["));
Serial.print(i);
Serial.print(F("] "));
i++;
}
myReceiver.enableIRIn(); //Restart receiver
}
// unsigned int cCmd = irCodes[0];
// unsigned int cPrefix = irCodes[0] >> 16;
// outputs[cOutput].vendorPrefixIR = cPrefix;
// outputs[cOutput].cmdIR = cCmd;
outputs[cOutput].vendorPrefixIR = irCodes[0] >> 16;
outputs[cOutput].cmdIR = irCodes[0];
outputs[cOutput].Protocol = myDecoder.protocolNum;
state_report();
}