Fixed sendSamsung() / sendSamsungLG() bug

Added functions stopTimer(), restartTimer() and restartTimerWithTicksToAdd()
Added rawlen and initialGap to IRData
Bumped version to 4.3.0
This commit is contained in:
Armin 2024-02-23 19:28:33 +01:00
parent ef69840a5f
commit 3930c4148a
35 changed files with 578 additions and 445 deletions

View File

@ -60,9 +60,9 @@ jobs:
- arduino:mbed:nano33ble
- arduino:mbed_rp2040:pico
- rp2040:rp2040:arduino_nano_connect
- ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
- ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
- ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
# - ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
# - ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
# - ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
- MegaCore:avr:128:bootloader=no_bootloader,eeprom=keep,BOD=2v7,LTO=Os_flto,clock=8MHz_internal # ATmega128
- SparkFun:avr:promicro
# - megaTinyCore:megaavr:atxy4:chip=1604,clock=16internal # https://github.com/SpenceKonde/megaTinyCore/issues/935
@ -193,26 +193,26 @@ jobs:
#
# ATTinyCore
#
- arduino-boards-fqbn: ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
platform-url: http://drazzy.com/package_drazzy.com_index.json
required-libraries: ATtinySerialOut
sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
build-properties: # the flags were put in compiler.cpp.extra_flags
SimpleSender: -DSEND_PWM_BY_TIMER
# - arduino-boards-fqbn: ATTinyCore:avr:attinyx5micr:LTO=enable,sketchclock=16pll
# platform-url: http://drazzy.com/package_drazzy.com_index.json
# required-libraries: ATtinySerialOut
# sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
# build-properties: # the flags were put in compiler.cpp.extra_flags
# SimpleSender: -DSEND_PWM_BY_TIMER
- arduino-boards-fqbn: ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
platform-url: http://drazzy.com/package_drazzy.com_index.json
required-libraries: ATtinySerialOut
sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
build-properties: # the flags were put in compiler.cpp.extra_flags
SimpleSender: -DSEND_PWM_BY_TIMER
# - arduino-boards-fqbn: ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
# platform-url: http://drazzy.com/package_drazzy.com_index.json
# required-libraries: ATtinySerialOut
# sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
# build-properties: # the flags were put in compiler.cpp.extra_flags
# SimpleSender: -DSEND_PWM_BY_TIMER
- arduino-boards-fqbn: ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
platform-url: http://drazzy.com/package_drazzy.com_index.json
required-libraries: ATtinySerialOut
sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
build-properties: # the flags were put in compiler.cpp.extra_flags
SimpleSender: -DSEND_PWM_BY_TIMER
# - arduino-boards-fqbn: ATTinyCore:avr:attinyx8micr:LTO=enable,sketchclock=16external,pinmapping=mhtiny,millis=enabled # ATtiny88 China clone board @16 MHz
# platform-url: http://drazzy.com/package_drazzy.com_index.json
# required-libraries: ATtinySerialOut
# sketch-names: TinyReceiver.ino,IRremoteInfo.ino,SimpleReceiver.ino,ReceiveDemo.ino,ControlRelay.ino,SimpleSender.ino,SendDemo.ino,SendRawDemo.ino,SendAndReceive.ino
# build-properties: # the flags were put in compiler.cpp.extra_flags
# SimpleSender: -DSEND_PWM_BY_TIMER
#
# MegaCore

131
README.md
View File

@ -30,56 +30,56 @@ Available as [Arduino library "IRremote"](https://www.arduinolibraries.info/libr
</div>
# Overview
- [Supported IR Protocols](https://github.com/Arduino-IRremote/Arduino-IRremote#supported-ir-protocols)
- [Features](https://github.com/Arduino-IRremote/Arduino-IRremote#features)
* [New features with version 4.x](https://github.com/Arduino-IRremote/Arduino-IRremote#new-features-with-version-4x)
* [New features with version 3.x](https://github.com/Arduino-IRremote/Arduino-IRremote#new-features-with-version-3x)
- [Converting your 2.x program to the 4.x version](https://github.com/Arduino-IRremote/Arduino-IRremote#converting-your-2x-program-to-the-4x-version)
* [How to convert old MSB first 32 bit IR data codes to new LSB first 32 bit IR data codes](https://github.com/Arduino-IRremote/Arduino-IRremote#how-to-convert-old-msb-first-32-bit-ir-data-codes-to-new-lsb-first-32-bit-ir-data-codes)
- [Errors with using the 3.x versions for old tutorials](https://github.com/Arduino-IRremote/Arduino-IRremote#errors-with-using-the-3x-versions-for-old-tutorials)
* [Staying on 2.x](https://github.com/Arduino-IRremote/Arduino-IRremote#staying-on-2x)
- [Why *.hpp instead of *.cpp](https://github.com/Arduino-IRremote/Arduino-IRremote#why-hpp-instead-of-cpp)
- [Using the new *.hpp files](https://github.com/Arduino-IRremote/Arduino-IRremote#using-the-new-hpp-files)
- [Receiving IR codes](https://github.com/Arduino-IRremote/Arduino-IRremote#receiving-ir-codes)
* [decodedIRData structure](https://github.com/Arduino-IRremote/Arduino-IRremote#decodedirdata-structure)
* [Ambiguous protocols](https://github.com/Arduino-IRremote/Arduino-IRremote#ambiguous-protocols)
* [Unknown protocol](https://github.com/Arduino-IRremote/Arduino-IRremote#unknown-protocol)
- [Sending IR codes](https://github.com/Arduino-IRremote/Arduino-IRremote#sending-ir-codes)
* [Send pin](https://github.com/Arduino-IRremote/Arduino-IRremote#send-pin)
+ [List of public IR code databases](https://github.com/Arduino-IRremote/Arduino-IRremote#list-of-public-ir-code-databases)
- [Tiny NEC receiver and sender](https://github.com/Arduino-IRremote/Arduino-IRremote#tiny-nec-receiver-and-sender)
- [The FAST protocol](https://github.com/Arduino-IRremote/Arduino-IRremote#the-fast-protocol)
- [FAQ and hints](https://github.com/Arduino-IRremote/Arduino-IRremote#faq-and-hints)
* [Problems with Neopixels, FastLed etc.](https://github.com/Arduino-IRremote/Arduino-IRremote#problems-with-neopixels-fastled-etc)
* [Does not work/compile with another library](https://github.com/Arduino-IRremote/Arduino-IRremote#does-not-workcompile-with-another-library)
* [Multiple IR receiver](https://github.com/Arduino-IRremote/Arduino-IRremote#multiple-ir-receiver)
* [Increase strength of sent output signal](https://github.com/Arduino-IRremote/Arduino-IRremote#increase-strength-of-sent-output-signal)
* [Minimal CPU clock frequency](https://github.com/Arduino-IRremote/Arduino-IRremote#minimal-cpu-clock-frequency)
* [Bang & Olufsen protocol](https://github.com/Arduino-IRremote/Arduino-IRremote#bang--olufsen-protocol)
- [Handling unknown Protocols](https://github.com/Arduino-IRremote/Arduino-IRremote#handling-unknown-protocols)
* [Disclaimer](https://github.com/Arduino-IRremote/Arduino-IRremote#disclaimer)
* [Protocol=PULSE_DISTANCE](https://github.com/Arduino-IRremote/Arduino-IRremote#protocolpulse_distance)
* [Protocol=UNKNOWN](https://github.com/Arduino-IRremote/Arduino-IRremote#protocolunknown)
* [How to deal with protocols not supported by IRremote](https://github.com/Arduino-IRremote/Arduino-IRremote#how-to-deal-with-protocols-not-supported-by-irremote)
- [Examples for this library](https://github.com/Arduino-IRremote/Arduino-IRremote#examples-for-this-library)
- [WOKWI online examples](https://github.com/Arduino-IRremote/Arduino-IRremote#wokwi-online-examples)
- [Issues and discussions](https://github.com/Arduino-IRremote/Arduino-IRremote#issues-and-discussions)
- [Compile options / macros for this library](https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library)
+ [Changing include (*.h) files with Arduino IDE](https://github.com/Arduino-IRremote/Arduino-IRremote#changing-include-h-files-with-arduino-ide)
+ [Modifying compile options with Sloeber IDE](https://github.com/Arduino-IRremote/Arduino-IRremote#modifying-compile-options--macros-with-sloeber-ide)
- [Supported Boards](https://github.com/Arduino-IRremote/Arduino-IRremote#supported-boards)
- [Timer and pin usage](https://github.com/Arduino-IRremote/Arduino-IRremote#timer-and-pin-usage)
* [Incompatibilities to other libraries and Arduino commands like tone() and analogWrite()](https://github.com/Arduino-IRremote/Arduino-IRremote#incompatibilities-to-other-libraries-and-arduino-commands-like-tone-and-analogwrite)
* [Hardware-PWM signal generation for sending](https://github.com/Arduino-IRremote/Arduino-IRremote#hardware-pwm-signal-generation-for-sending)
* [Why do we use 30% duty cycle for sending](https://github.com/Arduino-IRremote/Arduino-IRremote#why-do-we-use-30-duty-cycle-for-sending)
- [How we decode signals](https://github.com/Arduino-IRremote/Arduino-IRremote#how-we-decode-signals)
- [NEC encoding diagrams](https://github.com/Arduino-IRremote/Arduino-IRremote#nec-encoding-diagrams)
- [Quick comparison of 5 Arduino IR receiving libraries](https://github.com/Arduino-IRremote/Arduino-IRremote#quick-comparison-of-5-arduino-ir-receiving-libraries)
- [Useful links](https://github.com/Arduino-IRremote/Arduino-IRremote#useful-links)
# Table of content
- [Supported IR Protocols](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#supported-ir-protocols)
- [Features](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#features)
* [New features with version 4.x](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#new-features-with-version-4x)
* [New features with version 3.x](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#new-features-with-version-3x)
- [Converting your 2.x program to the 4.x version](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#converting-your-2x-program-to-the-4x-version)
* [How to convert old MSB first 32 bit IR data codes to new LSB first 32 bit IR data codes](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#how-to-convert-old-msb-first-32-bit-ir-data-codes-to-new-lsb-first-32-bit-ir-data-codes)
- [Errors with using the 3.x versions for old tutorials](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#errors-with-using-the-3x-versions-for-old-tutorials)
* [Staying on 2.x](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#staying-on-2x)
- [Why *.hpp instead of *.cpp](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#why-hpp-instead-of-cpp)
- [Using the new *.hpp files](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#using-the-new-hpp-files)
- [Receiving IR codes](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#receiving-ir-codes)
* [decodedIRData structure](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#decodedirdata-structure)
* [Ambiguous protocols](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#ambiguous-protocols)
* [Unknown protocol](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#unknown-protocol)
- [Sending IR codes](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#sending-ir-codes)
* [Send pin](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#send-pin)
+ [List of public IR code databases](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#list-of-public-ir-code-databases)
- [Tiny NEC receiver and sender](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#tiny-nec-receiver-and-sender)
- [The FAST protocol](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#the-fast-protocol)
- [FAQ and hints](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#faq-and-hints)
* [Problems with Neopixels, FastLed etc.](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#problems-with-neopixels-fastled-etc)
* [Does not work/compile with another library](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#does-not-workcompile-with-another-library)
* [Multiple IR receiver](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#multiple-ir-receiver)
* [Increase strength of sent output signal](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#increase-strength-of-sent-output-signal)
* [Minimal CPU clock frequency](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#minimal-cpu-clock-frequency)
* [Bang & Olufsen protocol](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#bang--olufsen-protocol)
- [Handling unknown Protocols](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#handling-unknown-protocols)
* [Disclaimer](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#disclaimer)
* [Protocol=PULSE_DISTANCE](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#protocolpulse_distance)
* [Protocol=UNKNOWN](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#protocolunknown)
* [How to deal with protocols not supported by IRremote](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#how-to-deal-with-protocols-not-supported-by-irremote)
- [Examples for this library](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#examples-for-this-library)
- [WOKWI online examples](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#wokwi-online-examples)
- [Issues and discussions](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#issues-and-discussions)
- [Compile options / macros for this library](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#compile-options--macros-for-this-library)
+ [Changing include (*.h) files with Arduino IDE](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#changing-include-h-files-with-arduino-ide)
+ [Modifying compile options with Sloeber IDE](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#modifying-compile-options--macros-with-sloeber-ide)
- [Supported Boards](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#supported-boards)
- [Timer and pin usage](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#timer-and-pin-usage)
* [Incompatibilities to other libraries and Arduino commands like tone() and analogWrite()](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#incompatibilities-to-other-libraries-and-arduino-commands-like-tone-and-analogwrite)
* [Hardware-PWM signal generation for sending](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#hardware-pwm-signal-generation-for-sending)
* [Why do we use 30% duty cycle for sending](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#why-do-we-use-30-duty-cycle-for-sending)
- [How we decode signals](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#how-we-decode-signals)
- [NEC encoding diagrams](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#nec-encoding-diagrams)
- [Quick comparison of 5 Arduino IR receiving libraries](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#quick-comparison-of-5-arduino-ir-receiving-libraries)
- [Useful links](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#useful-links)
- [Contributors](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/Contributors.md)
- [License](https://github.com/Arduino-IRremote/Arduino-IRremote#license)
- [Copyright](https://github.com/Arduino-IRremote/Arduino-IRremote#copyright)
- [License](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#license)
- [Copyright](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#copyright)
<br/>
@ -110,9 +110,10 @@ Protocols can be switched off and on by defining macros before the line `#includ
- New universal **Pulse Distance / Pulse Width decoder** added, which covers many previous unknown protocols.
- Printout of code how to send received command by `IrReceiver.printIRSendUsage(&Serial)`.
- RawData type is now 64 bit for 32 bit platforms and therefore `decodedIRData.decodedRawData` can contain complete frame information for more protocols than with 32 bit as before.
- Callback after receiving a command - It calls your code as soon as a message was received.
- **Callback** after receiving a command - It calls your code as soon as a message was received.
- Improved handling of `PULSE_DISTANCE` + `PULSE_WIDTH` protocols.
- New FAST protocol.
- Automatic printout of the **corresponding send function** with printIRSendUsage().
#### Converting your 3.x program to the 4.x version
- You must replace `#define DECODE_DISTANCE` by `#define DECODE_DISTANCE_WIDTH` (only if you explicitly enabled this decoder).
@ -131,9 +132,9 @@ Protocols can be switched off and on by defining macros before the line `#includ
- Allows for the generation of non PWM signal to just **simulate an active low receiver signal** for direct connect to existent receiving devices without using IR.
- Easy protocol configuration, **directly in your [source code](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/examples/SimpleReceiver/SimpleReceiver.ino#L33-L57)**.<br/>
Reduces memory footprint and decreases decoding time.
- Contains a [very small NEC only decoder](https://github.com/Arduino-IRremote/Arduino-IRremote#minimal-nec-receiver), which **does not require any timer resource**.
- Contains a [very small NEC only decoder](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#minimal-nec-receiver), which **does not require any timer resource**.
[-> Feature comparison of 5 Arduino IR libraries](https://github.com/Arduino-IRremote/Arduino-IRremote#quick-comparison-of-5-arduino-ir-receiving-libraries).
[-> Feature comparison of 5 Arduino IR libraries](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#quick-comparison-of-5-arduino-ir-receiving-libraries).
<br/>
@ -155,7 +156,7 @@ If IR_SEND_PIN is not defined (before the line `#include <IRremote.hpp>`) you mu
- Seldom used: `results.rawbuf` and `results.rawlen` must be replaced by `IrReceiver.decodedIRData.rawDataPtr->rawbuf` and `IrReceiver.decodedIRData.rawDataPtr->rawlen`.
- The 5 protocols **NEC, Panasonic, Sony, Samsung and JVC** have been converted to LSB first. Send functions for sending old MSB data for **NEC** and **JVC** were renamed to `sendNECMSB`, and `sendJVCMSB()`. The old `sendSAMSUNG()` and `sendSony()` MSB functions are still available. The old MSB version of `sendPanasonic()` function was deleted, since it had bugs nobody recognized.<br/>
For converting MSB codes to LSB see [below](https://github.com/Arduino-IRremote/Arduino-IRremote#how-to-convert-old-msb-first-32-bit-ir-data-codes-to-new-lsb-first-32-bit-ir-data-codes).
For converting MSB codes to LSB see [below](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#how-to-convert-old-msb-first-32-bit-ir-data-codes-to-new-lsb-first-32-bit-ir-data-codes).
### Example
#### Old 2.x program:
@ -198,7 +199,6 @@ void setup()
void loop() {
if (IrReceiver.decode()) {
Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX); // Print "old" raw data
// USE NEW 3.x FUNCTIONS
IrReceiver.printIRResultShort(&Serial); // Print complete received data in one line
IrReceiver.printIRSendUsage(&Serial); // Print the statement required to send this data
...
@ -232,7 +232,7 @@ You may use `bitreverseOneByte()` or `bitreverse32Bit()` for this.
# Errors with using the 4.x versions for old tutorials
If you suffer from errors with old tutorial code including `IRremote.h` instead of `IRremote.hpp`, just try to rollback to [Version 2.4.0](https://github.com/Arduino-IRremote/Arduino-IRremote/releases/tag/v2.4.0).<br/>
Most likely your code will run and you will not miss the new features...
Most likely your code will run and you will not miss the new features.
<br/>
@ -367,11 +367,14 @@ Another way is to check if `IrReceiver.decodedIRData.protocol` is NEC and not ON
### NEC, NEC2
On a long press, the **NEC protocol** does not repeat its frame, it sends a special short repeat frame.
This enables an easy distinction between long presses and repeated presses and saves a bit of battery energy.
This behavior is quite unique for NEC and its derived protocols like LG.
This behavior is quite unique for NEC and its derived protocols like LG and Samsung.
So there are of course also remote control systems, which uses the NEC protocol but on a long press just repeat the first frame instead of sending the special short repeat frame. We named this the **NEC2** protocol and it is sent with `sendNEC2()`.<br/>
But of course there are also remote control systems, that uses the NEC protocol but only repeat the first frame when a long press is made instead of sending the special short repeat frame. We named this the **NEC2** protocol and it is sent with `sendNEC2()`.<br/>
But be careful, the NEC2 protocol can only be detected by the NEC library decoder **after** the first frame and if you do a long press!
### Samsung, SamsungLG
On a long press, the **SamsungLG protocol** does not repeat its frame, it sends a special short repeat frame.
## Unknown protocol
If your protocol seems not to be supported by this library, you may try the [IRMP library](https://github.com/IRMP-org/IRMP).
@ -401,7 +404,7 @@ The old send*Raw() functions for sending like e.g. `IrSender.sendNECRaw(0xE61957
## Send pin
Any pin can be choosen as send pin, because the PWM signal is generated by default with software bit banging, since `SEND_PWM_BY_TIMER` is not active.
If `IR_SEND_PIN` is specified (as c macro), it reduces program size and improves send timing for AVR. If you want to use a variable to specify send pin e.g. with `setSendPin(uint8_t aSendPinNumber)`, you must disable this `IR_SEND_PIN` macro. Then you can change send pin at any time before sending an IR frame. See also [Compile options / macros for this library](https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library).
If `IR_SEND_PIN` is specified (as c macro), it reduces program size and improves send timing for AVR. If you want to use a variable to specify send pin e.g. with `setSendPin(uint8_t aSendPinNumber)`, you must disable this `IR_SEND_PIN` macro. Then you can change send pin at any time before sending an IR frame. See also [Compile options / macros for this library](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#compile-options--macros-for-this-library).
### List of public IR code databases
http://www.harctoolbox.org/IR-resources.html
@ -423,7 +426,7 @@ http://www.harctoolbox.org/IR-resources.html
For applications only requiring NEC, NEC variants or FAST -see below- protocol, there is a special receiver / sender included,<br/>
which has very **small code size of 500 bytes and does NOT require any timer**.
Check out the [TinyReceiver](https://github.com/Arduino-IRremote/Arduino-IRremote#tinyreceiver--tinysender) and [IRDispatcherDemo](https://github.com/Arduino-IRremote/Arduino-IRremote#irdispatcherdemo) examples.<br/>
Check out the [TinyReceiver](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#tinyreceiver--tinysender) and [IRDispatcherDemo](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#irdispatcherdemo) examples.<br/>
Take care to include `TinyIRReceiver.hpp` or `TinyIRSender.hpp` instead of `IRremote.hpp`.
### TinyIRReceiver usage
@ -510,7 +513,7 @@ There are some other solutions to this on more powerful processors,
## Does not work/compile with another library
**Another library is only working/compiling** if you deactivate the line `IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);`.<br/>
This is often due to **timer resource conflicts** with the other library. Please see [below](https://github.com/Arduino-IRremote/Arduino-IRremote#timer-and-pin-usage).
This is often due to **timer resource conflicts** with the other library. Please see [below](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#timer-and-pin-usage).
## Multiple IR receivers
IRreceiver consists of one timer triggered function reading the digital IR signal value from one pin every 50 &micro;s.<br/>
@ -701,7 +704,7 @@ Modify them by enabling / disabling them, or change the values if applicable.
| `RECORD_GAP_MICROS` | 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 &micro;s.<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. |
| `IR_INPUT_IS_ACTIVE_HIGH` | disabled | Enable it if you use a RF receiver, which has an active HIGH output signal. |
| `IR_SEND_PIN` | disabled | If specified, it reduces program size and improves send timing for AVR. If you want to use a variable to specify send pin e.g. with `setSendPin(uint8_t aSendPinNumber)`, you must not use / disable this macro in your source. |
| `SEND_PWM_BY_TIMER` | disabled | Disables carrier PWM generation in software and use hardware PWM (by timer). Has the advantage of more exact PWM generation, especially the duty cycle (which is not very relevant for most IR receiver circuits), and the disadvantage of using a hardware timer, which in turn is not available for other libraries and to fix the send pin (but not the receive pin) at the [dedicated timer output pin(s)](https://github.com/Arduino-IRremote/Arduino-IRremote#timer-and-pin-usage). Is enabled for ESP32 and RP2040 in all examples, since they support PWM gereration for each pin without using a shared resource (timer). |
| `SEND_PWM_BY_TIMER` | disabled | Disables carrier PWM generation in software and use hardware PWM (by timer). Has the advantage of more exact PWM generation, especially the duty cycle (which is not very relevant for most IR receiver circuits), and the disadvantage of using a hardware timer, which in turn is not available for other libraries and to fix the send pin (but not the receive pin) at the [dedicated timer output pin(s)](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#timer-and-pin-usage). Is enabled for ESP32 and RP2040 in all examples, since they support PWM gereration for each pin without using a shared resource (timer). |
| `USE_NO_SEND_PWM` | disabled | Uses no carrier PWM, just simulate an **active low** receiver signal. Used for transferring signal by cable instead of IR. Overrides `SEND_PWM_BY_TIMER` definition. |
| `IR_SEND_DUTY_CYCLE_PERCENT` | 30 | Duty cycle of IR send signal. |
| `USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN` | disabled | Uses or simulates open drain output mode at send pin. **Attention, active state of open drain is LOW**, so connect the send LED between positive supply and send pin! |
@ -728,7 +731,7 @@ These next macros for **TinyIRReceiver** must be defined in your program before
| `USE_CALLBACK_FOR_TINY_RECEIVER` | disabled | Call the fixed function `void handleReceivedTinyIRData()` each time a frame or repeat is received. |
The next macro for **IRCommandDispatcher** must be defined in your program before the line `#include <IRCommandDispatcher.hpp>` to take effect.
| `USE_TINY_IR_RECEIVER` | disabled | Use [TinyReceiver](https://github.com/Arduino-IRremote/Arduino-IRremote#tinyreceiver--tinysender) for receiving IR codes. |
| `USE_TINY_IR_RECEIVER` | disabled | Use [TinyReceiver](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#tinyreceiver--tinysender) for receiving IR codes. |
| `IR_COMMAND_HAS_MORE_THAN_8_BIT` | disabled | Enables mapping and dispatching of IR commands consisting of more than 8 bits. Saves up to 160 bytes program memory and 4 bytes RAM + 1 byte RAM per mapping entry. |
| `BUZZER_PIN` | | If `USE_TINY_IR_RECEIVER` is enabled, the pin to be used for the optional 50 ms buzzer feedback before executing a command. Other IR libraries than Tiny are not compatible with tone() command. |
@ -862,7 +865,7 @@ For other boards/platforms you must look for the appropriate section guarded by
### Stop and start timer
Another approach can be to share the timer **sequentially** if their functionality is used only for a short period of time like for the **Arduino tone() command**.
An example can be seen [here](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/21b5747a58e9d47c9e3f1beb056d58c875a92b47/examples/ReceiveDemo/ReceiveDemo.ino#L159-L169), where the timer settings for IR receive are restored after the tone has stopped.
For this we must call `IrReceiver.start()` or better `IrReceiver.start(microsecondsOfToneDuration)`.<br/>
For this we must call `IrReceiver.restartTimer()` or better `IrReceiver.restartTimer(microsecondsOfToneDuration)`.<br/>
This only works since each call to` tone()` completely initializes the timer 2 used by the `tone()` command.
## Hardware-PWM signal generation for sending
@ -886,7 +889,7 @@ And believe me, if you send a 525 &micro;s signal, your receiver will output som
Therefore **we decode by default with a +/- 25% margin** using the formulas [here](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremoteInt.h#L376-L399).<br/>
E.g. for the NEC protocol with its 560 &micro;s unit length, we have TICKS_LOW = 8.358 and TICKS_HIGH = 15.0. This means, we accept any value between 8 ticks / 400 &micro;s and 15 ticks / 750 &micro;s (inclusive) as a mark or as a zero space. For a one space we have TICKS_LOW = 25.07 and TICKS_HIGH = 45.0.<br/>
And since the receivers generated marks are longer or shorter than the spaces,
we have introduced the [`MARK_EXCESS_MICROS`](https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library) macro
we have introduced the [`MARK_EXCESS_MICROS`](https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#compile-options--macros-for-this-library) macro
to compensate for this receiver (and signal strength as well as ambient light dependent :disappointed: ) specific deviation.<br/>
Welcome to the world of **real world signal processing**.

View File

@ -2,9 +2,12 @@
The latest version may not be released!
See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-IRremote/commits/master
# 4.2.2
# 4.3.0
- Added convenience function isIRReceiverAttachedForTinyReceiver().
- Added Extended NEC Protocol macro to TinyIR by Buzzerb.
- Fixed sendSamsung() / sendSamsungLG() bug.
- Added functions stopTimer(), restartTimer() and restartTimerWithTicksToAdd().
- Added rawlen and initialGap to IRData.
# 4.2.1
- Fix wrong type of tEnableLEDFeedback in IRSend.hpp and IRReceive.hpp.

View File

@ -231,7 +231,7 @@ void loop() {
} else {
// play tone
auto tStartMillis = millis();
IrReceiver.stop();
IrReceiver.stopTimer();
tone(TONE_PIN, 2200);
if ((IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(DEBUG_BUTTON_PIN) == LOW)
@ -251,7 +251,7 @@ void loop() {
noTone(TONE_PIN);
// Restore IR timer. millis() - tStartMillis to compensate for stop of receiver. This enables a correct gap measurement.
IrReceiver.startWithTicksToAdd((millis() - tStartMillis) * (MICROS_IN_ONE_MILLI / MICROS_PER_TICK));
IrReceiver.restartTimerWithTicksToAdd((millis() - tStartMillis) * (MICROS_IN_ONE_MILLI / MICROS_PER_TICK));
#if defined(USE_LCD)
printIRResultOnLCD();
@ -277,11 +277,11 @@ void loop() {
#if defined(USE_LCD) && defined(ADC_UTILS_ARE_AVAILABLE)
printsVCCVoltageMillivoltOnLCD();
#endif
IrReceiver.stop();
IrReceiver.stopTimer();
tone(TONE_PIN, 2200);
delay(50);
noTone(TONE_PIN);
IrReceiver.startWithTicksToAdd(50 * (MICROS_IN_ONE_MILLI / MICROS_PER_TICK));
IrReceiver.restartTimerWithTicksToAdd(50 * (MICROS_IN_ONE_MILLI / MICROS_PER_TICK));
}
#if defined(USE_LCD) && defined(ADC_UTILS_ARE_AVAILABLE)

View File

@ -3,14 +3,14 @@
*
* Demonstrates receiving IR codes with the IRremote library and the use of the Arduino tone() function with this library.
* Long press of one IR button (receiving of multiple repeats for one command) is detected.
* If debug button is pressed (pin connected to ground) a long output is generated.
* If debug button is pressed (pin connected to ground) a long output is generated, which may disturb detecting of repeats.
*
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
*
************************************************************************************
* MIT License
*
* Copyright (c) 2020-2023 Armin Joachimsmeyer
* Copyright (c) 2020-2024 Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -54,18 +54,14 @@
//#define DECODE_SONY
//#define DECODE_RC5
//#define DECODE_RC6
//#define DECODE_BOSEWAVE
//#define DECODE_LEGO_PF
//#define DECODE_MAGIQUEST
//#define DECODE_WHYNTER
//#define DECODE_FAST
//#define DECODE_DISTANCE_WIDTH // Universal decoder for pulse distance width protocols
//#define DECODE_HASH // special decoder for all protocols
//#define DECODE_BEO // This protocol must always be enabled manually, i.e. it is NOT enabled if no protocol is defined. It prevents decoding of SONY!
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
// !!! Enabling B&O disables detection of Sony, because the repeat gap for SONY is smaller than the B&O frame gap :-( !!!
//#define DECODE_BEO // Bang & Olufsen protocol always must be enabled explicitly. It has an IR transmit frequency of 455 kHz! It prevents decoding of SONY!
@ -108,6 +104,8 @@
#define DEBUG_BUTTON_PIN 6
#endif
void generateTone();
void handleOverflow();
bool detectLongPress(uint16_t aLongPressDurationMillis);
void setup() {
@ -153,7 +151,6 @@ void setup() {
Serial.print(MARK_EXCESS_MICROS);
Serial.println(F(" us are subtracted from all marks and added to all spaces for decoding"));
#endif
}
void loop() {
@ -164,99 +161,60 @@ void loop() {
* E.g. command is in IrReceiver.decodedIRData.command
* address is in command is in IrReceiver.decodedIRData.address
* and up to 32 bit raw data in IrReceiver.decodedIRData.decodedRawData
*
* At 115200 baud, printing takes 40 ms for NEC protocol and 10 ms for NEC repeat
*/
if (IrReceiver.decode()) {
Serial.println();
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604
#if FLASHEND < 0x3FFF //
// For less than 16k flash, only print a minimal summary of received data
IrReceiver.printIRResultMinimal(&Serial);
#else
/*
*
*/
if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_WAS_OVERFLOW) {
Serial.println(F("Overflow detected"));
Serial.println(F("Try to increase the \"RAW_BUFFER_LENGTH\" value of " STR(RAW_BUFFER_LENGTH) " in " __FILE__));
// see also https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library
# if !defined(ESP8266) && !defined(NRF5)
/*
* do double beep
*/
# if !defined(ESP32)
IrReceiver.stop(); // ESP32 uses another timer for tone()
# endif
tone(TONE_PIN, 1100, 10);
delay(50);
tone(TONE_PIN, 1100, 10);
delay(50);
# if !defined(ESP32)
IrReceiver.start(100000); // to compensate for 100 ms stop of receiver. This enables a correct gap measurement.
# endif
# endif
handleOverflow();
} else {
auto tStartMillis = millis();
# if !defined(ESP32)
IrReceiver.stop(); // ESP32 uses another timer for tone()
# endif
tone(TONE_PIN, 2200);
/*
* No overflow here.
* Stop receiver, generate a single beep, print short info and send usage and start receiver again
*****************************************************************************************************/
// No overflow, print a short summary of received data
# if defined(LOCAL_DEBUG)
IrReceiver.printIRResultShort(&Serial, true);
# else
IrReceiver.printIRResultShort(&Serial, true, digitalRead(DEBUG_BUTTON_PIN) == LOW);
# endif
// Guarantee at least 5 millis for tone. decode starts 5 millis (RECORD_GAP_MICROS) after end of frame
// so here we are 10 millis after end of frame. Sony20 has only a 12 ms repeat gap.
while ((millis() - tStartMillis) < 5)
;
noTone(TONE_PIN);
if ((IrReceiver.decodedIRData.protocol != SONY) && (IrReceiver.decodedIRData.protocol != PULSE_WIDTH)
&& (IrReceiver.decodedIRData.protocol != PULSE_DISTANCE) && (IrReceiver.decodedIRData.protocol != UNKNOWN)
&& digitalRead(DEBUG_BUTTON_PIN) != LOW) {
/*
* For SONY the tone prevents the detection of a repeat after the 15 ms SONY gap.
* In debug mode and for unknown protocols, we need the time for extended output.
* Skipping tone will get exact gap time between transmissions and not running into repeat frames while wait for tone to end.
* This in turn enables the next CheckForRecordGapsMicros() call a chance to eventually propose a change of the current RECORD_GAP_MICROS value.
*/
generateTone();
}
# if !defined(ESP32)
// Restore IR timer. millis() - tStartMillis to compensate for stop of receiver. This enables a correct gap measurement.
IrReceiver.startWithTicksToAdd((millis() - tStartMillis) * (MICROS_IN_ONE_MILLI / MICROS_PER_TICK));
# endif
IrReceiver.printIRSendUsage(&Serial);
# if defined(LOCAL_DEBUG)
IrReceiver.printIRResultRawFormatted(&Serial, true);
# else
/*
* Print info
*/
if (IrReceiver.decodedIRData.protocol == UNKNOWN || digitalRead(DEBUG_BUTTON_PIN) == LOW) {
// We have an unknown protocol, print more info
// We have debug enabled or an unknown protocol, print extended info
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
Serial.println(F("Received noise or an unknown (or not yet enabled) protocol"));
}
IrReceiver.printIRResultRawFormatted(&Serial, true);
} else {
/*
* This is the info output for a successful receive in normal mode
*/
IrReceiver.printIRResultShort(&Serial);
IrReceiver.printIRSendUsage(&Serial);
}
# endif
}
// tone on esp8266 works once, then it disables the successful IrReceiver.start() / timerConfigForReceive().
# if !defined(ESP8266) && !defined(NRF5) && !defined(LOCAL_DEBUG)
if ((IrReceiver.decodedIRData.protocol != SONY) && (IrReceiver.decodedIRData.protocol != PULSE_WIDTH)
&& (IrReceiver.decodedIRData.protocol != PULSE_DISTANCE) && (IrReceiver.decodedIRData.protocol != UNKNOWN)
&& digitalRead(DEBUG_BUTTON_PIN) != LOW) {
/*
* If no debug mode or a valid protocol was received, play tone, wait and restore IR timer.
* For SONY the tone prevents the detection of a repeat
* Otherwise do not play a tone to get exact gap time between transmissions and not running into repeat frames while wait for tone to end.
* This will give the next CheckForRecordGapsMicros() call a chance to eventually propose a change of the current RECORD_GAP_MICROS value.
*/
# if !defined(ESP32)
IrReceiver.stop(); // ESP32 uses another timer for tone()
# endif
tone(TONE_PIN, 2200, 8);
# if !defined(ESP32)
delay(8);
IrReceiver.start(8000); // Restore IR timer. 8000 to compensate for 8 ms stop of receiver. This enables a correct gap measurement.
# endif
}
# endif
#else // #if FLASHEND >= 0x3FFF
// Print a minimal summary of received data
IrReceiver.printIRResultMinimal(&Serial);
#endif // #if FLASHEND >= 0x3FFF
/*
* !!!Important!!! Enable receiving of the next value,
* since receiving has stopped after the end of the current received data packet.
* !!!Important!!! Enable receiving of the next value, because receiving
* has stopped after the end of the current received data packet.
* Do it here, to preserve raw data for printing with printIRResultRawFormatted()
*/
IrReceiver.resume();
@ -289,6 +247,46 @@ void loop() {
}
/*
* Stop receiver, generate a single beep and start receiver again
*/
void generateTone() {
#if !defined(ESP8266) && !defined(NRF5) // tone on esp8266 works only once, then it disables IrReceiver.restartTimer() / timerConfigForReceive().
# if defined(ESP32) // ESP32 uses another timer for tone()
tone(TONE_PIN, 2200, 5);
# else
IrReceiver.stopTimer(); // ESP32 uses another timer for tone(), maybe other platforms (not tested yet) too.
tone(TONE_PIN, 2200, 8);
delay(8);
IrReceiver.restartTimer(8000); // Restart IR timer. 8000 to compensate for 8 ms stop of receiver. This enables a correct gap measurement.
# endif
#endif
}
void handleOverflow() {
Serial.println(F("Overflow detected"));
Serial.println(F("Try to increase the \"RAW_BUFFER_LENGTH\" value of " STR(RAW_BUFFER_LENGTH) " in " __FILE__));
// see also https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library
#if !defined(ESP8266) && !defined(NRF5) // tone on esp8266 works once, then it disables IrReceiver.restartTimer() / timerConfigForReceive().
/*
* Stop timer, generate a double beep and start timer again
*/
# if defined(ESP32) // ESP32 uses another timer for tone()
tone(TONE_PIN, 1100, 10);
delay(50);
tone(TONE_PIN, 1100, 10);
# else
IrReceiver.stopTimer();
tone(TONE_PIN, 1100, 10);
delay(50);
tone(TONE_PIN, 1100, 10);
delay(50);
IrReceiver.restartTimer(100000); // to compensate for 100 ms stop of receiver. This enables a correct gap measurement.
# endif
#endif
}
unsigned long sMillisOfFirstReceive;
bool sLongPressJustDetected;
/**

View File

@ -10,7 +10,7 @@
************************************************************************************
* MIT License
*
* Copyright (c) 2020-2022 Armin Joachimsmeyer
* Copyright (c) 2020-2024 Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -88,6 +88,9 @@ void setup() {
Serial.println();
Serial.println(F("Because of the verbose output (>200 ms at 115200 baud), repeats are not dumped correctly!"));
Serial.println();
Serial.println(F("If you receive protocol NEC, Samsung or LG, run also ReceiveDemo to check if your actual protocol is eventually NEC2, SamsungLG or LG2, which is determined by the repeats"));
Serial.println();
}
//+=============================================================================
@ -147,6 +150,6 @@ void loop() {
// Serial.println(); // blank line between entries
// }
}
IrReceiver.resume(); // Prepare for the next value
IrReceiver.resume(); // Prepare for the next IR frame
}
}

View File

@ -190,7 +190,7 @@ void sendSamsungSmartHubMacro(bool aDoSelect) {
}
# if !defined(ESP32)
IrReceiver.stop(); // ESP32 uses another timer for tone()
IrReceiver.stopTimer(); // ESP32 uses another timer for tone()
# endif
if (millis() < tWaitTimeAfterBoot) {
// division by 1000 and printing requires much (8%) program memory
@ -218,7 +218,7 @@ void sendSamsungSmartHubMacro(bool aDoSelect) {
delay(200);
# if !defined(ESP32)
IrReceiver.start(200000); // to compensate for 200 ms stop of receiver. This enables a correct gap measurement.
IrReceiver.restartTimer(200000); // to compensate for 200 ms stop of receiver. This enables a correct gap measurement.
# endif
Serial.println(F("Wait for \"not supported\" to disappear"));

View File

@ -94,23 +94,20 @@ void loop() {
if (IrReceiver.decode()) {
/*
* Print a short summary of received data
* Print a summary of received data
*/
IrReceiver.printIRResultShort(&Serial);
IrReceiver.printIRSendUsage(&Serial);
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
Serial.println(F("Received noise or an unknown (or not yet enabled) protocol"));
// We have an unknown protocol here, print more info
// We have an unknown protocol here, print extended info
IrReceiver.printIRResultRawFormatted(&Serial, true);
IrReceiver.resume(); // Do it here, to preserve raw data for printing with printIRResultRawFormatted()
} else {
IrReceiver.resume(); // Early enable receiving of the next IR frame
IrReceiver.printIRResultShort(&Serial);
IrReceiver.printIRSendUsage(&Serial);
}
Serial.println();
/*
* !!!Important!!! Enable receiving of the next value,
* since receiving has stopped after the end of the current received data packet.
*/
IrReceiver.resume(); // Enable receiving of the next value
/*
* Finally, check the received data and perform actions according to the received command
*/

View File

@ -85,7 +85,7 @@ void setup() {
IrReceiver.registerReceiveCompleteCallback(ReceiveCompleteCallbackHandler);
Serial.print(F("Ready to receive IR signals of protocols: "));
printActiveIRProtocols (&Serial);
printActiveIRProtocols(&Serial);
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
}
@ -94,9 +94,7 @@ void loop() {
* Print in loop (interrupts are enabled here) if received data is available.
*/
if (sIRDataJustReceived) {
// Print a short summary of received data
IrReceiver.printIRResultShort(&Serial);
IrReceiver.printIRSendUsage(&Serial);
// Print a summary of received data
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
Serial.println(F("Received noise or an unknown (or not yet enabled) protocol"));
/*
@ -105,6 +103,9 @@ void loop() {
* and the the first mark of the next (repeat) data was yet received
*/
IrReceiver.printIRResultRawFormatted(&Serial, true); //
} else {
IrReceiver.printIRResultShort(&Serial);
IrReceiver.printIRSendUsage(&Serial);
}
Serial.println();
}
@ -124,6 +125,10 @@ IRAM_ATTR
# endif
void ReceiveCompleteCallbackHandler() {
IrReceiver.decode(); // fill IrReceiver.decodedIRData
/*
* Enable receiving of the next value.
*/
IrReceiver.resume();
/*
* Check the received data and perform actions according to the received command
@ -146,13 +151,4 @@ void ReceiveCompleteCallbackHandler() {
*/
sIRDataJustReceived = true;
/*
* Enable receiving of the next value.
* !!!Attention!!!
* After receiving the first mark of the next (repeat) data, 3 variables required for printing are reset/overwritten.
* - IrReceiver.irparams.rawlen
* - IrReceiver.irparams.rawbuf[0]
* - IrReceiver.irparams.OverflowFlag)
*/
IrReceiver.resume();
}

View File

@ -288,7 +288,7 @@ void ReceiveCompleteCallbackHandler() {
void checkReceive(uint16_t aSentAddress, uint16_t aSentCommand) {
// wait until signal has received
while (!sDataJustReceived) {
};
}
sDataJustReceived = false;
if (IrReceiver.decode()) {
@ -311,6 +311,8 @@ void checkReceive(uint16_t aSentAddress, uint16_t aSentCommand) {
IrReceiver.printIRResultRawFormatted(&Serial, true);
}
#endif
IrReceiver.resume(); // Early resume
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
Serial.println(F("ERROR: Unknown protocol"));
} else {
@ -334,9 +336,9 @@ void checkReceive(uint16_t aSentAddress, uint16_t aSentCommand) {
}
}
IrReceiver.resume();
} else {
Serial.println(F("No data received"));
IrReceiver.resume();
}
Serial.println();
}
@ -350,7 +352,7 @@ void checkReceive(uint16_t aSentAddress, uint16_t aSentCommand) {
uint16_t sAddress = 0xFFF1;
uint8_t sCommand = 0x76;
uint16_t s16BitCommand = 0x9876;
#define sRepeats 0 // no unit test for repeats
uint8_t sRepeats = 0;
void loop() {
/*
@ -366,19 +368,29 @@ void loop() {
Serial.println(F("Send NEC with 8 bit address"));
Serial.flush();
IrSender.sendNEC(sAddress & 0xFF, sCommand, sRepeats);
IrSender.sendNEC(sAddress & 0xFF, sCommand, 0);
checkReceive(sAddress & 0xFF, sCommand);
//
for (int8_t i = 0; i < sRepeats; i++) {
Serial.println(F("Repeat NEC frame for NEC2"));
Serial.flush();
// if debug is enabled, printing time (50 ms) is too high anyway
delayMicroseconds(NEC_REPEAT_DISTANCE - 200); // 200 is just a guess
IrSender.sendNEC(sAddress & 0xFF, sCommand, 0);
checkReceive(sAddress & 0xFF, sCommand);
}
delay(DELAY_AFTER_SEND); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
Serial.println(F("Send NEC with 16 bit address"));
Serial.flush();
IrSender.sendNEC(sAddress, sCommand, sRepeats);
IrSender.sendNEC(sAddress, sCommand, 0);
checkReceive(sAddress, sCommand);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send NEC2 with 16 bit address"));
Serial.flush();
IrSender.sendNEC2(sAddress, sCommand, sRepeats);
IrSender.sendNEC2(sAddress, sCommand, 0);
checkReceive(sAddress, sCommand);
delay(DELAY_AFTER_SEND);
@ -418,7 +430,7 @@ void loop() {
*/
Serial.println(F("Send ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)"));
Serial.flush();
IrSender.sendNECRaw(0x03040102, sRepeats);
IrSender.sendNECRaw(0x03040102, 0);
checkReceive(0x0102, 0x304);
delay(DELAY_AFTER_SEND);
@ -453,7 +465,7 @@ void loop() {
* Send 2 Panasonic 48 bit codes as generic Pulse Distance data, once with LSB and once with MSB first
*/
Serial.println(F("Send Panasonic 0xB, 0x10 as generic 48 bit PulseDistance"));
Serial.println(F(" LSB first"));
Serial.println(F("-LSB first"));
Serial.flush();
# if __INT_WIDTH__ < 32
IrSender.sendPulseDistanceWidthFromArray(38, 3450, 1700, 450, 1250, 450, 400, &tRawData[0], 48, PROTOCOL_IS_LSB_FIRST, 0,
@ -467,7 +479,7 @@ void loop() {
delay(DELAY_AFTER_SEND);
// The same with MSB first. Use bit reversed raw data of LSB first part
Serial.println(F(" MSB first"));
Serial.println(F("-MSB first"));
# if __INT_WIDTH__ < 32
tRawData[0] = 0x40040D00; // MSB of tRawData[0] is sent first
tRawData[1] = 0x805;
@ -585,32 +597,32 @@ void loop() {
Serial.println(F("Send Onkyo (NEC with 16 bit command)"));
Serial.flush();
IrSender.sendOnkyo(sAddress, (sCommand + 1) << 8 | sCommand, sRepeats);
IrSender.sendOnkyo(sAddress, (sCommand + 1) << 8 | sCommand, 0);
checkReceive(sAddress, (sCommand + 1) << 8 | sCommand);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send Apple"));
Serial.flush();
IrSender.sendApple(sAddress & 0xFF, sCommand, sRepeats);
IrSender.sendApple(sAddress & 0xFF, sCommand, 0);
checkReceive(sAddress & 0xFF, sCommand);
delay(DELAY_AFTER_SEND);
#if defined(DECODE_PANASONIC) || defined(DECODE_KASEIKYO)
Serial.println(F("Send Panasonic"));
Serial.flush();
IrSender.sendPanasonic(sAddress & 0xFFF, sCommand, sRepeats);
IrSender.sendPanasonic(sAddress & 0xFFF, sCommand, 0);
checkReceive(sAddress & 0xFFF, sCommand);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send Kaseikyo with 0x4711 as Vendor ID"));
Serial.flush();
IrSender.sendKaseikyo(sAddress & 0xFFF, sCommand, sRepeats, 0x4711);
IrSender.sendKaseikyo(sAddress & 0xFFF, sCommand, 0, 0x4711);
checkReceive(sAddress & 0xFFF, sCommand);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send Kaseikyo_Denon variant"));
Serial.flush();
IrSender.sendKaseikyo_Denon(sAddress & 0xFFF, sCommand, sRepeats);
IrSender.sendKaseikyo_Denon(sAddress & 0xFFF, sCommand, 0);
checkReceive(sAddress & 0xFFF, sCommand);
delay(DELAY_AFTER_SEND);
#endif
@ -618,13 +630,13 @@ void loop() {
#if defined(DECODE_DENON)
Serial.println(F("Send Denon"));
Serial.flush();
IrSender.sendDenon(sAddress & 0x1F, sCommand, sRepeats);
IrSender.sendDenon(sAddress & 0x1F, sCommand, 0);
checkReceive(sAddress & 0x1F, sCommand);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send Denon/Sharp variant"));
Serial.flush();
IrSender.sendSharp(sAddress & 0x1F, sCommand, sRepeats);
IrSender.sendSharp(sAddress & 0x1F, sCommand, 0);
checkReceive(sAddress & 0x1F, sCommand);
delay(DELAY_AFTER_SEND);
#endif
@ -632,19 +644,19 @@ void loop() {
#if defined(DECODE_SONY)
Serial.println(F("Send Sony/SIRCS with 7 command and 5 address bits"));
Serial.flush();
IrSender.sendSony(sAddress & 0x1F, sCommand, sRepeats);
IrSender.sendSony(sAddress & 0x1F, sCommand, 0);
checkReceive(sAddress & 0x1F, sCommand & 0x7F);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send Sony/SIRCS with 7 command and 8 address bits"));
Serial.flush();
IrSender.sendSony(sAddress & 0xFF, sCommand, sRepeats, SIRCS_15_PROTOCOL);
IrSender.sendSony(sAddress & 0xFF, sCommand, 0, SIRCS_15_PROTOCOL);
checkReceive(sAddress & 0xFF, sCommand & 0x7F);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send Sony/SIRCS with 7 command and 13 address bits"));
Serial.flush();
IrSender.sendSony(sAddress & 0x1FFF, sCommand, sRepeats, SIRCS_20_PROTOCOL);
IrSender.sendSony(sAddress & 0x1FFF, sCommand, 0, SIRCS_20_PROTOCOL);
checkReceive(sAddress & 0x1FFF, sCommand & 0x7F);
delay(DELAY_AFTER_SEND);
#endif
@ -652,19 +664,19 @@ void loop() {
#if defined(DECODE_SAMSUNG)
Serial.println(F("Send Samsung 8 bit command"));
Serial.flush();
IrSender.sendSamsung(sAddress, sCommand, sRepeats);
IrSender.sendSamsung(sAddress, sCommand, 0);
checkReceive(sAddress, sCommand);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send Samsung 16 bit command"));
Serial.flush();
IrSender.sendSamsung(sAddress, s16BitCommand, sRepeats);
IrSender.sendSamsung(sAddress, s16BitCommand, 0);
checkReceive(sAddress, s16BitCommand);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send Samsung48 16 bit command"));
Serial.flush();
IrSender.sendSamsung48(sAddress, s16BitCommand, sRepeats);
IrSender.sendSamsung48(sAddress, s16BitCommand, 0);
checkReceive(sAddress, s16BitCommand);
delay(DELAY_AFTER_SEND);
#endif
@ -672,13 +684,13 @@ void loop() {
#if defined(DECODE_RC5)
Serial.println(F("Send RC5"));
Serial.flush();
IrSender.sendRC5(sAddress & 0x1F, sCommand & 0x3F, sRepeats, true); // 5 address, 6 command bits
IrSender.sendRC5(sAddress & 0x1F, sCommand & 0x3F, 0, true); // 5 address, 6 command bits
checkReceive(sAddress & 0x1F, sCommand & 0x3F);
delay(DELAY_AFTER_SEND);
Serial.println(F("Send RC5X with 7.th MSB of command set"));
Serial.flush();
IrSender.sendRC5(sAddress & 0x1F, (sCommand & 0x3F) + 0x40, sRepeats, true); // 5 address, 7 command bits
IrSender.sendRC5(sAddress & 0x1F, (sCommand & 0x3F) + 0x40, 0, true); // 5 address, 7 command bits
checkReceive(sAddress & 0x1F, (sCommand & 0x3F) + 0x40);
delay(DELAY_AFTER_SEND);
#endif
@ -687,7 +699,7 @@ void loop() {
Serial.println(F("Send RC6"));
// RC6 check does not work stable without the flush
Serial.flush();
IrSender.sendRC6(sAddress & 0xFF, sCommand, sRepeats, true);
IrSender.sendRC6(sAddress & 0xFF, sCommand, 0, true);
checkReceive(sAddress & 0xFF, sCommand);
delay(DELAY_AFTER_SEND);
#endif
@ -706,7 +718,7 @@ void loop() {
Serial.print(F("Send "));
Serial.println(getProtocolString(IRSendData.protocol));
Serial.flush();
IrSender.write(&IRSendData, sRepeats);
IrSender.write(&IRSendData, 0);
checkReceive(IRSendData.address & 0xFF, IRSendData.command);
delay(DELAY_AFTER_SEND);
#endif
@ -720,7 +732,7 @@ void loop() {
Serial.print(F("Send "));
Serial.println(getProtocolString(IRSendData.protocol));
Serial.flush();
IrSender.write(&IRSendData, sRepeats);
IrSender.write(&IRSendData, 0);
checkReceive(IRSendData.address, IRSendData.command);
delay(DELAY_AFTER_SEND);
#endif
@ -730,7 +742,7 @@ void loop() {
Serial.print(F("Send "));
Serial.println(getProtocolString(IRSendData.protocol));
Serial.flush();
IrSender.write(&IRSendData, sRepeats);
IrSender.write(&IRSendData, 0);
checkReceive(IRSendData.address & 0xFF, IRSendData.command);
delay(DELAY_AFTER_SEND);
#endif
@ -746,19 +758,21 @@ void loop() {
#if defined(DECODE_BEO)
Serial.println(F("Send Bang&Olufsen"));
Serial.flush();
IrSender.sendBangOlufsen(sAddress & 0x0FF, sCommand, sRepeats);
IrSender.sendBangOlufsen(sAddress & 0x0FF, sCommand, 0);
# if defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
delay((RECORD_GAP_MICROS / 1000) + 1);
Serial.println(F("- ENABLE_BEO_WITHOUT_FRAME_GAP is enabled. PrintRaw and try to decode"));
IrReceiver.printIRResultRawFormatted(&Serial, true);
uint8_t tOriginalRawlen = IrReceiver.decodedIRData.rawDataPtr->rawlen;
IrReceiver.decodedIRData.rawDataPtr->rawlen = 6;
uint8_t tOriginalRawlen = IrReceiver.decodedIRData.rawlen;
IrReceiver.decodedIRData.rawlen = 6;
// decode first part of frame
IrReceiver.decode();
IrReceiver.printIRResultShort(&Serial);
// Remove trailing 6 entries for next decode
IrReceiver.decodedIRData.rawDataPtr->rawlen = tOriginalRawlen - 6;
for (uint_fast8_t i = 0; i < IrReceiver.decodedIRData.rawDataPtr->rawlen; ++i) {
// Remove trailing 6 entries for next decode try
Serial.println(F("- Remove trailing 6 entries for next decode try"));
IrReceiver.decodedIRData.rawlen = tOriginalRawlen - 6;
for (uint_fast8_t i = 0; i < IrReceiver.decodedIRData.rawlen; ++i) {
IrReceiver.decodedIRData.rawDataPtr->rawbuf[i] = IrReceiver.decodedIRData.rawDataPtr->rawbuf[i + 6];
}
# endif
@ -770,7 +784,7 @@ void loop() {
IRSendData.protocol = BOSEWAVE;
Serial.println(F("Send Bosewave with no address and 8 command bits"));
Serial.flush();
IrSender.write(&IRSendData, sRepeats);
IrSender.write(&IRSendData, 0);
checkReceive(0, IRSendData.command & 0xFF);
delay(DELAY_AFTER_SEND);
#endif
@ -780,7 +794,7 @@ void loop() {
Serial.print(F("Send "));
Serial.println(getProtocolString(IRSendData.protocol));
Serial.flush();
IrSender.write(&IRSendData, sRepeats);
IrSender.write(&IRSendData, 0);
checkReceive(0, IRSendData.command & 0xFF);
delay(DELAY_AFTER_SEND);
#endif
@ -813,7 +827,11 @@ void loop() {
sAddress += 0x0101;
sCommand += 0x11;
s16BitCommand += 0x1111;
sRepeats++;
// clip repeats at 4
if (sRepeats > 4) {
sRepeats = 4;
}
delay(DELAY_AFTER_LOOP); // additional delay at the end of each loop
}

View File

@ -12,7 +12,7 @@ address=0xFFF1 command=0x76
Send NEC with 8 bit address
Protocol=NEC Address=0xF1 Command=0x76 Raw-Data=0x89760EF1 32 bits LSB first
Send with: IrSender.sendNEC(0xF1, 0x76, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1044300
+8950,-4400
+ 600,-1650 + 600,- 500 + 600,- 550 + 600,- 500
@ -29,7 +29,7 @@ Sum: 67650
Send NEC with 16 bit address
Protocol=NEC Address=0xFFF1 Command=0x76 Raw-Data=0x8976FFF1 32 bits LSB first
Send with: IrSender.sendNEC(0xFFF1, 0x76, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1055100
+8850,-4450
+ 600,-1650 + 600,- 500 + 600,- 550 + 600,- 500
@ -46,7 +46,7 @@ Sum: 73150
Send NEC2 with 16 bit address
Protocol=NEC Address=0xFFF1 Command=0x76 Raw-Data=0x8976FFF1 32 bits LSB first
Send with: IrSender.sendNEC(0xFFF1, 0x76, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1055500
+8950,-4400
+ 650,-1600 + 600,- 500 + 650,- 500 + 600,- 500
@ -63,7 +63,7 @@ Sum: 73400
Send NEC Pronto data with 8 bit address 0x80 and command 0x45 and no repeats
Protocol=NEC Address=0x80 Command=0x45 Raw-Data=0xBA457F80 32 bits LSB first
Send with: IrSender.sendNEC(0x80, 0x45, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1064450
+9050,-4450
+ 550,- 550 + 600,- 550 + 600,- 600 + 550,- 600
@ -80,7 +80,7 @@ Sum: 67800
Send NEC sendRaw data with 8 bit address=0xFB04 and command 0x08 and exact timing (16 bit array format)
Protocol=NEC Address=0x4 Command=0x8 Raw-Data=0xF708FB04 32 bits LSB first
Send with: IrSender.sendNEC(0x4, 0x8, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1061400
+9000,-4400
+ 600,- 500 + 650,- 500 + 600,-1650 + 600,- 500
@ -97,7 +97,7 @@ Sum: 67900
Send ONKYO with 16 bit address 0x0102 and 16 bit command 0x0304 with NECRaw(0x03040102)
Protocol=Onkyo Address=0x102 Command=0x304 Raw-Data=0x3040102 32 bits LSB first
Send with: IrSender.sendOnkyo(0x102, 0x304, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1059700
+8900,-4400
+ 600,- 550 + 600,-1600 + 600,- 550 + 600,- 500
@ -114,7 +114,7 @@ Sum: 55450
Send ONKYO with 16 bit address 0x0102 and command 0x34 with old 32 bit format MSB first (0x40802CD3)
Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 32 bits LSB first
Send with: IrSender.sendNEC(0x102, 0x34, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1061500
+8950,-4400
+ 600,- 500 + 550,-1700 + 600,- 500 + 650,- 500
@ -131,7 +131,7 @@ Sum: 61000
Send Panasonic 0xB, 0x10 as 48 bit generic PulseDistance using ProtocolConstants
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
rawData[100]:
rawData[100]:
-1059500
+3450,-1700
+ 450,- 450 + 450,-1250 + 450,- 400 + 450,- 450
@ -150,10 +150,10 @@ rawData[100]:
Sum: 54100
Send Panasonic 0xB, 0x10 as generic 48 bit PulseDistance
LSB first
- LSB first
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
rawData[100]:
rawData[100]:
-1076450
+3450,-1700
+ 450,- 400 + 450,-1250 + 450,- 400 + 450,- 400
@ -171,10 +171,10 @@ rawData[100]:
+ 400
Sum: 53200
MSB first
- MSB first
Protocol=Panasonic Address=0xB Command=0x10 Raw-Data=0xA01000B0 48 bits LSB first
Send with: IrSender.sendPanasonic(0xB, 0x10, <numberOfRepeats>);
rawData[100]:
rawData[100]:
-1070700
+3400,-1700
+ 450,- 400 + 450,-1250 + 450,- 400 + 450,- 400
@ -194,10 +194,10 @@ Sum: 53150
Send generic 72 bit PulseDistance 0x5A AFEDCBA9 87654321 LSB first
Protocol=PulseDistance Raw-Data=0x5A 72 bits LSB first
Send with:
Send on a 8 bit platform with:
uint32_t tRawData[]={0x87654321, 0xAFEDCBA9, 0x5A};
IrSender.sendPulseDistanceWidthFromArray(38, 8850, 4400, 550, 1650, 550, 600, &tRawData[0], 72, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
rawData[148]:
rawData[148]:
-1076300
+8850,-4400
+ 600,-1650 + 550,- 600 + 550,- 600 + 550,- 600
@ -223,10 +223,10 @@ Sum: 138200
Send generic 52 bit PulseDistanceWidth 0xDCBA9 87654321 LSB first
Protocol=PulseWidth Raw-Data=0xDCBA9 52 bits LSB first
Send with:
Send on a 8 bit platform with:
uint32_t tRawData[]={0x87654321, 0xDCBA9};
IrSender.sendPulseDistanceWidthFromArray(38, 350, 600, 600, 300, 300, 600, &tRawData[0], 52, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
rawData[106]:
rawData[106]:
-1115100
+ 350,- 600
+ 650,- 250 + 350,- 550 + 350,- 550 + 300,- 600
@ -246,8 +246,8 @@ Sum: 47550
Send generic 32 bit PulseWidth 0x87654321 LSB first
Protocol=PulseWidth Raw-Data=0x87654321 32 bits LSB first
Send with: IrSender.sendPulseDistanceWidth(38, 950, 550, 600, 300, 300, 300, 0x87654321, 32, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
rawData[66]:
Send on a 8 bit platform with: IrSender.sendPulseDistanceWidth(38, 950, 550, 600, 300, 300, 300, 0x87654321, 32, PROTOCOL_IS_LSB_FIRST, <RepeatPeriodMillis>, <numberOfRepeats>);
rawData[66]:
-1088600
+ 950,- 550
+ 600,- 300 + 300,- 300 + 350,- 250 + 350,- 250
@ -263,7 +263,7 @@ Sum: 24500
Send MagiQuest 0x6BCDFF00, 0x176 as generic 55 bit PulseDistanceWidth MSB first
Protocol=MagiQuest Address=0xFF00 Command=0x176 Raw-Data=0x6BCDFF00 56 bits MSB first
Send with: IrSender.sendMagiQuest(0x6BCDFF00, 0x176, <numberOfRepeats>);
rawData[112]:
rawData[112]:
-1089000
+ 350,- 800 + 350,- 800 + 350,- 800 + 300,- 850
+ 300,- 850 + 300,- 850 + 300,- 850 + 350,- 800
@ -284,7 +284,7 @@ Sum: 63850
Send Onkyo (NEC with 16 bit command)
Protocol=Onkyo Address=0xFFF1 Command=0x7776 Raw-Data=0x7776FFF1 32 bits LSB first
Send with: IrSender.sendOnkyo(0xFFF1, 0x7776, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1070700
+8900,-4550
+ 500,-1600 + 650,- 500 + 600,- 500 + 600,- 550
@ -301,7 +301,7 @@ Sum: 76500
Send Apple
Protocol=Apple Address=0xF1 Command=0x76 Raw-Data=0xF17687EE 32 bits LSB first
Send with: IrSender.sendApple(0xF1, 0x76, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1054650
+8950,-4400
+ 600,- 550 + 550,-1650 + 650,-1600 + 600,-1600
@ -318,7 +318,7 @@ Sum: 72100
Send Panasonic
Protocol=Panasonic Address=0xFF1 Command=0x76 Raw-Data=0x9976FF10 48 bits LSB first
Send with: IrSender.sendPanasonic(0xFF1, 0x76, <numberOfRepeats>);
rawData[100]:
rawData[100]:
-1054300
+3450,-1700
+ 450,- 450 + 400,-1300 + 450,- 400 + 450,- 450
@ -339,7 +339,7 @@ Sum: 64400
Send Kaseikyo with 0x4711 as Vendor ID
Protocol=Kaseikyo Address=0xFF1 Command=0x76 Extra=0x4711 Raw-Data=0x9A76FF13 48 bits LSB first
Send with: IrSender.sendKaseikyo(0xFF1, 0x76, <numberOfRepeats>, 0x4711);
rawData[100]:
rawData[100]:
-1074550
+3400,-1750
+ 450,-1250 + 450,- 450 + 450,- 400 + 450,- 450
@ -360,7 +360,7 @@ Sum: 69500
Send Kaseikyo_Denon variant
Protocol=Kaseikyo_Denon Address=0xFF1 Command=0x76 Raw-Data=0x9976FF10 48 bits LSB first
Send with: IrSender.sendKaseikyo_Denon(0xFF1, 0x76, <numberOfRepeats>);
rawData[100]:
rawData[100]:
-1067700
+3400,-1750
+ 450,- 400 + 450,- 450 + 450,-1250 + 450,- 400
@ -381,7 +381,7 @@ Sum: 67700
Send Denon
Protocol=Denon Address=0x11 Command=0x76 Raw-Data=0xED1 15 bits LSB first
Send with: IrSender.sendDenon(0x11, 0x76, <numberOfRepeats>);
rawData[32]:
rawData[32]:
-1073050
+ 250,-1850 + 250,- 750 + 250,- 800 + 250,- 800
+ 250,-1800 + 250,- 800 + 250,-1800 + 250,-1850
@ -392,7 +392,7 @@ Sum: 23050
Send Denon/Sharp variant
Protocol=Sharp Address=0x11 Command=0x76 Raw-Data=0x4ED1 15 bits LSB first
Send with: IrSender.sendSharp(0x11, 0x76, <numberOfRepeats>);
rawData[32]:
rawData[32]:
-1018750
+ 300,-1750 + 300,- 750 + 250,- 800 + 250,- 800
+ 250,-1800 + 250,- 800 + 250,-1800 + 300,-1800
@ -403,7 +403,7 @@ Sum: 24100
Send Sony/SIRCS with 7 command and 5 address bits
Protocol=Sony Address=0x11 Command=0x76 Raw-Data=0x8F6 12 bits LSB first
Send with: IrSender.sendSony(0x11, 0x76, 2, 12);
rawData[26]:
rawData[26]:
-1020950
+2400,- 650
+ 550,- 600 +1200,- 550 +1250,- 550 + 650,- 550
@ -414,7 +414,7 @@ Sum: 20950
Send Sony/SIRCS with 7 command and 8 address bits
Protocol=Sony Address=0xF1 Command=0x76 Raw-Data=0x78F6 15 bits LSB first
Send with: IrSender.sendSony(0xF1, 0x76, 2, 15);
rawData[32]:
rawData[32]:
-1032550
+2400,- 600
+ 600,- 600 +1200,- 600 +1200,- 550 + 650,- 550
@ -426,7 +426,7 @@ Sum: 26400
Send Sony/SIRCS with 7 command and 13 address bits
Protocol=Sony Address=0x1FF1 Command=0x76 Raw-Data=0xFF8F6 20 bits LSB first
Send with: IrSender.sendSony(0x1FF1, 0x76, 2, 20);
rawData[42]:
rawData[42]:
-1036350
+2300,- 650
+ 600,- 600 +1200,- 550 +1250,- 550 + 650,- 600
@ -439,7 +439,7 @@ Sum: 35350
Send Samsung 8 bit command
Protocol=Samsung Address=0xFFF1 Command=0x76 Raw-Data=0x8976FFF1 32 bits LSB first
Send with: IrSender.sendSamsung(0xFFF1, 0x76, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1039650
+4400,-4450
+ 550,-1700 + 550,- 550 + 600,- 550 + 550,- 550
@ -456,7 +456,7 @@ Sum: 68750
Send Samsung 16 bit command
Protocol=Samsung Address=0xFFF1 Command=0x9876 Raw-Data=0x9876FFF1 32 bits LSB first
Send with: IrSender.sendSamsung(0xFFF1, 0x9876, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1056350
+4400,-4400
+ 600,-1650 + 550,- 550 + 600,- 550 + 550,- 550
@ -473,7 +473,7 @@ Sum: 68650
Send Samsung48 16 bit command
Protocol=Samsung48 Address=0xFFF1 Command=0x9876 Raw-Data=0x6798 48 bits LSB first
Send with: IrSender.sendSamsung48(0xFFF1, 0x9876, <numberOfRepeats>);
rawData[100]:
rawData[100]:
-1056750
+4450,-4450
+ 600,-1650 + 600,- 500 + 600,- 550 + 550,- 550
@ -494,7 +494,7 @@ Sum: 95650
Send RC5
Protocol=RC5 Address=0x11 Command=0x36 Raw-Data=0x1476 13 bits MSB first
Send with: IrSender.sendRC5(0x11, 0x36, <numberOfRepeats>);
rawData[20]:
rawData[20]:
-1073300
+ 900,- 900
+1750,-1800 +1750,- 900 + 900,- 850 + 900,-1750
@ -505,7 +505,7 @@ Sum: 23100
Send RC5X with 7.th MSB of command set
Protocol=RC5 Address=0x11 Command=0x76 Toggle=1 Raw-Data=0xC76 13 bits MSB first
Send with: IrSender.sendRC5(0x11, 0x76, <numberOfRepeats>);
rawData[20]:
rawData[20]:
-1031250
+1800,-1750
+ 850,- 900 +1800,- 850 + 900,- 900 + 900,-1750
@ -516,7 +516,7 @@ Sum: 23050
Send RC6
Protocol=RC6 Address=0xF1 Command=0x76 Raw-Data=0xF176 20 bits MSB first
Send with: IrSender.sendRC6(0xF1, 0x76, <numberOfRepeats>);
rawData[36]:
rawData[36]:
-1028550
+2650,- 900
+ 450,- 900 + 450,- 450 + 450,- 450 + 450,- 850
@ -529,7 +529,7 @@ Sum: 23250
Send JVC
Protocol=JVC Address=0xF1 Command=0x76 Raw-Data=0x76F1 16 bits LSB first
Send with: IrSender.sendJVC(0xF1, 0x76, <numberOfRepeats>);
rawData[36]:
rawData[36]:
-1037050
+8400,-4150
+ 500,-1600 + 550,- 500 + 500,- 550 + 550,- 500
@ -542,7 +542,7 @@ Sum: 40400
Send Samsung
Protocol=Samsung Address=0xFFF1 Command=0x9876 Raw-Data=0x9876FFF1 32 bits LSB first
Send with: IrSender.sendSamsung(0xFFF1, 0x9876, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1036350
+4450,-4400
+ 550,-1700 + 600,- 550 + 550,- 550 + 600,- 550
@ -559,7 +559,7 @@ Sum: 68750
Send LG
Protocol=LG Address=0xF1 Command=0x9876 Raw-Data=0xF19876E 28 bits MSB first
Send with: IrSender.sendLG(0xF1, 0x9876, <numberOfRepeats>);
rawData[60]:
rawData[60]:
-1054900
+9000,-4150
+ 450,-1600 + 500,-1550 + 500,-1550 + 500,-1600
@ -575,7 +575,7 @@ Sum: 59350
Send MagiQuest
Protocol=MagiQuest Address=0xFFF1 Command=0x76 Raw-Data=0x6BCDFFF1 56 bits MSB first
Send with: IrSender.sendMagiQuest(0x6BCDFFF1, 0x76, <numberOfRepeats>);
rawData[112]:
rawData[112]:
-1049950
+ 250,- 850 + 250,- 900 + 250,- 900 + 250,- 900
+ 250,- 900 + 300,- 850 + 250,- 900 + 250,- 900
@ -594,9 +594,29 @@ rawData[112]:
Sum: 63750
Send Bang&Olufsen
- ENABLE_BEO_WITHOUT_FRAME_GAP is enabled. PrintRaw and try to decode
rawData[112]:
-1049800
+ 300,-2900 + 200,-2850 + 250,-15200 + 300,-2850
+ 250,-9000 + 300,-5900 + 300,-5950 + 250,-5950
+ 250,-2850 + 250,-5950 + 250,-5950 + 250,-9000
+ 300,-2850 + 250,-9050 + 250,-5900 + 300,-5950
+ 250,-2850 + 250,-9000 + 300,-5950 + 250,-2850
+ 250,-12100 + 300,- 800 + 650,- 500 + 650,- 500
+ 650,- 500 + 650,- 500 + 650,- 500 + 650,- 500
+ 650,- 500 + 650,- 500 + 650,- 500 + 650,- 500
+ 650,- 500 + 650,- 500 + 650,- 500 + 350,- 800
+ 350,- 800 + 350,- 800 + 650,- 500 + 350,- 800
+ 350,- 800 + 650,- 500 + 650,- 500 + 650,- 500
+ 350,- 800 + 650,- 500 + 650,- 500 + 350,- 850
+ 350,- 800 + 350,- 750 + 650,- 500 + 650,- 500
+ 300,- 850 + 650,- 500 + 650,- 500 + 650
Sum: 176100
Protocol=UNKNOWN Hash=0x643E0496 22 bits (incl. gap and start) received
- Remove trailing 6 entries for next decode try
Protocol=Bang&Olufsen Address=0xF1 Command=0x76 Raw-Data=0xF176 16 bits MSB first
Send with: IrSender.sendBang&Olufsen(0xF1, 0x76, <numberOfRepeats>);
rawData[44]:
rawData[44]:
-1078450
+ 150,-2850
+ 200,-2900 + 200,-15300 + 200,-2900 + 200,-9100
@ -610,7 +630,7 @@ Sum: 136500
Send Bosewave with no address and 8 command bits
Protocol=BoseWave Address=0x0 Command=0x76 Raw-Data=0x8976 16 bits LSB first
Send with: IrSender.sendBoseWave(0x0, 0x76, <numberOfRepeats>);
rawData[36]:
rawData[36]:
-1044750
+1050,-1450
+ 550,- 450 + 550,-1400 + 550,-1450 + 550,- 450
@ -623,7 +643,7 @@ Sum: 26750
Send FAST
Protocol=FAST Address=0x0 Command=0x76 Raw-Data=0x8976 16 bits LSB first
Send with: IrSender.sendFAST(0x0, 0x76, <numberOfRepeats>);
rawData[36]:
rawData[36]:
-1036750
+2100,-1050
+ 550,- 500 + 550,-1550 + 550,-1550 + 550,- 500
@ -636,7 +656,7 @@ Sum: 28900
Force buffer overflow by sending 280 marks and spaces
Overflow
Try to increase the "RAW_BUFFER_LENGTH" value of 150 in ../src/UnitTest.cpp
rawData[150]:
rawData[150]:
-1040000
+ 250,- 500
+ 200,- 600 + 200,- 550 + 200,- 500 + 200,- 550
@ -667,7 +687,7 @@ address=0xF2 command=0x87
Send NEC with 8 bit address
Protocol=NEC Address=0xF2 Command=0x87 Raw-Data=0x78870DF2 32 bits LSB first
Send with: IrSender.sendNEC(0xF2, 0x87, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-3276750
+8850,-4500
+ 550,- 500 + 600,-1650 + 600,- 500 + 600,- 550
@ -681,10 +701,27 @@ rawData[68]:
+ 600
Sum: 67600
Repeat NEC frame for NEC2
Protocol=NEC2 Address=0xF8 Command=0xED Repeat gap=48600us Raw-Data=0x12ED07F8 32 bits LSB first
!Use the NEC2 protocol for sending!
rawData[68]:
-87300
+8950,-4400
+ 650,- 500 + 600,-1600 + 650,- 500 + 650,- 500
+ 600,-1600 + 650,-1600 + 650,-1600 + 650,-1600
+ 600,-1600 + 650,- 500 + 650,-1600 + 600,-1650
+ 600,- 500 + 650,- 500 + 600,- 500 + 650,- 500
+ 600,-1600 + 650,-1600 + 650,-1600 + 650,- 500
+ 600,- 500 + 650,- 500 + 600,- 500 + 650,-1600
+ 650,- 500 + 600,- 500 + 650,- 500 + 650,-1600
+ 600,-1650 + 600,-1600 + 650,-1600 + 650,- 500
+ 600
Sum: 67850
Send NEC with 16 bit address
Protocol=NEC Address=0xF2 Command=0x87 Raw-Data=0x78870DF2 32 bits LSB first
Send with: IrSender.sendNEC(0xF2, 0x87, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-998700
+8900,-4400
+ 600,- 500 + 600,-1650 + 600,- 550 + 600,- 500
@ -701,7 +738,7 @@ Sum: 67650
Send NEC2 with 16 bit address
Protocol=NEC Address=0xF2 Command=0x87 Raw-Data=0x78870DF2 32 bits LSB first
Send with: IrSender.sendNEC(0xF2, 0x87, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1055100
+8950,-4400
+ 600,- 500 + 650,-1600 + 650,- 500 + 600,- 500
@ -718,7 +755,7 @@ Sum: 67800
Send Onkyo (NEC with 16 bit command)
Protocol=Onkyo Address=0xF2 Command=0x8887 Raw-Data=0x888700F2 32 bits LSB first
Send with: IrSender.sendOnkyo(0xF2, 0x8887, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1053400
+8850,-4400
+ 600,- 550 + 600,-1650 + 600,- 500 + 600,- 550
@ -735,7 +772,7 @@ Sum: 62050
Send Apple
Protocol=Apple Address=0xF2 Command=0x87 Raw-Data=0xF28787EE 32 bits LSB first
Send with: IrSender.sendApple(0xF2, 0x87, <numberOfRepeats>);
rawData[68]:
rawData[68]:
-1054100
+8900,-4450
+ 550,- 550 + 600,-1650 + 600,-1650 + 600,-1650

View File

@ -7,7 +7,7 @@
"type": "git",
"url": "https://github.com/z3t0/Arduino-IRremote.git"
},
"version": "4.2.1",
"version": "4.3.0",
"frameworks": "arduino",
"platforms": ["atmelavr", "atmelmegaavr", "atmelsam", "espressif8266", "espressif32", "ststm32"],
"authors" :

View File

@ -1,9 +1,9 @@
name=IRremote
version=4.2.1
version=4.3.0
author=shirriff, z3t0, ArminJo
maintainer=Armin Joachimsmeyer <armin.arduino@gmail.com>
sentence=Send and receive infrared signals with multiple protocols
paragraph=Currently included protocols: Denon / Sharp, JVC, LG / LG2, NEC / Onkyo / Apple, Panasonic / Kaseikyo, RC5, RC6, Samsung, Sony, (Pronto), BangOlufsen, BoseWave, Lego, Whynter, FAST, MagiQuest. NEW: TinyReceiver 2.0 and minor fixes.
paragraph=Currently included protocols: Denon / Sharp, JVC, LG / LG2, NEC / Onkyo / Apple, Panasonic / Kaseikyo, RC5, RC6, Samsung, Sony, (Pronto), BangOlufsen, BoseWave, Lego, Whynter, FAST, MagiQuest, Universal Pulse Distance and Pulse Width. NEW: TinyRSender improvements, sendSamsung bug fixes, new fields rawlen and initialGap and new functions stop/startTimer...().
category=Communication
url=https://github.com/Arduino-IRremote/Arduino-IRremote
architectures=avr,megaavr,samd,esp8266,esp32,stm32,STM32F1,mbed,mbed_nano,rp2040,mbed_rp2040,renesas_uno

View File

@ -58,8 +58,8 @@ typedef enum {
RC5,
RC6,
SAMSUNG,
SAMSUNGLG,
SAMSUNG48,
SAMSUNG_LG,
SHARP,
SONY,
/* Now the exotic protocols */
@ -71,7 +71,6 @@ typedef enum {
FAST
} decode_type_t;
#define SIRCS_12_PROTOCOL 12
#define SIRCS_15_PROTOCOL 15
#define SIRCS_20_PROTOCOL 20
@ -95,6 +94,7 @@ struct DistanceWidthTimingInfoStruct {
#define IRDATA_FLAGS_TOGGLE_BIT 0x08 ///< Is set if RC5 or RC6 toggle bit is set.
#define IRDATA_TOGGLE_BIT_MASK 0x08 ///< deprecated -is set if RC5 or RC6 toggle bit is set.
#define IRDATA_FLAGS_EXTRA_INFO 0x10 ///< There is extra info not contained in address and data (e.g. Kaseikyo unknown vendor ID, or in decodedRawDataArray).
#define IRDATA_FLAGS_IS_PROTOCOL_WITH_DIFFERENT_REPEAT 0x20 ///< Here we have a repeat of type NEC2 or SamsungLG
#define IRDATA_FLAGS_WAS_OVERFLOW 0x40 ///< irparams.rawlen is set to 0 in this case to avoid endless OverflowFlag.
#define IRDATA_FLAGS_IS_MSB_FIRST 0x80 ///< Value is mainly determined by the (known) protocol.
#define IRDATA_FLAGS_IS_LSB_FIRST 0x00
@ -117,6 +117,15 @@ struct IRData {
#endif
uint16_t numberOfBits; ///< Number of bits received for data (address + command + parity) - to determine protocol length if different length are possible.
uint8_t flags; ///< IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above
//These 2 variables allow to call resume() directly after decode, if no dump is required. Since 4.3.0.
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
uint_fast8_t rawlen; ///< counter of entries in rawbuf
#else
uint_fast16_t rawlen; ///< counter of entries in rawbuf
#endif
uint16_t initialGap; ///< rawbuf[0] contains the initial gap of the last frame.
irparams_struct *rawDataPtr; ///< Pointer of the raw timing data to be decoded. Mainly the OverflowFlag and the data buffer filled by receiving ISR.
};

View File

@ -63,8 +63,8 @@ const char string_Kaseikyo_Mitsubishi[] PROGMEM = "Kaseikyo_Mitsubishi";
const char string_RC5[] PROGMEM = "RC5";
const char string_RC6[] PROGMEM = "RC6";
const char string_Samsung[] PROGMEM = "Samsung";
const char string_Samsung48[] PROGMEM = "Samsung48";
const char string_SamsungLG[] PROGMEM = "SamsungLG";
const char string_Samsung48[] PROGMEM = "Samsung48";
const char string_Sharp[] PROGMEM = "Sharp";
const char string_Sony[] PROGMEM = "Sony";
const char string_BangOlufsen[] PROGMEM = "Bang&Olufsen";
@ -80,7 +80,7 @@ const char string_FAST[] PROGMEM = "FAST";
const char *const ProtocolNames[]
PROGMEM = { string_Unknown, string_PulseWidth, string_PulseDistance, string_Apple, string_Denon, string_JVC, string_LG, string_LG2,
string_NEC, string_NEC2, string_Onkyo, string_Panasonic, string_Kaseikyo, string_Kaseikyo_Denon, string_Kaseikyo_Sharp,
string_Kaseikyo_JVC, string_Kaseikyo_Mitsubishi, string_RC5, string_RC6, string_Samsung, string_Samsung48, string_SamsungLG,
string_Kaseikyo_JVC, string_Kaseikyo_Mitsubishi, string_RC5, string_RC6, string_Samsung, string_SamsungLG, string_Samsung48,
string_Sharp, string_Sony
#if !defined(EXCLUDE_EXOTIC_PROTOCOLS)
, string_BangOlufsen, string_BoseWave, string_Lego, string_MagiQuest, string_Whynter, string_FAST
@ -178,7 +178,7 @@ void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintRepeatGap
#endif
#if !defined(DISABLE_CODE_FOR_RECEIVER)
aSerial->print(' ');
aSerial->print((aIRDataPtr->rawDataPtr->rawlen + 1) / 2, DEC);
aSerial->print((aIRDataPtr->rawlen + 1) / 2, DEC);
aSerial->println(F(" bits (incl. gap and start) received"));
#endif
} else {
@ -218,7 +218,7 @@ void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintRepeatGap
#if !defined(DISABLE_CODE_FOR_RECEIVER)
if (aPrintRepeatGap) {
aSerial->print(F(" gap="));
aSerial->print((uint32_t) aIRDataPtr->rawDataPtr->rawbuf[0] * MICROS_PER_TICK);
aSerial->print((uint32_t) aIRDataPtr->initialGap * MICROS_PER_TICK);
aSerial->print(F("us"));
}
#else

View File

@ -342,6 +342,19 @@ void IRrecv::start() {
pinModeFast(_IR_TIMING_TEST_PIN, OUTPUT);
#endif
}
/*
* Do not resume() reading of IR data
*/
void IRrecv::restartTimer() {
// Setup for cyclic 50 us interrupt
timerConfigForReceive(); // no interrupts enabled here!
// Timer interrupt is enabled after state machine reset
timerEnableReceiveInterrupt(); // Enables the receive sample timer interrupt which consumes a small amount of CPU every 50 us.
#ifdef _IR_MEASURE_TIMING
pinModeFast(_IR_TIMING_TEST_PIN, OUTPUT);
#endif
}
/**
* Alias for start().
*/
@ -358,10 +371,18 @@ void IRrecv::start(uint32_t aMicrosecondsToAddToGapCounter) {
irparams.TickCounterForISR += aMicrosecondsToAddToGapCounter / MICROS_PER_TICK;
start();
}
void IRrecv::restartTimer(uint32_t aMicrosecondsToAddToGapCounter) {
irparams.TickCounterForISR += aMicrosecondsToAddToGapCounter / MICROS_PER_TICK;
restartTimer();
}
void IRrecv::startWithTicksToAdd(uint16_t aTicksToAddToGapCounter) {
irparams.TickCounterForISR += aTicksToAddToGapCounter;
start();
}
void IRrecv::restartTimerWithTicksToAdd(uint16_t aTicksToAddToGapCounter) {
irparams.TickCounterForISR += aTicksToAddToGapCounter;
restartTimer();
}
void IRrecv::addTicksToInternalTickCounter(uint16_t aTicksToAddToInternalTickCounter) {
irparams.TickCounterForISR += aTicksToAddToInternalTickCounter;
@ -385,6 +406,10 @@ void IRrecv::restartAfterSend() {
void IRrecv::stop() {
timerDisableReceiveInterrupt();
}
void IRrecv::stopTimer() {
timerDisableReceiveInterrupt();
}
/**
* Alias for stop().
*/
@ -408,7 +433,7 @@ bool IRrecv::isIdle() {
/**
* Restart the ISR (Interrupt Service Routine) state machine, to enable receiving of the next IR frame.
* Counting of gap timing is independent of StateForISR and therefore independent of call time of resume().
* Internal counting of gap timing is independent of StateForISR and therefore independent of call time of resume().
*/
void IRrecv::resume() {
// This check allows to call resume at arbitrary places or more than once
@ -434,11 +459,16 @@ void IRrecv::initDecodedIRData() {
} else {
decodedIRData.flags = IRDATA_FLAGS_EMPTY;
// save last protocol, command and address for repeat handling (where they are compared or copied back :-))
lastDecodedProtocol = decodedIRData.protocol; // repeat patterns can be equal between protocols (e.g. NEC and LG), so we must keep the original one
lastDecodedProtocol = decodedIRData.protocol; // repeat patterns can be equal between protocols (e.g. NEC, Samsung and LG), so we must keep the original one
lastDecodedCommand = decodedIRData.command;
lastDecodedAddress = decodedIRData.address;
}
//These 2 variables allow to call resume() directly after decode, if no dump is required. since 4.3.0.
decodedIRData.initialGap = decodedIRData.rawDataPtr->rawbuf[0];
decodedIRData.rawlen = decodedIRData.rawDataPtr->rawlen;
decodedIRData.protocol = UNKNOWN;
decodedIRData.command = 0;
decodedIRData.address = 0;
@ -834,7 +864,7 @@ void IRrecv::initBiphaselevel(uint_fast8_t aRCDecodeRawbuffOffset, uint16_t aBip
uint_fast8_t IRrecv::getBiphaselevel() {
uint_fast8_t tLevelOfCurrentInterval; // 0 (SPACE) or 1 (MARK)
if (sBiphaseDecodeRawbuffOffset >= decodedIRData.rawDataPtr->rawlen) {
if (sBiphaseDecodeRawbuffOffset >= decodedIRData.rawlen) {
return SPACE; // After end of recorded buffer, assume space.
}
@ -917,7 +947,7 @@ bool IRrecv::decodeHash() {
unsigned long hash = FNV_BASIS_32; // the result is the same no matter if we use a long or unsigned long variable
// Require at least 6 samples to prevent triggering on noise
if (decodedIRData.rawDataPtr->rawlen < 6) {
if (decodedIRData.rawlen < 6) {
return false;
}
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
@ -925,7 +955,7 @@ bool IRrecv::decodeHash() {
#else
unsigned int i;
#endif
for (i = 1; (i + 2) < decodedIRData.rawDataPtr->rawlen; i++) {
for (i = 1; (i + 2) < decodedIRData.rawlen; i++) {
uint_fast8_t value = compare(decodedIRData.rawDataPtr->rawbuf[i], decodedIRData.rawDataPtr->rawbuf[i + 2]);
// Add value into the hash
hash = (hash * FNV_PRIME_32) ^ value;
@ -1114,10 +1144,10 @@ bool IRrecv::checkForRecordGapsMicros(Print *aSerial) {
* is smaller than known value for protocols (Sony with around 24 ms)
*/
if (decodedIRData.protocol <= PULSE_DISTANCE
&& decodedIRData.rawDataPtr->rawbuf[0] < (RECORD_GAP_MICROS_WARNING_THRESHOLD / MICROS_PER_TICK)) {
&& decodedIRData.initialGap < (RECORD_GAP_MICROS_WARNING_THRESHOLD / MICROS_PER_TICK)) {
aSerial->println();
aSerial->print(F("Space of "));
aSerial->print(decodedIRData.rawDataPtr->rawbuf[0] * MICROS_PER_TICK);
aSerial->print(decodedIRData.initialGap * MICROS_PER_TICK);
aSerial->print(F(" us between two detected transmission is smaller than the minimal gap of "));
aSerial->print(RECORD_GAP_MICROS_WARNING_THRESHOLD);
aSerial->println(F(" us known for implemented protocols like NEC, Sony, RC% etc.."));
@ -1234,7 +1264,7 @@ void IRrecv::printDistanceWidthTimingInfo(Print *aSerial, DistanceWidthTimingInf
uint32_t IRrecv::getTotalDurationOfRawData() {
uint16_t tSumOfDurationTicks = 0;
for (uint_fast8_t i = 1; i < decodedIRData.rawDataPtr->rawlen; i++) {
for (uint_fast8_t i = 1; i < decodedIRData.rawlen; i++) {
tSumOfDurationTicks += decodedIRData.rawDataPtr->rawbuf[i];
}
return tSumOfDurationTicks * (uint32_t) MICROS_PER_TICK;
@ -1248,19 +1278,27 @@ uint32_t IRrecv::getTotalDurationOfRawData() {
* @param aSerial The Print object on which to write, for Arduino you can use &Serial.
*/
void IRrecv::printIRSendUsage(Print *aSerial) {
if (decodedIRData.protocol != UNKNOWN
&& (decodedIRData.flags & (IRDATA_FLAGS_IS_AUTO_REPEAT | IRDATA_FLAGS_IS_REPEAT)) == 0x00) {
if (decodedIRData.flags & IRDATA_FLAGS_IS_PROTOCOL_WITH_DIFFERENT_REPEAT) {
/*
* Here we have a repeat of type NEC2 or SamsungLG. -> Inform the user to use this and not the initial protocol for sending.
*/
Serial.print(F("!Use the "));
Serial.print(getProtocolString());
Serial.println(F(" protocol for sending!"));
} else {
if (decodedIRData.protocol != UNKNOWN
&& (decodedIRData.flags & (IRDATA_FLAGS_IS_AUTO_REPEAT | IRDATA_FLAGS_IS_REPEAT)) == 0x00) {
#if defined(DECODE_DISTANCE_WIDTH)
uint_fast8_t tNumberOfArrayData = 0;
if (decodedIRData.protocol == PULSE_DISTANCE || decodedIRData.protocol == PULSE_WIDTH) {
# if __INT_WIDTH__ < 32
aSerial->print(F("Send on a 8 bit platform with:"));
aSerial->print(F("Send on a 8 bit platform with: "));
tNumberOfArrayData = ((decodedIRData.numberOfBits - 1) / 32) + 1;
if(tNumberOfArrayData > 1) {
aSerial->println();
aSerial->print(F(" uint32_t tRawData[]={0x"));
# else
aSerial->print(F("Send on a 32 bit platform with:"));
aSerial->print(F("Send on a 32 bit platform with: "));
tNumberOfArrayData = ((decodedIRData.numberOfBits - 1) / 64) + 1;
if(tNumberOfArrayData > 1) {
aSerial->println();
@ -1277,19 +1315,22 @@ void IRrecv::printIRSendUsage(Print *aSerial) {
}
}
aSerial->println(F("};"));
aSerial->print(F(" "));
aSerial->print(F(" "));
}
} else {
aSerial->print(F("Send with: "));
}
aSerial->print(F(" IrSender.send"));
aSerial->print(F("IrSender.send"));
#else
aSerial->print(F("Send with: IrSender.send"));
aSerial->print(F("Send with: IrSender.send"));
#endif
#if defined(DECODE_DISTANCE_WIDTH)
if (decodedIRData.protocol != PULSE_DISTANCE && decodedIRData.protocol != PULSE_WIDTH) {
#endif
aSerial->print(getProtocolString());
aSerial->print(F("(0x"));
aSerial->print(getProtocolString());
aSerial->print(F("(0x"));
#if defined(DECODE_MAGIQUEST)
if (decodedIRData.protocol == MAGIQUEST) {
# if (__INT_WIDTH__ < 32)
@ -1301,20 +1342,20 @@ void IRrecv::printIRSendUsage(Print *aSerial) {
aSerial->print(decodedIRData.address, HEX);
}
#else
/*
* New decoders have address and command
*/
aSerial->print(decodedIRData.address, HEX);
/*
* New decoders have address and command
*/
aSerial->print(decodedIRData.address, HEX);
#endif
aSerial->print(F(", 0x"));
aSerial->print(decodedIRData.command, HEX);
if (decodedIRData.protocol == SONY) {
aSerial->print(F(", 2, "));
aSerial->print(decodedIRData.numberOfBits);
} else {
aSerial->print(F(", <numberOfRepeats>"));
}
aSerial->print(F(", 0x"));
aSerial->print(decodedIRData.command, HEX);
if (decodedIRData.protocol == SONY) {
aSerial->print(F(", 2, "));
aSerial->print(decodedIRData.numberOfBits);
} else {
aSerial->print(F(", <numberOfRepeats>"));
}
#if defined(DECODE_DISTANCE_WIDTH)
} else {
@ -1357,14 +1398,10 @@ void IRrecv::printIRSendUsage(Print *aSerial) {
aSerial->print(decodedIRData.extra, HEX);
}
#endif
aSerial->print(F(");"));
aSerial->println();
aSerial->print(F(");"));
aSerial->println();
}
}
#if defined(DECODE_DISTANCE_WIDTH)
else {
aSerial->print(F("Send with:"));
}
#endif
}
/**
@ -1386,7 +1423,7 @@ void IRrecv::printIRResultMinimal(Print *aSerial) {
# endif
#endif
aSerial->print(' ');
aSerial->print((decodedIRData.rawDataPtr->rawlen + 1) / 2, DEC);
aSerial->print((decodedIRData.rawlen + 1) / 2, DEC);
aSerial->println(F(" bits received"));
} else {
/*
@ -1419,7 +1456,7 @@ void IRrecv::printIRResultMinimal(Print *aSerial) {
*/
void IRrecv::printIRResultRawFormatted(Print *aSerial, bool aOutputMicrosecondsInsteadOfTicks) {
uint8_t tRawlen = decodedIRData.rawDataPtr->rawlen; // Get it once here in order to print quite consistent data, even if ISR is running
uint8_t tRawlen = decodedIRData.rawlen; // Get it once here in order to print quite consistent data, even if ISR is running
// Print Raw data
aSerial->print(F("rawData["));
aSerial->print(tRawlen, DEC);
@ -1430,9 +1467,9 @@ void IRrecv::printIRResultRawFormatted(Print *aSerial, bool aOutputMicrosecondsI
*/
aSerial->print(F(" -"));
if (aOutputMicrosecondsInsteadOfTicks) {
aSerial->println((uint32_t) decodedIRData.rawDataPtr->rawbuf[0] * MICROS_PER_TICK, DEC);
aSerial->println((uint32_t) decodedIRData.initialGap * MICROS_PER_TICK, DEC);
} else {
aSerial->println(decodedIRData.rawDataPtr->rawbuf[0], DEC);
aSerial->println(decodedIRData.initialGap, DEC);
}
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
uint_fast8_t i;
@ -1524,7 +1561,7 @@ void IRrecv::compensateAndPrintIRResultAsCArray(Print *aSerial, bool aOutputMicr
aSerial->print(F("uint8_t rawTicks[")); // variable type, array name
}
aSerial->print(decodedIRData.rawDataPtr->rawlen - 1, DEC); // array size
aSerial->print(decodedIRData.rawlen - 1, DEC); // array size
aSerial->print(F("] = {")); // Start declaration
// Dump data
@ -1533,7 +1570,7 @@ void IRrecv::compensateAndPrintIRResultAsCArray(Print *aSerial, bool aOutputMicr
#else
unsigned int i;
#endif
for (i = 1; i < decodedIRData.rawDataPtr->rawlen; i++) {
for (i = 1; i < decodedIRData.rawlen; i++) {
uint32_t tDuration = decodedIRData.rawDataPtr->rawbuf[i] * MICROS_PER_TICK;
if (i & 1) {
@ -1553,10 +1590,8 @@ void IRrecv::compensateAndPrintIRResultAsCArray(Print *aSerial, bool aOutputMicr
tTicks = (tTicks > UINT8_MAX) ? UINT8_MAX : tTicks;
aSerial->print(tTicks);
}
if (i + 1 < decodedIRData.rawDataPtr->rawlen)
aSerial->print(','); // ',' not required on last one
if (!(i & 1))
aSerial->print(' ');
if (i + 1 < decodedIRData.rawlen) aSerial->print(','); // ',' not required on last one
if (!(i & 1)) aSerial->print(' ');
}
// End declaration
@ -1585,9 +1620,9 @@ void IRrecv::compensateAndStoreIRResultInArray(uint8_t *aArrayPtr) {
#if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
uint_fast8_t i;
#else
unsigned int i;
unsigned int i;
#endif
for (i = 1; i < decodedIRData.rawDataPtr->rawlen; i++) {
for (i = 1; i < decodedIRData.rawlen; i++) {
uint32_t tDuration = decodedIRData.rawDataPtr->rawbuf[i] * MICROS_PER_TICK;
if (i & 1) {
// Mark

View File

@ -220,7 +220,7 @@ size_t IRsend::write(IRData *aIRSendData, int_fast8_t aNumberOfRepeats) {
} else if (tProtocol == SAMSUNG48) {
sendSamsung48(tAddress, tCommand, aNumberOfRepeats);
} else if (tProtocol == SAMSUNG_LG) {
} else if (tProtocol == SAMSUNGLG) {
sendSamsungLG(tAddress, tCommand, aNumberOfRepeats);
} else if (tProtocol == SONY) {
@ -341,7 +341,7 @@ size_t IRsend::write(decode_type_t aProtocol, uint16_t aAddress, uint16_t aComma
} else if (aProtocol == SAMSUNG48) {
sendSamsung48(aAddress, aCommand, aNumberOfRepeats);
} else if (aProtocol == SAMSUNG_LG) {
} else if (aProtocol == SAMSUNGLG) {
sendSamsungLG(aAddress, aCommand, aNumberOfRepeats);
} else if (aProtocol == SONY) {
@ -693,10 +693,14 @@ void IRsend::sendPulseDistanceWidth(PulseDistanceWidthProtocolConstants *aProtoc
if (aNumberOfRepeats < 0) {
if (aProtocolConstants->SpecialSendRepeatFunction != NULL) {
/*
* Send only a special repeat and return
*/
aProtocolConstants->SpecialSendRepeatFunction();
return;
} else {
aNumberOfRepeats = 0; // send a plain frame as repeat
// Send only one plain frame (as repeat)
aNumberOfRepeats = 0;
}
}
@ -708,7 +712,7 @@ void IRsend::sendPulseDistanceWidth(PulseDistanceWidthProtocolConstants *aProtoc
unsigned long tStartOfFrameMillis = millis();
if (tNumberOfCommands < ((uint_fast8_t) aNumberOfRepeats + 1) && aProtocolConstants->SpecialSendRepeatFunction != NULL) {
// send special repeat
// send special repeat, if specified and we are not in the first loop
aProtocolConstants->SpecialSendRepeatFunction();
} else {
/*
@ -722,12 +726,12 @@ void IRsend::sendPulseDistanceWidth(PulseDistanceWidthProtocolConstants *aProtoc
tNumberOfCommands--;
// skip last delay!
if (tNumberOfCommands > 0) {
auto tCurrentFrameDurationMillis = millis() - tStartOfFrameMillis;
/*
* Check and fallback for wrong RepeatPeriodMillis parameter. I.e the repeat period must be greater than each frame duration.
*/
auto tFrameDurationMillis = millis() - tStartOfFrameMillis;
if (aProtocolConstants->RepeatPeriodMillis > tFrameDurationMillis) {
delay(aProtocolConstants->RepeatPeriodMillis - tFrameDurationMillis);
if (aProtocolConstants->RepeatPeriodMillis > tCurrentFrameDurationMillis) {
delay(aProtocolConstants->RepeatPeriodMillis - tCurrentFrameDurationMillis);
}
}
}

View File

@ -36,10 +36,10 @@
#ifndef _IR_VERSION_HPP
#define _IR_VERSION_HPP
#define VERSION_IRREMOTE "4.2.1"
#define VERSION_IRREMOTE "4.3.0"
#define VERSION_IRREMOTE_MAJOR 4
#define VERSION_IRREMOTE_MINOR 2
#define VERSION_IRREMOTE_PATCH 1
#define VERSION_IRREMOTE_MINOR 3
#define VERSION_IRREMOTE_PATCH 0
/*
* Macro to convert 3 version parts into an integer

View File

@ -186,10 +186,13 @@ public:
*/
void begin(uint_fast8_t aReceivePin, bool aEnableLEDFeedback = false, uint_fast8_t aFeedbackLEDPin =
USE_DEFAULT_FEEDBACK_LED_PIN);
void restartTimer();
void start();
void enableIRIn(); // alias for start
void start(uint32_t aMicrosecondsToAddToGapCounter);
void restartTimer(uint32_t aMicrosecondsToAddToGapCounter);
void startWithTicksToAdd(uint16_t aTicksToAddToGapCounter);
void restartTimerWithTicksToAdd(uint16_t aTicksToAddToGapCounter);
void restartAfterSend();
void addTicksToInternalTickCounter(uint16_t aTicksToAddToInternalTickCounter);
@ -199,6 +202,7 @@ public:
IRData* read(); // returns decoded data
// write is a method of class IRsend below
// size_t write(IRData *aIRSendData, int_fast8_t aNumberOfRepeats = NO_REPEATS);
void stopTimer();
void stop();
void disableIRIn(); // alias for stop
void end(); // alias for stop
@ -314,7 +318,7 @@ public:
void checkForRepeatSpaceTicksAndSetFlag(uint16_t aMaximumRepeatSpaceTicks);
bool checkForRecordGapsMicros(Print *aSerial);
IRData decodedIRData; // New: decoded IR data for the application
IRData decodedIRData; // Decoded IR data for the application
// Last decoded IR data for repeat detection and parity for Denon autorepeat
decode_type_t lastDecodedProtocol;
@ -535,6 +539,7 @@ public:
void sendRC6(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle = true);
void sendSamsungLGRepeat();
void sendSamsung(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
void sendSamsung16BitAddressAndCommand(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
void sendSamsung48(uint16_t aAddress, uint32_t aCommand, int_fast8_t aNumberOfRepeats);
void sendSamsungLG(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats);
void sendSharp(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats); // redirected to sendDenon

View File

@ -289,9 +289,9 @@ static bool matchBeoLength(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros)
bool IRrecv::decodeBangOlufsen() {
#if defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
if (decodedIRData.rawDataPtr->rawlen != 6 && decodedIRData.rawDataPtr->rawlen < 36) { // 16 bits minimum
if (decodedIRData.rawlen != 6 && decodedIRData.rawlen < 36) { // 16 bits minimum
#else
if (decodedIRData.rawDataPtr->rawlen < 44) { // 16 bits minimum
if (decodedIRData.rawlen < 44) { // 16 bits minimum
#endif
return false;
}
@ -307,15 +307,15 @@ bool IRrecv::decodeBangOlufsen() {
uint8_t tBitNumber = 0;
BEO_TRACE_PRINT(F("Pre gap: "));
BEO_TRACE_PRINT(decodedIRData.rawDataPtr->rawbuf[0] * 50);
BEO_TRACE_PRINT(decodedIRData.initialGap * 50);
BEO_TRACE_PRINT(F(" raw len: "));
BEO_TRACE_PRINTLN(decodedIRData.rawDataPtr->rawlen);
BEO_TRACE_PRINTLN(decodedIRData.rawlen);
#if defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
/*
* Check if we have the AGC part of the first frame in a row
*/
if (decodedIRData.rawDataPtr->rawlen == 6) {
if (decodedIRData.rawlen == 6) {
if ((matchMark(decodedIRData.rawDataPtr->rawbuf[3], BEO_IR_MARK)
|| matchMark(decodedIRData.rawDataPtr->rawbuf[3], BEO_DATALINK_MARK))
&& (matchSpace(decodedIRData.rawDataPtr->rawbuf[4], BEO_PULSE_LENGTH_ZERO - BEO_IR_MARK)
@ -329,7 +329,7 @@ bool IRrecv::decodeBangOlufsen() {
/*
* Check if leading gap is trailing bit of first frame
*/
if (!matchSpace(decodedIRData.rawDataPtr->rawbuf[0], BEO_PULSE_LENGTH_START_BIT)) {
if (!matchSpace(decodedIRData.initialGap, BEO_PULSE_LENGTH_START_BIT)) {
BEO_TRACE_PRINT(::getProtocolString(BANG_OLUFSEN));
BEO_TRACE_PRINTLN(F(": Leading gap is wrong")); // Leading gap is trailing bit of first frame
return false; // no B&O protocol
@ -348,9 +348,9 @@ bool IRrecv::decodeBangOlufsen() {
}
// skip first zero header bit
for (uint8_t tRawBufferMarkIndex = 3; tRawBufferMarkIndex < decodedIRData.rawDataPtr->rawlen; tRawBufferMarkIndex += 2) {
for (uint8_t tRawBufferMarkIndex = 3; tRawBufferMarkIndex < decodedIRData.rawlen; tRawBufferMarkIndex += 2) {
#else
for (uint8_t tRawBufferMarkIndex = 1; tRawBufferMarkIndex < decodedIRData.rawDataPtr->rawlen; tRawBufferMarkIndex += 2) {
for (uint8_t tRawBufferMarkIndex = 1; tRawBufferMarkIndex < decodedIRData.rawlen; tRawBufferMarkIndex += 2) {
#endif
uint16_t markLength = decodedIRData.rawDataPtr->rawbuf[tRawBufferMarkIndex];
@ -426,7 +426,7 @@ bool IRrecv::decodeBangOlufsen() {
break;
}
#if !defined(ENABLE_BEO_WITHOUT_FRAME_GAP)
if (tRawBufferMarkIndex >= decodedIRData.rawDataPtr->rawlen - 3) { // (rawlen - 3) is index of trailing bit mark
if (tRawBufferMarkIndex >= decodedIRData.rawlen - 3) { // (rawlen - 3) is index of trailing bit mark
BEO_DEBUG_PRINT(::getProtocolString(BANG_OLUFSEN));
BEO_DEBUG_PRINTLN(F(": End of buffer, but no trailing bit detected"));
return false;
@ -467,7 +467,7 @@ bool IRrecv::decodeBangOlufsen() {
/*
* Check for last bit after decoding it
*/
if (tRawBufferMarkIndex >= decodedIRData.rawDataPtr->rawlen - 3) { // (rawlen - 3) is index of last bit mark
if (tRawBufferMarkIndex >= decodedIRData.rawlen - 3) { // (rawlen - 3) is index of last bit mark
BEO_TRACE_PRINT(::getProtocolString(BANG_OLUFSEN));
BEO_TRACE_PRINTLN(F(": Last bit reached"));
break;

View File

@ -68,10 +68,10 @@ bool IRrecv::decodeBoseWave() {
}
// Check we have enough data +4 for initial gap, start bit mark and space + stop bit mark
if (decodedIRData.rawDataPtr->rawlen != (2 * BOSEWAVE_BITS) + 4) {
if (decodedIRData.rawlen != (2 * BOSEWAVE_BITS) + 4) {
IR_DEBUG_PRINT(F("Bose: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is not 36"));
return false;
}

View File

@ -156,10 +156,10 @@ bool IRrecv::decodeDenon() {
// we have no start bit, so check for the exact amount of data bits
// Check we have the right amount of data (32). The + 2 is for initial gap + stop bit mark
if (decodedIRData.rawDataPtr->rawlen != (2 * DENON_BITS) + 2) {
if (decodedIRData.rawlen != (2 * DENON_BITS) + 2) {
IR_DEBUG_PRINT(F("Denon: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is not 32"));
return false;
}
@ -189,7 +189,7 @@ bool IRrecv::decodeDenon() {
decodedIRData.command &= 0xFF;
// Check for (auto) repeat
if (decodedIRData.rawDataPtr->rawbuf[0] < ((DENON_AUTO_REPEAT_DISTANCE + (DENON_AUTO_REPEAT_DISTANCE / 4)) / MICROS_PER_TICK)) {
if (decodedIRData.initialGap < ((DENON_AUTO_REPEAT_DISTANCE + (DENON_AUTO_REPEAT_DISTANCE / 4)) / MICROS_PER_TICK)) {
repeatCount++;
if (repeatCount > 1) { // skip first auto repeat
decodedIRData.flags = IRDATA_FLAGS_IS_REPEAT;
@ -280,7 +280,7 @@ void IRsend::sendSharp(uint16_t aAddress, uint16_t aCommand) {
bool IRrecv::decodeDenonOld(decode_results *aResults) {
// Check we have the right amount of data
if (decodedIRData.rawDataPtr->rawlen != 1 + 2 + (2 * DENON_BITS) + 1) {
if (decodedIRData.rawlen != 1 + 2 + (2 * DENON_BITS) + 1) {
return false;
}

View File

@ -155,10 +155,10 @@ bool IRrecv::decodeDistanceWidth() {
/*
* Accept only protocols with at least 8 bits
*/
if (decodedIRData.rawDataPtr->rawlen < (2 * 8) + 4) {
if (decodedIRData.rawlen < (2 * 8) + 4) {
IR_DEBUG_PRINT(F("PULSE_DISTANCE_WIDTH: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is less than 20"));
return false;
}
@ -172,7 +172,7 @@ bool IRrecv::decodeDistanceWidth() {
/*
* Count number of mark durations up to 49 ticks. Skip leading start and trailing stop bit.
*/
for (i = 3; i < (uint_fast8_t) decodedIRData.rawDataPtr->rawlen - 2; i += 2) {
for (i = 3; i < (uint_fast8_t) decodedIRData.rawlen - 2; i += 2) {
auto tDurationTicks = decodedIRData.rawDataPtr->rawbuf[i];
if (tDurationTicks < DURATION_ARRAY_SIZE) {
tDurationArray[tDurationTicks]++; // count duration if less than DURATION_ARRAY_SIZE (50)
@ -219,7 +219,7 @@ bool IRrecv::decodeDistanceWidth() {
* Count number of space durations. Skip leading start and trailing stop bit.
*/
tIndexOfMaxDuration = 0;
for (i = 4; i < (uint_fast8_t) decodedIRData.rawDataPtr->rawlen - 2; i += 2) {
for (i = 4; i < (uint_fast8_t) decodedIRData.rawlen - 2; i += 2) {
auto tDurationTicks = decodedIRData.rawDataPtr->rawbuf[i];
if (tDurationTicks < DURATION_ARRAY_SIZE) {
tDurationArray[tDurationTicks]++;
@ -286,7 +286,7 @@ bool IRrecv::decodeDistanceWidth() {
#endif
uint8_t tStartIndex = 3;
// skip leading start bit for decoding.
uint16_t tNumberOfBits = (decodedIRData.rawDataPtr->rawlen / 2) - 1;
uint16_t tNumberOfBits = (decodedIRData.rawlen / 2) - 1;
if (tSpaceTicksLong > 0 && tMarkTicksLong == 0) {
// For PULSE_DISTANCE a stop bit is mandatory, for PULSE_WIDTH it is not required!
tNumberOfBits--; // Correct for stop bit

View File

@ -96,13 +96,13 @@ void IRsend::sendFAST(uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
bool IRrecv::decodeFAST() {
// uint_fast8_t tRawlen = decodedIRData.rawDataPtr->rawlen; // Using a local variable does not improve code size
// uint_fast8_t tRawlen = decodedIRData.rawlen; // Using a local variable does not improve code size
// Check we have the right amount of data (36). The +4 is for initial gap, start bit mark and space + stop bit mark.
if (decodedIRData.rawDataPtr->rawlen != ((2 * FAST_BITS) + 4)) {
if (decodedIRData.rawlen != ((2 * FAST_BITS) + 4)) {
IR_DEBUG_PRINT(F("FAST: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is not 36"));
return false;
}

View File

@ -118,26 +118,26 @@ void IRsend::sendJVC(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRe
bool IRrecv::decodeJVC() {
// uint_fast8_t tRawlen = decodedIRData.rawDataPtr->rawlen; // Using a local variable does not improve code size
// uint_fast8_t tRawlen = decodedIRData.rawlen; // Using a local variable does not improve code size
// Check we have the right amount of data (36 or 34). The +4 is for initial gap, start bit mark and space + stop bit mark.
// +4 is for first frame, +2 is for repeats
if (decodedIRData.rawDataPtr->rawlen != ((2 * JVC_BITS) + 2) && decodedIRData.rawDataPtr->rawlen != ((2 * JVC_BITS) + 4)) {
if (decodedIRData.rawlen != ((2 * JVC_BITS) + 2) && decodedIRData.rawlen != ((2 * JVC_BITS) + 4)) {
IR_DEBUG_PRINT(F("JVC: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is not 34 or 36"));
return false;
}
if (decodedIRData.rawDataPtr->rawlen == ((2 * JVC_BITS) + 2)) {
if (decodedIRData.rawlen == ((2 * JVC_BITS) + 2)) {
/*
* Check for repeat
* Check leading space and first and last mark length
*/
if (decodedIRData.rawDataPtr->rawbuf[0] < ((JVC_REPEAT_DISTANCE + (JVC_REPEAT_DISTANCE / 4) / MICROS_PER_TICK))
if (decodedIRData.initialGap < ((JVC_REPEAT_DISTANCE + (JVC_REPEAT_DISTANCE / 4) / MICROS_PER_TICK))
&& matchMark(decodedIRData.rawDataPtr->rawbuf[1], JVC_BIT_MARK)
&& matchMark(decodedIRData.rawDataPtr->rawbuf[decodedIRData.rawDataPtr->rawlen - 1], JVC_BIT_MARK)) {
&& matchMark(decodedIRData.rawDataPtr->rawbuf[decodedIRData.rawlen - 1], JVC_BIT_MARK)) {
/*
* We have a repeat here, so do not check for start bit
*/

View File

@ -200,10 +200,10 @@ bool IRrecv::decodeKaseikyo() {
decode_type_t tProtocol;
// Check we have enough data (96 + 4) 4 for initial gap, start bit mark and space + stop bit mark
if (decodedIRData.rawDataPtr->rawlen != ((2 * KASEIKYO_BITS) + 4)) {
if (decodedIRData.rawlen != ((2 * KASEIKYO_BITS) + 4)) {
IR_DEBUG_PRINT(F("Kaseikyo: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is not 100"));
return false;
}

View File

@ -8,7 +8,7 @@
************************************************************************************
* MIT License
*
* Copyright (c) 2017-2023 Darryl Smith, Armin Joachimsmeyer
* Copyright (c) 2017-2024 Darryl Smith, Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -124,7 +124,7 @@ LG_ONE_SPACE, LG_BIT_MARK, LG_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST, (LG_REPEAT_PERI
* Start of send and decode functions
************************************/
/*
* Send special LG2 repeat not used yet
* Send special LG2 repeat - not used internally
*/
void IRsend::sendLG2Repeat() {
enableIROut (LG_KHZ); // 38 kHz
@ -184,30 +184,30 @@ bool IRrecv::decodeLG() {
*/
// Check we have the right amount of data (60). The +4 is for initial gap, start bit mark and space + stop bit mark.
if (decodedIRData.rawDataPtr->rawlen != ((2 * LG_BITS) + 4) && (decodedIRData.rawDataPtr->rawlen != 4)) {
if (decodedIRData.rawlen != ((2 * LG_BITS) + 4) && (decodedIRData.rawlen != 4)) {
IR_DEBUG_PRINT(F("LG: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is not 60 or 4"));
return false;
}
// Check header "mark" this must be done for repeat and data
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[1], LG_HEADER_MARK)) {
if (!matchMark(decodedIRData.rawDataPtr->rawbuf[1], LG2_HEADER_MARK)) {
if (matchMark(decodedIRData.rawDataPtr->rawbuf[1], LG2_HEADER_MARK)) {
tProtocol = LG2;
tHeaderSpace = LG2_HEADER_SPACE;
} else {
#if defined(LOCAL_DEBUG)
Serial.print(F("LG: "));
Serial.println(F("Header mark is wrong"));
#endif
return false;
} else {
tProtocol = LG2;
tHeaderSpace = LG2_HEADER_SPACE;
return false; // neither LG nor LG2 header
}
}
// Check for repeat - here we have another header space length
if (decodedIRData.rawDataPtr->rawlen == 4) {
if (decodedIRData.rawlen == 4) {
if (matchSpace(decodedIRData.rawDataPtr->rawbuf[2], LG_REPEAT_HEADER_SPACE)
&& matchMark(decodedIRData.rawDataPtr->rawbuf[3], LG_BIT_MARK)) {
decodedIRData.flags = IRDATA_FLAGS_IS_REPEAT | IRDATA_FLAGS_IS_MSB_FIRST;

View File

@ -47,13 +47,13 @@
// https://oberguru.net/elektronik/ir/codes/lego_power_functions_train.lircd.conf
//
// To ensure correct detection of IR messages six 38 kHz cycles are transmitted as mark.
// Low bit consists of 6 cycles of IR and 10 “cycles” of pause,
// high bit of 6 cycles IR and 21 “cycles” of pause and start bit of 6 cycles IR and 39 “cycles” of pause.
// Low bit consists of 6 cycles of IR and 10 <EFBFBD>cycles<EFBFBD> of pause,
// high bit of 6 cycles IR and 21 <EFBFBD>cycles<EFBFBD> of pause and start bit of 6 cycles IR and 39 <20>cycles<65> of pause.
// Low bit range 316 - 526 us
// High bit range 526 947 us
// Start/stop bit range 947 1579 us
// High bit range 526 <EFBFBD> 947 us
// Start/stop bit range 947 <EFBFBD> 1579 us
// If tm is the maximum message length (16ms) and Ch is the channel number, then
// The delay before transmitting the first message is: (4 Ch)*tm
// The delay before transmitting the first message is: (4 <EFBFBD> Ch)*tm
// The time from start to start for the next 2 messages is: 5*tm
// The time from start to start for the following messages is: (6 + 2*Ch)*tm
// Supported Devices
@ -186,7 +186,7 @@ bool IRrecv::decodeLegoPowerFunctions() {
/*
* Check for autorepeat (should happen 4 times for one press)
*/
if (decodedIRData.rawDataPtr->rawbuf[0] < (LEGO_AUTO_REPEAT_PERIOD_MAX / MICROS_PER_TICK)) {
if (decodedIRData.initialGap < (LEGO_AUTO_REPEAT_PERIOD_MAX / MICROS_PER_TICK)) {
decodedIRData.flags |= IRDATA_FLAGS_IS_AUTO_REPEAT;
}
decodedIRData.address = tToggleEscapeChannel;

View File

@ -151,10 +151,10 @@ void IRsend::sendMagiQuest(uint32_t aWandId, uint16_t aMagnitude) {
bool IRrecv::decodeMagiQuest() {
// Check we have the right amount of data, magnitude and ID bits and 8 start bits + 0 stop bit
if (decodedIRData.rawDataPtr->rawlen != (2 * MAGIQUEST_BITS)) {
if (decodedIRData.rawlen != (2 * MAGIQUEST_BITS)) {
IR_DEBUG_PRINT(F("MagiQuest: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is not 112"));
return false;
}

View File

@ -171,8 +171,7 @@ uint32_t IRsend::computeNECRawDataAndChecksum(uint16_t aAddress, uint16_t aComma
/**
* NEC Send frame and special repeats
* There is NO delay after the last sent repeat!
* @param aNumberOfRepeats If < 0 then only a special repeat frame without leading and trailing space
* will be sent by calling NECProtocolConstants.SpecialSendRepeatFunction().
* @param aNumberOfRepeats If < 0 then only a special NEC repeat frame will be sent by calling NECProtocolConstants.SpecialSendRepeatFunction().
*/
void IRsend::sendNEC(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
sendPulseDistanceWidth(&NECProtocolConstants, computeNECRawDataAndChecksum(aAddress, aCommand), NEC_BITS, aNumberOfRepeats);
@ -237,10 +236,10 @@ bool IRrecv::decodeNEC() {
* Next try the decode
*/
// Check we have the right amount of data (68). The +4 is for initial gap, start bit mark and space + stop bit mark.
if (decodedIRData.rawDataPtr->rawlen != ((2 * NEC_BITS) + 4) && (decodedIRData.rawDataPtr->rawlen != 4)) {
if (decodedIRData.rawlen != ((2 * NEC_BITS) + 4) && (decodedIRData.rawlen != 4)) {
IR_DEBUG_PRINT(F("NEC: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is not 68 or 4"));
return false;
}
@ -251,7 +250,7 @@ bool IRrecv::decodeNEC() {
}
// Check for repeat - here we have another header space length
if (decodedIRData.rawDataPtr->rawlen == 4) {
if (decodedIRData.rawlen == 4) {
if (matchSpace(decodedIRData.rawDataPtr->rawbuf[2], NEC_REPEAT_HEADER_SPACE)
&& matchMark(decodedIRData.rawDataPtr->rawbuf[3], NEC_BIT_MARK)) {
decodedIRData.flags = IRDATA_FLAGS_IS_REPEAT | IRDATA_FLAGS_IS_LSB_FIRST;
@ -328,6 +327,7 @@ bool IRrecv::decodeNEC() {
checkForRepeatSpaceTicksAndSetFlag(NEC_MAXIMUM_REPEAT_DISTANCE / MICROS_PER_TICK);
if (decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT) {
decodedIRData.protocol = NEC2;
decodedIRData.flags |= IRDATA_FLAGS_IS_PROTOCOL_WITH_DIFFERENT_REPEAT;
}
return true;
}

View File

@ -93,7 +93,7 @@ void IRsend::sendWhynter(uint32_t aData, uint8_t aNumberOfBitsToSend) {
bool IRrecv::decodeWhynter() {
// Check we have the right amount of data (68). The +4 is for initial gap, start bit mark and space + stop bit mark.
if (decodedIRData.rawDataPtr->rawlen != (2 * WHYNTER_BITS) + 4) {
if (decodedIRData.rawlen != (2 * WHYNTER_BITS) + 4) {
return false;
}
if (!checkHeader(&WhynterProtocolConstants)) {

View File

@ -256,10 +256,10 @@ void IRrecv::compensateAndPrintIRResultAsPronto(Print *aSerial, uint16_t aFreque
aSerial->print(F("char prontoData[] = \""));
dumpNumber(aSerial, aFrequencyHertz > 0 ? learnedToken : learnedNonModulatedToken);
dumpNumber(aSerial, toFrequencyCode(aFrequencyHertz));
dumpNumber(aSerial, (decodedIRData.rawDataPtr->rawlen + 1) / 2);
dumpNumber(aSerial, (decodedIRData.rawlen + 1) / 2);
dumpNumber(aSerial, 0);
uint16_t timebase = toTimebase(aFrequencyHertz);
compensateAndDumpSequence(aSerial, &decodedIRData.rawDataPtr->rawbuf[1], decodedIRData.rawDataPtr->rawlen - 1, timebase); // skip leading space
compensateAndDumpSequence(aSerial, &decodedIRData.rawDataPtr->rawbuf[1], decodedIRData.rawlen - 1, timebase); // skip leading space
aSerial->println("\";");
}
@ -326,9 +326,9 @@ size_t IRrecv::compensateAndStorePronto(String *aString, uint16_t frequency) {
size += dumpNumber(aString, frequency > 0 ? learnedToken : learnedNonModulatedToken);
size += dumpNumber(aString, toFrequencyCode(frequency));
size += dumpNumber(aString, (decodedIRData.rawDataPtr->rawlen + 1) / 2);
size += dumpNumber(aString, (decodedIRData.rawlen + 1) / 2);
size += dumpNumber(aString, 0);
size += compensateAndDumpSequence(aString, &decodedIRData.rawDataPtr->rawbuf[1], decodedIRData.rawDataPtr->rawlen - 1,
size += compensateAndDumpSequence(aString, &decodedIRData.rawDataPtr->rawbuf[1], decodedIRData.rawlen - 1,
timebase); // skip leading space
return size;

View File

@ -160,11 +160,11 @@ bool IRrecv::decodeRC5() {
initBiphaselevel(1, RC5_UNIT); // Skip gap space
// Check we have the right amount of data (11 to 26). The +2 is for initial gap and start bit mark.
if (decodedIRData.rawDataPtr->rawlen < ((RC5_BITS + 1) / 2) + 2 && (RC5_BITS + 2) < decodedIRData.rawDataPtr->rawlen) {
if (decodedIRData.rawlen < ((RC5_BITS + 1) / 2) + 2 && (RC5_BITS + 2) < decodedIRData.rawlen) {
// no debug output, since this check is mainly to determine the received protocol
IR_DEBUG_PRINT(F("RC5: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is not between 9 and 15"));
return false;
}
@ -179,7 +179,7 @@ bool IRrecv::decodeRC5() {
/*
* Get data bits - MSB first
*/
for (tBitIndex = 0; sBiphaseDecodeRawbuffOffset < decodedIRData.rawDataPtr->rawlen; tBitIndex++) {
for (tBitIndex = 0; sBiphaseDecodeRawbuffOffset < decodedIRData.rawlen; tBitIndex++) {
// get next 2 levels and check for transition
uint8_t tStartLevel = getBiphaselevel();
uint8_t tEndLevel = getBiphaselevel();
@ -396,10 +396,10 @@ bool IRrecv::decodeRC6() {
uint32_t tDecodedRawData = 0;
// Check we have the right amount of data (). The +3 for initial gap, start bit mark and space
if (decodedIRData.rawDataPtr->rawlen < MIN_RC6_MARKS + 3 && (RC6_BITS + 3) < decodedIRData.rawDataPtr->rawlen) {
if (decodedIRData.rawlen < MIN_RC6_MARKS + 3 && (RC6_BITS + 3) < decodedIRData.rawlen) {
IR_DEBUG_PRINT(F("RC6: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is not between 15 and 25"));
return false;
}
@ -428,7 +428,7 @@ bool IRrecv::decodeRC6() {
return false;
}
for (tBitIndex = 0; sBiphaseDecodeRawbuffOffset < decodedIRData.rawDataPtr->rawlen; tBitIndex++) {
for (tBitIndex = 0; sBiphaseDecodeRawbuffOffset < decodedIRData.rawlen; tBitIndex++) {
uint8_t tStartLevel; // start level of coded bit
uint8_t tEndLevel; // end level of coded bit

View File

@ -8,7 +8,7 @@
************************************************************************************
* MIT License
*
* Copyright (c) 2017-2023 Darryl Smith, Armin Joachimsmeyer
* Copyright (c) 2017-2024 Darryl Smith, Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -63,7 +63,7 @@
Sum: 68750
*/
/*
* Samsung repeat frame can be the original frame again or a special repeat frame,
* Samsung repeat frame can be the original frame again or a special short repeat frame,
* then we call the protocol SamsungLG. They differ only in the handling of repeat,
* so we can not decide for the first frame which protocol is used.
*/
@ -101,8 +101,11 @@
struct PulseDistanceWidthProtocolConstants SamsungProtocolConstants = { SAMSUNG, SAMSUNG_KHZ, SAMSUNG_HEADER_MARK,
SAMSUNG_HEADER_SPACE, SAMSUNG_BIT_MARK, SAMSUNG_ONE_SPACE, SAMSUNG_BIT_MARK, SAMSUNG_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST,
(SAMSUNG_REPEAT_PERIOD / MICROS_IN_ONE_MILLI), &sendSamsungLGSpecialRepeat };
(SAMSUNG_REPEAT_PERIOD / MICROS_IN_ONE_MILLI), NULL };
struct PulseDistanceWidthProtocolConstants SamsungLGProtocolConstants = { SAMSUNGLG, SAMSUNG_KHZ, SAMSUNG_HEADER_MARK,
SAMSUNG_HEADER_SPACE, SAMSUNG_BIT_MARK, SAMSUNG_ONE_SPACE, SAMSUNG_BIT_MARK, SAMSUNG_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST,
(SAMSUNG_REPEAT_PERIOD / MICROS_IN_ONE_MILLI), &sendSamsungLGSpecialRepeat };
/************************************
* Start of send and decode functions
************************************/
@ -122,7 +125,8 @@ void IRsend::sendSamsungLGRepeat() {
}
/**
* Static function for sending special repeat frame.
* Like above, but implemented as a static function
* Used for sending special repeat frame.
* For use in ProtocolConstants. Saves up to 250 bytes compared to a member function.
*/
void sendSamsungLGSpecialRepeat() {
@ -150,30 +154,34 @@ void IRsend::sendSamsungLG(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNu
tRawData.UByte.MidHighByte = aCommand;
tRawData.UByte.HighByte = ~aCommand;
sendPulseDistanceWidth(&SamsungProtocolConstants, tRawData.ULong, SAMSUNG_BITS, aNumberOfRepeats);
sendPulseDistanceWidth(&SamsungLGProtocolConstants, tRawData.ULong, SAMSUNG_BITS, aNumberOfRepeats);
}
/**
* Here we send Samsung32
* If we get a command < 0x100, we send command and then ~command
* If we get an address < 0x100, we send address and then address again, this makes it flipper IRDB compatible
* !!! Be aware, that this is flexible, but makes it impossible to send e.g. 0x0042 as 16 bit value!!!
* @param aNumberOfRepeats If < 0 then only a special repeat frame will be sent
*/
void IRsend::sendSamsung(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
// send 16 bit address
LongUnion tSendValue;
tSendValue.UWords[0] = aAddress;
if (aAddress < 0x100) {
// This makes it flipper IRDB compatible
// https://github.com/flipperdevices/flipperzero-firmware/blob/master/lib/infrared/encoder_decoder/samsung/infrared_decoder_samsung.c#L18
// Duplicate address byte, if data is 8 bit and 8 bit inverted and address is 8bit
tSendValue.UBytes[1] = aAddress;
tSendValue.UBytes[0] = aAddress;
} else {
tSendValue.UWords[0] = aAddress;
}
if (aCommand < 0x100) {
// Send 8 command bits and then 8 inverted command bits LSB first
tSendValue.UBytes[2] = aCommand;
tSendValue.UBytes[3] = ~aCommand;
if (aAddress < 0x100) {
// This makes it flipper IRDB compatible
// https://github.com/flipperdevices/flipperzero-firmware/blob/master/lib/infrared/encoder_decoder/samsung/infrared_decoder_samsung.c#L18
// Duplicate address byte, if data is 8 bit and 8 bit inverted and address is 8bit
tSendValue.UBytes[1] = aAddress;
}
} else {
// Send 16 command bits
tSendValue.UWords[1] = aCommand;
@ -182,6 +190,22 @@ void IRsend::sendSamsung(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumb
sendPulseDistanceWidth(&SamsungProtocolConstants, tSendValue.ULong, SAMSUNG_BITS, aNumberOfRepeats);
}
/**
* Maybe no one needs it in the wild...
* As above, but we are able to send e.g. 0x0042 as 16 bit address
* @param aNumberOfRepeats If < 0 then only a special repeat frame will be sent
*/
void IRsend::sendSamsung16BitAddressAndCommand(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
LongUnion tSendValue;
// send 16 bit address
tSendValue.UWords[0] = aAddress;
// Send 16 command bits
tSendValue.UWords[1] = aCommand;
sendPulseDistanceWidth(&SamsungProtocolConstants, tSendValue.ULong, SAMSUNG_BITS, aNumberOfRepeats);
}
/**
* Here we send Samsung48
* We send 2 x (8 bit command and then ~command)
@ -220,11 +244,11 @@ void IRsend::sendSamsung48(uint16_t aAddress, uint32_t aCommand, int_fast8_t aNu
bool IRrecv::decodeSamsung() {
// Check we have enough data (68). The +4 is for initial gap, start bit mark and space + stop bit mark
if (decodedIRData.rawDataPtr->rawlen != ((2 * SAMSUNG_BITS) + 4)
&& decodedIRData.rawDataPtr->rawlen != ((2 * SAMSUNG48_BITS) + 4) && (decodedIRData.rawDataPtr->rawlen != 6)) {
if (decodedIRData.rawlen != ((2 * SAMSUNG_BITS) + 4) && decodedIRData.rawlen != ((2 * SAMSUNG48_BITS) + 4)
&& (decodedIRData.rawlen != 6)) {
IR_DEBUG_PRINT(F("Samsung: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is not 6 or 68 or 100"));
return false;
}
@ -234,11 +258,11 @@ bool IRrecv::decodeSamsung() {
}
// Check for SansungLG style repeat
if (decodedIRData.rawDataPtr->rawlen == 6) {
decodedIRData.flags = IRDATA_FLAGS_IS_REPEAT | IRDATA_FLAGS_IS_LSB_FIRST;
if (decodedIRData.rawlen == 6) {
decodedIRData.flags = IRDATA_FLAGS_IS_REPEAT | IRDATA_FLAGS_IS_PROTOCOL_WITH_DIFFERENT_REPEAT | IRDATA_FLAGS_IS_LSB_FIRST;
decodedIRData.address = lastDecodedAddress;
decodedIRData.command = lastDecodedCommand;
decodedIRData.protocol = SAMSUNG_LG;
decodedIRData.protocol = SAMSUNGLG;
return true;
}
@ -256,7 +280,7 @@ bool IRrecv::decodeSamsung() {
tValue.ULong = decodedIRData.decodedRawData;
decodedIRData.address = tValue.UWord.LowWord;
if (decodedIRData.rawDataPtr->rawlen == (2 * SAMSUNG48_BITS) + 4) {
if (decodedIRData.rawlen == (2 * SAMSUNG48_BITS) + 4) {
/*
* Samsung48
*/
@ -298,8 +322,9 @@ bool IRrecv::decodeSamsung() {
* Samsung32
*/
if (tValue.UByte.MidHighByte == (uint8_t)(~tValue.UByte.HighByte)) {
// 8 bit command protocol
// 8 bit command (and address) protocol
decodedIRData.command = tValue.UByte.MidHighByte; // first 8 bit
decodedIRData.address = tValue.UByte.MidLowByte; // assume LowByte == MidLowByte
} else {
// 16 bit command protocol
decodedIRData.command = tValue.UWord.HighWord; // first 16 bit

View File

@ -113,16 +113,16 @@ bool IRrecv::decodeSony() {
}
// Check we have enough data. +2 for initial gap and start bit mark and space minus the last/MSB space. NO stop bit! 26, 32, 42
if (decodedIRData.rawDataPtr->rawlen != (2 * SONY_BITS_MIN) + 2 && decodedIRData.rawDataPtr->rawlen != (2 * SONY_BITS_MAX) + 2
&& decodedIRData.rawDataPtr->rawlen != (2 * SONY_BITS_15) + 2) {
if (decodedIRData.rawlen != (2 * SONY_BITS_MIN) + 2 && decodedIRData.rawlen != (2 * SONY_BITS_MAX) + 2
&& decodedIRData.rawlen != (2 * SONY_BITS_15) + 2) {
IR_DEBUG_PRINT(F("Sony: "));
IR_DEBUG_PRINT(F("Data length="));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawlen);
IR_DEBUG_PRINT(decodedIRData.rawlen);
IR_DEBUG_PRINTLN(F(" is not 12, 15 or 20"));
return false;
}
if (!decodePulseDistanceWidthData(&SonyProtocolConstants, (decodedIRData.rawDataPtr->rawlen - 1) / 2, 3)) {
if (!decodePulseDistanceWidthData(&SonyProtocolConstants, (decodedIRData.rawlen - 1) / 2, 3)) {
#if defined(LOCAL_DEBUG)
Serial.print(F("Sony: "));
Serial.println(F("Decode failed"));
@ -134,7 +134,7 @@ bool IRrecv::decodeSony() {
// decodedIRData.flags = IRDATA_FLAGS_IS_LSB_FIRST; // Not required, since this is the start value
decodedIRData.command = decodedIRData.decodedRawData & 0x7F; // first 7 bits
decodedIRData.address = decodedIRData.decodedRawData >> 7; // next 5 or 8 or 13 bits
decodedIRData.numberOfBits = (decodedIRData.rawDataPtr->rawlen - 1) / 2;
decodedIRData.numberOfBits = (decodedIRData.rawlen - 1) / 2;
decodedIRData.protocol = SONY;
//Check for repeat