Skip to content

Commit 61f00b8

Browse files
committed
Update IRrecvDumpV2.ino
Fixed presentation & 2 bugs. Presentation: No longer display leading space in timings, as is confusing to users & essentially irrelevant. Bug Fix 1: rawData was starting with a space & would not work with sendRaw Bug Fix 2: chaned x from unsigned int to nsigend long to avoid potential overflow on integer multiplication. very similar to recent changes to IRrecDump #167 Arduino-IRremote#207
1 parent bd72084 commit 61f00b8

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

examples/IRrecvDumpV2/IRrecvDumpV2.ino

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//------------------------------------------------------------------------------
77
// Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
88
//
9-
int recvPin = 6;
9+
int recvPin = 11;
1010
IRrecv irrecv(recvPin);
1111

1212
//+=============================================================================
@@ -92,10 +92,9 @@ void dumpRaw (decode_results *results)
9292
Serial.print("Timing[");
9393
Serial.print(results->rawlen, DEC);
9494
Serial.println("]: ");
95-
Serial.print(" -");
96-
Serial.println(results->rawbuf[0] * USECPERTICK, DEC);
95+
9796
for (int i = 1; i < results->rawlen; i++) {
98-
unsigned int x = results->rawbuf[i] * USECPERTICK;
97+
unsigned long x = results->rawbuf[i] * USECPERTICK;
9998
if (!(i & 1)) { // even
10099
Serial.print("-");
101100
if (x < 1000) Serial.print(" ") ;
@@ -109,7 +108,7 @@ void dumpRaw (decode_results *results)
109108
Serial.print(x, DEC);
110109
Serial.print(", ");
111110
}
112-
if (!(i%8)) Serial.println("");
111+
if (!(i % 8)) Serial.println("");
113112
}
114113
Serial.println(""); // Newline
115114
}
@@ -126,10 +125,10 @@ void dumpCode (decode_results *results)
126125
Serial.print("] = {"); // Start declaration
127126

128127
// Dump data
129-
for (int i = 0; i < results->rawlen; i++) {
128+
for (int i = 1; i < results->rawlen; i++) {
130129
Serial.print(results->rawbuf[i] * USECPERTICK, DEC);
131130
Serial.print(",");
132-
if (!(i&1)) Serial.print(" ");
131+
if (!(i & 1)) Serial.print(" ");
133132
}
134133

135134
// End declaration
@@ -143,17 +142,17 @@ void dumpCode (decode_results *results)
143142

144143
// Newline
145144
Serial.println("");
146-
145+
147146
// Now dump "known" codes
148147
if (results->decode_type != UNKNOWN) {
149-
148+
150149
// Some protocols have an address
151150
if (results->decode_type == PANASONIC) {
152151
Serial.print("unsigned int addr = 0x");
153152
Serial.print(results->address, HEX);
154153
Serial.println(";");
155154
}
156-
155+
157156
// All protocols have data
158157
Serial.print("unsigned int data = 0x");
159158
Serial.print(results->value, HEX);
@@ -166,14 +165,13 @@ void dumpCode (decode_results *results)
166165
//
167166
void loop ( )
168167
{
169-
decode_results results; // Somewhere to store the results
170-
171-
if (irrecv.decode(&results)) { // Grab an IR code
172-
dumpInfo(&results); // Output the results
173-
dumpRaw(&results); // Output the results in RAW format
174-
dumpCode(&results); // Output the results as source code
175-
Serial.println(""); // Blank line between entries
176-
irrecv.resume(); // Prepare for the next value
177-
}
168+
decode_results results; // Somewhere to store the results
169+
170+
if (irrecv.decode(&results)) { // Grab an IR code
171+
dumpInfo(&results); // Output the results
172+
dumpRaw(&results); // Output the results in RAW format
173+
dumpCode(&results); // Output the results as source code
174+
Serial.println(""); // Blank line between entries
175+
irrecv.resume(); // Prepare for the next value
176+
}
178177
}
179-

0 commit comments

Comments
 (0)