Skip to content

Commit 46f3190

Browse files
committed
Improved ir_DistanceProtocol
1 parent f58d23d commit 46f3190

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,13 @@ For applications only requiring NEC protocol, there is a receiver which has very
123123

124124
# Handling unknown Protocols
125125
## Disclaimer
126-
This library was never designed to handle long codes like the ones used by air conditioners.
127-
See [Recording long Infrared Remote control signals with Arduino](https://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino).<br/>
126+
**This library was never designed to handle long codes like the ones used by air conditioners.**<br/>
127+
For air condioners [see this fork](https://github.com/crankyoldgit/IRremoteESP8266) which supports an impressive set of protocols and a lot of air conditioners and the blog entry: ["Recording long Infrared Remote control signals with Arduino"](https://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino).<br/>
128128
The main reason is, that it was designed to fit inside MCUs with relatively low levels of resources and was intended to work as a library together with other applications which also require some resources of the MCU to operate.
129129

130+
## Protocol=PULSE_DISTANCE
131+
If you get something like this: `PULSE_DISTANCE: HeaderMarkMicros=8900 HeaderSpaceMicros=4450 MarkMicros=550 OneSpaceMicros=1700 ZeroSpaceMicros=600 NumberOfBits=56 0x43D8613C 0x3BC3BC`, then you have a code consisting of **56 bits**, which is probably from an air condioner remote. You can send it with calling sendPulseDistanceWidthData() twice, once for the first 32 bit and next for the remaining 24 bits.
132+
130133
## Protocol=UNKNOWN
131134
If you see something like `Protocol=UNKNOWN Hash=0x13BD886C 35 bits received` as output of e.g. the ReceiveDemo example, you either have a problem with decoding a protocol, or an unsupported protocol.
132135

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ The latest version may not be released!
33
See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-IRremote/commits/master
44

55
## 3.4.1
6+
- Improved ir_DistanceProtocol.
67

78
## 3.4.0
89
- Added LG2 protocol.

src/ir_DistanceProtocol.cpp

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ bool IRrecv::decodeDistance() {
218218
return false;
219219
}
220220
if (i == 0) {
221-
// Print protocol timing only once
221+
// Print protocol timing and length only once
222222
INFO_PRINTLN();
223223
INFO_PRINT(F("PULSE_WIDTH:"));
224224
INFO_PRINT(F(" HeaderMarkMicros="));
@@ -230,16 +230,18 @@ bool IRrecv::decodeDistance() {
230230
INFO_PRINT(F(" ZeroMarkMicros="));
231231
INFO_PRINT(tMarkTicksShort * MICROS_PER_TICK);
232232
INFO_PRINT(F(" SpaceMicros="));
233-
INFO_PRINTLN(tSpaceTicksShort * MICROS_PER_TICK);
234-
}
235-
if (tNumberOfAdditionalLong > 0) {
236-
// print only if we have more than 32 bits for decode
237-
INFO_PRINT(F(" 0x"));
238-
INFO_PRINT(decodedIRData.decodedRawData, HEX);
239-
tStartIndex += 64;
240-
tNumberOfBits -= 32;
233+
INFO_PRINT(tSpaceTicksShort * MICROS_PER_TICK);
234+
INFO_PRINT(F(" NumberOfBits="));
235+
INFO_PRINT(decodedIRData.numberOfBits);
236+
INFO_PRINT(F(" DecodedRawData:"));
237+
241238
}
239+
INFO_PRINT(F(" 0x"));
240+
INFO_PRINT(decodedIRData.decodedRawData, HEX);
241+
tStartIndex += 64;
242+
tNumberOfBits -= 32;
242243
}
244+
INFO_PRINTLN();
243245

244246
// Store ticks used for decoding in extra
245247
decodedIRData.extra = (tMarkTicksShort << 8) | tMarkTicksLong;
@@ -252,6 +254,9 @@ bool IRrecv::decodeDistance() {
252254
// tNumberOfBits++;
253255
// }
254256

257+
/*
258+
* Decode in 32 bit chunks
259+
*/
255260
for (uint8_t i = 0; i <= tNumberOfAdditionalLong; ++i) {
256261
uint8_t tNumberOfBitsForOneDecode = tNumberOfBits;
257262
if (tNumberOfBitsForOneDecode > 32) {
@@ -276,16 +281,17 @@ bool IRrecv::decodeDistance() {
276281
INFO_PRINT(F(" OneSpaceMicros="));
277282
INFO_PRINT(tSpaceTicksLong * MICROS_PER_TICK);
278283
INFO_PRINT(F(" ZeroSpaceMicros="));
279-
INFO_PRINTLN(tSpaceTicksShort * MICROS_PER_TICK);
280-
}
281-
if (tNumberOfAdditionalLong > 0) {
282-
// print only if we have more than 32 bits for decode
283-
INFO_PRINT(F(" 0x"));
284-
INFO_PRINT(decodedIRData.decodedRawData, HEX);
285-
tStartIndex += 64;
286-
tNumberOfBits -= 32;
284+
INFO_PRINT(tSpaceTicksShort * MICROS_PER_TICK);
285+
INFO_PRINT(F(" NumberOfBits="));
286+
INFO_PRINT(decodedIRData.numberOfBits);
287+
INFO_PRINT(F(" DecodedRawData:"));
287288
}
289+
INFO_PRINT(F(" 0x"));
290+
INFO_PRINT(decodedIRData.decodedRawData, HEX);
291+
tStartIndex += 64;
292+
tNumberOfBits -= 32;
288293
}
294+
INFO_PRINTLN();
289295
}
290296

291297
// Store ticks used for decoding in extra

0 commit comments

Comments
 (0)