Skip to content

Commit f2e5fd2

Browse files
committed
Update ir_receiver to use IRremote 4.x API
- Migrate from old IRremote 2.x API to 4.x API for consistency - Change include from <IRremote.h> to <IRremote.hpp> - Use IrReceiver global object instead of IRrecv class - Update decode() method and data access patterns - Convert rawbuf values using MICROS_PER_TICK for correct timing - Update dump() function to use new API and IrSender naming This fixes CI build failures by ensuring both sketches use the same IRremote library version (4.1.2). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 87f4a19 commit f2e5fd2

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

ac_control/ir_receiver/ir_receiver.ino

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,63 @@
1-
#define sprint Serial.print
1+
#define sprint Serial.print
22
#define sprintln Serial.println
3-
#include <IRremote.h>
3+
#include <IRremote.hpp> // IRremote 4.1.2 from Library Manager
44
int RECV_PIN = 11;
55

6-
7-
IRrecv irrecv(RECV_PIN);
8-
9-
10-
decode_results results;
6+
unsigned long timeBegin;
117
int c = 1;
12-
unsigned long timeBegin;
8+
139
void setup()
1410
{
1511
Serial.begin(9600);
16-
irrecv.enableIRIn(); // Start the receiver
12+
IrReceiver.begin(RECV_PIN, ENABLE_LED_FEEDBACK); // Start the receiver
1713
timeBegin = micros();
18-
1914
}
2015

2116
void loop() {
22-
23-
24-
if (irrecv.decode(&results)) {
25-
dump(&results);
17+
if (IrReceiver.decode()) {
18+
dump();
2619
// ========
27-
Serial.println(results.value, HEX);
20+
Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);
2821
Serial.print("rawlen ");
29-
Serial.println(results.rawlen);
22+
Serial.println(IrReceiver.decodedIRData.rawDataPtr->rawlen);
3023
Serial.print("decode type ");
31-
Serial.println(results.decode_type);
24+
Serial.println(IrReceiver.decodedIRData.protocol);
3225

3326
unsigned long timeEnd = micros();
3427
unsigned long duration = timeEnd - timeBegin;
3528
double averageDuration = (double)duration / 1000.0;
3629
Serial.println(averageDuration);
37-
// if(results.value==0xA1026EFF) {
30+
// if(IrReceiver.decodedIRData.decodedRawData==0xA1026EFF) {
3831
// Serial.println("turning off");
3932
// }
40-
irrecv.resume(); // Receive the next value
41-
33+
IrReceiver.resume(); // Receive the next value
4234
}
4335
}
4436

45-
void dump(decode_results *results) {
46-
int count = results->rawlen;
37+
void dump() {
38+
int count = IrReceiver.decodedIRData.rawDataPtr->rawlen;
4739
sprintln(c);
4840
c++;
4941
sprintln("For IR Scope: ");
5042
for (int i = 1; i < count; i++) {
5143
sprint("0x");
52-
sprint((unsigned int)results->rawbuf[i], HEX);
44+
sprint((unsigned int)IrReceiver.decodedIRData.rawDataPtr->rawbuf[i] * MICROS_PER_TICK, HEX);
5345
sprint(" ");
5446
}
5547

5648
sprintln("");
5749
sprintln("For Arduino sketch: ");
58-
sprint("unsigned int raw[");
50+
sprint("uint16_t raw[");
5951
sprint(count, DEC);
6052
sprint("] = {");
6153
for (int i = 1; i < count; i++) {
6254
sprint("0x");
63-
sprint((unsigned int)results->rawbuf[i], HEX);
55+
sprint((unsigned int)IrReceiver.decodedIRData.rawDataPtr->rawbuf[i] * MICROS_PER_TICK, HEX);
6456
sprint(",");
6557
}
6658
sprint("};");
6759
sprintln("");
68-
sprint("irsend.sendRaw(raw,");
60+
sprint("IrSender.sendRaw(raw,");
6961
sprint(count, DEC);
7062
sprint(",38);");
7163
sprintln("");

0 commit comments

Comments
 (0)