Skip to content

Commit fff3d94

Browse files
committed
Added universal decoder for pulse width or pulse distance protocols
1 parent 1c7fc01 commit fff3d94

21 files changed

+296
-25
lines changed

.github/workflows/LibraryBuild.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,23 @@ jobs:
109109
- arduino-boards-fqbn: digistump:avr:digispark-tiny:clock=clock1
110110
platform-url: https://raw.githubusercontent.com/ArminJo/DigistumpArduino/master/package_digistump_index.json
111111
required-libraries: ATtinySerialOut
112-
sketches-exclude: UnitTest,ControlRelay,ReceiveAndSend,ReceiveDump,SendProntoDemo,SendBoseWaveDemo,MicroGirs,IRDispatcherDemo,SendLGAirConditionerDemo,ReceiverTimingAnalysis # Does not fit in FLASH or RAM, missing digitalPinToInterrupt
112+
sketches-exclude: UnitTest,ControlRelay,ReceiveAndSend,ReceiveDump,SendProntoDemo,SendBoseWaveDemo,MicroGirs,IRDispatcherDemo,SendLGAirConditionerDemo,ReceiverTimingAnalysis,IRremoteExtensionTest # Does not fit in FLASH or RAM, missing digitalPinToInterrupt
113113
build-properties: # the flags were put in compiler.cpp.extra_flags
114-
All: -DEXCLUDE_EXOTIC_PROTOCOLS
114+
All: -DEXCLUDE_EXOTIC_PROTOCOLS -DEXCLUDE_UNIVERSAL_PROTOCOLS
115115

116116
- arduino-boards-fqbn: digistump:avr:MHETtiny88 # ATtiny88 China clone board @16 MHz
117117
platform-url: https://raw.githubusercontent.com/ArminJo/DigistumpArduino/master/package_digistump_index.json
118118
required-libraries: ATtinySerialOut
119119
sketches-exclude: UnitTest,ControlRelay,ReceiveAndSend,ReceiveDump,SendProntoDemo,SendBoseWaveDemo,MicroGirs,IRDispatcherDemo,SendLGAirConditionerDemo,ReceiverTimingAnalysis,IRremoteExtensionTest # Does not fit in FLASH or RAM, missing digitalPinToInterrupt
120120
build-properties: # the flags were put in compiler.cpp.extra_flags
121-
All: -DEXCLUDE_EXOTIC_PROTOCOLS
121+
All: -DEXCLUDE_EXOTIC_PROTOCOLS -DEXCLUDE_UNIVERSAL_PROTOCOLS
122122

123123
- arduino-boards-fqbn: ATTinyCore:avr:attinyx5:chip=85,clock=1internal
124124
platform-url: http://drazzy.com/package_drazzy.com_index.json
125125
required-libraries: ATtinySerialOut
126126
sketches-exclude: UnitTest,ReceiveAndSend,ReceiveDump,SendProntoDemo,SendBoseWaveDemo,MicroGirs,IRDispatcherDemo,SendLGAirConditionerDemo,ReceiverTimingAnalysis # Does not fit in FLASH or RAM
127127
build-properties: # the flags were put in compiler.cpp.extra_flags
128-
All: -DEXCLUDE_EXOTIC_PROTOCOLS
128+
All: -DEXCLUDE_EXOTIC_PROTOCOLS -DEXCLUDE_UNIVERSAL_PROTOCOLS
129129

130130
- arduino-boards-fqbn: TinyCore:avr:tiny32
131131
platform-url: https://raw.githubusercontent.com/xukangmin/TinyCore/master/avr/package/package_tinycore_index.json

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# IRremote Arduino Library
22
Available as Arduino library "IRremote"
33

4-
### [Version 3.2.1](https://github.com/Arduino-IRremote/Arduino-IRremote/archive/master.zip) - work in progress
4+
### [Version 3.3.0](https://github.com/Arduino-IRremote/Arduino-IRremote/archive/master.zip) - work in progress
55

66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
77
[![Commits since latest](https://img.shields.io/github/commits-since/Arduino-IRremote/Arduino-IRremote/latest)](https://github.com/Arduino-IRremote/Arduino-IRremote/commits/master)
@@ -122,6 +122,7 @@ If you see something like `Protocol=UNKNOWN Hash=0x13BD886C 35 bits received` as
122122
- If you have an **odd number of bits** received, it is likely, that your receiver circuit has problems. Maybe because the IR signal is too weak.
123123
- If you see timings like `+ 600,- 600 + 550,- 150 + 200,- 100 + 750,- 550` then one 450 µs space was split into two 150 and 100 µs spaces with a spike / error signal of 200 µs between. Maybe because of a defective receiver or a weak signal in conjunction with another light emitting source nearby.
124124
- If you see timings like `+ 500,- 550 + 450,- 550 + 500,- 500 + 500,-1550`, then marks are generally shorter than spaces and therefore `MARK_EXCESS_MICROS` (specified in your ino file) should be **negative** to compensate for this at decoding.
125+
- If you see rawData[2] it may be that the space after the initial mark is longer than [`RECORD_GAP_MICROS`](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremote.h#L127). This was observed for some LG air conditioner protocols. Try again with a line e.g. `#define RECORD_GAP_MICROS 12000` before `#include <IRremote.h>` in yout ino file.
125126
- To see more info supporting you to find the reason for your UNKNOWN protocol, you must enable the line `//#define DEBUG` in IRremoteInt.h.
126127

127128
## How to deal with protocols not supported by IRremote
@@ -178,8 +179,10 @@ Modify it by commenting them out or in, or change the values if applicable. Or d
178179
|-|-|-|-|
179180
| `SEND_PWM_BY_TIMER` | Before `#include <IRremote.h>` | disabled | Disable carrier PWM generation in software and use (restricted) hardware PWM except for ESP32 where both modes are using the flexible `hw_timer_t`. |
180181
| `USE_NO_SEND_PWM` | Before `#include <IRremote.h>` | disabled | Use no carrier PWM, just simulate an active low receiver signal. Overrides `SEND_PWM_BY_TIMER` definition. |
182+
| `RECORD_GAP_MICROS` | Before `#include <IRremote.h>` | 5000 | Minimum gap between IR transmissions, to detect the end of a protocol.<br/>Must be greater than any space of a protocol e.g. the NEC header space of 4500 us.<br/>Must be smaller than any gap between a command and a repeat e.g. the retransmission gap for Sony is around 24 ms.<br/>Keep in mind that this is the delay between the end of the received command and the start of decoding. |
181183
| `NO_LEGACY_COMPATIBILITY` | IRremoteInt.h | disabled | Disables the old decoder for version 2.x compatibility, where all protocols -especially NEC, Panasonic, Sony, Samsung and JVC- were MSB first. Saves around 60 bytes program space and 14 bytes RAM. |
182184
| `EXCLUDE_EXOTIC_PROTOCOLS` | Before `#include <IRremote.h>` | disabled | If activated, BOSEWAVE, MAGIQUEST,WHYNTER and LEGO_PF are excluded in `decode()` and in sending with `IrSender.write()`. Saves up to 900 bytes program space. |
185+
| `EXCLUDE_UNIVERSAL_PROTOCOLS` | Before `#include <IRremote.h>` | disabled | If activated, the universal decoder for pulse width or pulse distance protocols and decodeHash (special decoder for all protocols) are excluded in `decode()`. Saves up to 1000 bytes program space. |
183186
| `MARK_EXCESS_MICROS` | Before `#include <IRremote.h>` | 20 | MARK_EXCESS_MICROS is subtracted from all marks and added to all spaces before decoding, to compensate for the signal forming of different IR receiver modules. |
184187
| `FEEDBACK_LED_IS_ACTIVE_LOW` | Before `#include <IRremote.h>` | disabled | Required on some boards (like my BluePill and my ESP8266 board), where the feedback LED is active low. |
185188
| `DISABLE_LED_FEEDBACK_FOR_RECEIVE` | Before `#include <IRremote.h>` | disabled | This completely disables the LED feedback code for receive, thus saving around 108 bytes program space and halving the receiver ISR processing time. |

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Changelog
22
The latest version may not be released!
3-
## 3.2.1
3+
## 3.3.0
44
- Fix errors if LED_BUILTIN is not defined.
55
- Fixed error for AVR timer1. Thanks to alexbarcelo.
66
- New example IRremoteExtensionTest.
77
- Enabled megaAVR 0-series devices.
8+
- Added universal decoder for pulse width or pulse distance protocols.
89

910
## 3.2.0
1011
- Fix for ESP32 send Error, removed `USE_SOFT_SEND_PWM` macro.

examples/ReceiveDemo/ReceiveDemo.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
//#define DISABLE_LED_FEEDBACK_FOR_RECEIVE // saves 108 bytes program space
4646
#if FLASHEND <= 0x1FFF
4747
#define EXCLUDE_EXOTIC_PROTOCOLS
48+
#define EXCLUDE_UNIVERSAL_PROTOCOLS
4849
#endif
4950
//#define EXCLUDE_EXOTIC_PROTOCOLS // saves around 670 bytes program space if all other protocols are active
5051
//#define IR_MEASURE_TIMING
@@ -53,6 +54,9 @@
5354
// to compensate for the signal forming of different IR receiver modules.
5455
#define MARK_EXCESS_MICROS 20 // 20 is recommended for the cheap VS1838 modules
5556

57+
//#define DEBUG // Activate this for lots of lovely debug outputs.
58+
//#define RECORD_GAP_MICROS 12000 // Activate it for some LG air conditioner protocols
59+
5660
/*
5761
* First define macros for input and output pin etc.
5862
*/

examples/ReceiveDump/ReceiveDump.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
*/
4646
#define MARK_EXCESS_MICROS 20 // recommended for the cheap VS1838 modules
4747

48+
//#define DEBUG // Activate this for lots of lovely debug outputs.
49+
//#define RECORD_GAP_MICROS 12000 // Activate it for some LG air conditioner protocols
4850
#include <IRremote.h>
4951

5052
//+=============================================================================

examples/SimpleReceiver/SimpleReceiver.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
//#define DECODE_MAGIQUEST
3232
//#define DECODE_WHYNTER
3333

34+
//#define DECODE_DISTANCE // universal decoder for pulse width or pulse distance protocols
3435
//#define DECODE_HASH // special decoder for all protocols
3536

3637
#include <Arduino.h>

examples/UnitTest/UnitTest.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#define DECODE_SAMSUNG
5656
#define DECODE_LG
5757

58+
#define DECODE_DISTANCE // universal decoder for pulse width or pulse distance protocols
5859
#define DECODE_HASH // special decoder for all protocols
5960
#endif
6061

@@ -69,6 +70,7 @@
6970
//#define SEND_PWM_BY_TIMER
7071
//#define USE_NO_SEND_PWM
7172
//#define IR_MEASURE_TIMING
73+
//#define DEBUG // Activate this for lots of lovely debug outputs.
7274
#define MARK_EXCESS_MICROS 10 // Adapt it to your IR receiver module. See also IRremote.h.
7375
#define DISABLE_LED_FEEDBACK_FOR_RECEIVE // halves ISR duration
7476

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=IRremote
2-
version=3.2.0
2+
version=3.3.0
33
author=shirriff, z3t0 <[email protected]>, ArminJo
44
maintainer=Armin Joachimsmeyer <[email protected]>
55
sentence=Send and receive infrared signals with multiple protocols
6-
paragraph=Currently included protocols: Denon / Sharp, JVC, LG, NEC / Onkyo / Apple, Panasonic / Kaseikyo, RC5, RC6, Samsung, Sony, (Pronto), BoseWave, Lego, Whynter, MagiQuest.<br/><br/><b>New: </b><a href="https://github.com/Arduino-IRremote/Arduino-IRremote#converting-your-program-to-the-31-version">Upgrade instructions</a><br/>Fixed ESP send bug. Added Onkyo protocol. Added ESP8266 support.<br/>Generation of PWM is now done by software by default, thus saving the hardware timer and enabling abitrary output pins. Fixed LG send bug. STM32 and ATtiny88 support added. Removed decode_results results. Renamed most irparams_struct values. The macros FEEDBACK_LED, SYSCLOCK, SENDPIN_ON and SENDPIN_OFF are not longer used / evaluated. Major refactoring of CPU dependent and feedback LED code.<br/>
6+
paragraph=Currently included protocols: Denon / Sharp, JVC, LG, NEC / Onkyo / Apple, Panasonic / Kaseikyo, RC5, RC6, Samsung, Sony, (Pronto), BoseWave, Lego, Whynter, MagiQuest.<br/><br/><b>New: </b><a href="https://github.com/Arduino-IRremote/Arduino-IRremote#converting-your-program-to-the-31-version">3.x upgrade instructions</a><br/>Added universal decoder for pulse width or pulse distance protocols.<br/>For all 3.x: Generation of PWM is now done by software by default, thus saving the hardware timer and enabling abitrary output pins. Removed decode_results results. Renamed most irparams_struct values. The macros FEEDBACK_LED, SYSCLOCK, SENDPIN_ON and SENDPIN_OFF are not longer used / evaluated. Major refactoring of CPU dependent and feedback LED code. Support for more CPU's.<br/>
77
category=Communication
88
url=https://github.com/Arduino-IRremote/Arduino-IRremote
99
architectures=avr,megaavr,samd,esp8266,esp32,mbed,stm32,STM32F1

src/IRProtocol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ typedef enum {
5656
SONY,
5757
ONKYO,
5858
APPLE,
59+
PULSE_DISTANCE,
60+
PULSE_WIDTH,
5961
BOSEWAVE,
6062
LEGO_PF,
6163
MAGIQUEST,

src/IRReceive.cpp.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,16 @@ bool IRrecv::decode() {
350350
}
351351
#endif
352352

353+
/*
354+
* Try the universal decoder for pulse width or pulse distance protocols
355+
*/
356+
#if defined(DECODE_DISTANCE)
357+
TRACE_PRINTLN("Attempting universal Distance decode");
358+
if (decodeDistance()) {
359+
return true;
360+
}
361+
#endif
362+
353363
/*
354364
* Last resort is the universal hash decode which always return true
355365
*/
@@ -373,7 +383,7 @@ bool IRrecv::decode() {
373383
* Common decode functions
374384
**********************************************************************************************************************/
375385
/**
376-
* Decode pulse width protocols.
386+
* Decode pulse width protocols. Currently only used for sony protocol.
377387
* The space (pause) has constant length, the length of the mark determines the bit value.
378388
* Each bit looks like: MARK_1 + SPACE -> 1 or : MARK_0 + SPACE -> 0
379389
*
@@ -1171,6 +1181,12 @@ const __FlashStringHelper* getProtocolString(decode_type_t aProtocol) {
11711181
case APPLE:
11721182
return (F("APPLE"));
11731183
break;
1184+
case PULSE_DISTANCE:
1185+
return (F("PULSE_DISTANCE"));
1186+
break;
1187+
case PULSE_WIDTH:
1188+
return (F("PULSE_WIDTH"));
1189+
break;
11741190
#if !defined(EXCLUDE_EXOTIC_PROTOCOLS)
11751191
case BOSEWAVE:
11761192
return (F("BOSEWAVE"));

0 commit comments

Comments
 (0)