diff --git a/README.md b/README.md index 1e35cc3..9be6d43 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,7 @@ For converting MSB codes to LSB see [below](https://github.com/Arduino-IRremote/ ```c++ #include +#define RECV_PIN 2 IRrecv irrecv(RECV_PIN); decode_results results; @@ -181,6 +182,7 @@ void loop() { ```c++ #include +#define IR_RECEIVE_PIN 2 void setup() { @@ -667,11 +669,11 @@ These macros must be defined in your program **before** the line `#include ` | all | Selection of individual protocol(s) to be decoded. You can specify multiple protocols. See [here](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremote.hpp#L98-L121) | -| `DECODE_STRICT_CHECKS` | disabled | Check for additional characteristics of protocol timing like length of mark for a constant mark protocol, where space length determines the bit value. Requires up to 194 additional bytes of program memory. | +| `DECODE_STRICT_CHECKS` | disabled | Check for additional required characteristics of protocol timing like length of mark for a constant mark protocol, where space length determines the bit value. Requires up to 194 additional bytes of program memory. | | `IR_REMOTE_DISABLE_RECEIVE_COMPLETE_CALLBACK` | disabled | Saves up to 60 bytes of program memory and 2 bytes RAM. | | `MARK_EXCESS_MICROS` | 20 | MARK_EXCESS_MICROS is subtracted from all marks and added to all spaces before decoding, to compensate for the signal forming of different IR receiver modules. | | `RECORD_GAP_MICROS` | 5000 | Minimum gap between IR transmissions, to detect the end of a protocol.
Must be greater than any space of a protocol e.g. the NEC header space of 4500 µs.
Must be smaller than any gap between a command and a repeat; e.g. the retransmission gap for Sony is around 24 ms.
Keep in mind, that this is the delay between the end of the received command and the start of decoding. | @@ -692,7 +694,7 @@ Modify them by enabling / disabling them, or change the values if applicable. These next macros for **TinyIRReceiver** must be defined in your program before the line `#include ` to take effect. | Name | Default value | Description | -|:---|---:|----| +|:---|---:|---| | `IR_RECEIVE_PIN` | 2 | The pin number for TinyIRReceiver IR input, which gets compiled in. | | `IR_FEEDBACK_LED_PIN` | `LED_BUILTIN` | The pin number for TinyIRReceiver feedback LED, which gets compiled in. | | `NO_LED_FEEDBACK_CODE` | disabled | Disables the feedback LED function. Saves 14 bytes program memory. | @@ -723,9 +725,11 @@ If you are using [Sloeber](https://eclipse.baeyens.it) as your IDE, you can easi # Supported Boards **Issues and discussions with the content "Is it possible to use this library with the ATTinyXYZ? / board XYZ" without any reasonable explanations will be immediately closed without further notice.**

-ATtiny and Digispark boards are only tested with the recommended [ATTinyCore](https://github.com/SpenceKonde/ATTinyCore) using `New Style` pin mapping for the pro board. +Digispark boards are only tested with [ATTinyCore](https://github.com/SpenceKonde/ATTinyCore) using `New Style` pin mapping for the Digispark Pro board.
+ATtiny boards are only tested with [ATTinyCore](https://github.com/SpenceKonde/ATTinyCore#supported-devices) or [megaTinyCore](https://github.com/SpenceKonde/megaTinyCore). + - Arduino Uno / Mega / Leonardo / Duemilanove / Diecimila / LilyPad / Mini / Fio / Nano etc. -- Arduino Uno R4, but not yet tested, because of lack of a R4 board. +- Arduino Uno R4, but not yet tested, because of lack of a R4 board. **Sending does not work** on the `arduino:renesas_uno:unor4wifi`. - Teensy 1.0 / 1.0++ / 2.0 / 2++ / 3.0 / 3.1 / 3.2 / Teensy-LC - but [limited support](https://forum.pjrc.com/threads/65912-Enable-Continuous-Integration-with-arduino-cli-for-3-party-libraries); Credits: PaulStoffregen (Teensy Team) - Sanguino - ATmega8, 48, 88, 168, 328 @@ -736,7 +740,7 @@ ATtiny and Digispark boards are only tested with the recommended [ATTinyCore](ht - ATtiny84, 85, 167 (Digispark + Digispark Pro) - SAMD21 (Zero, MKR*, **but not SAMD51 and not DUE, the latter is SAM architecture**) - ESP8266 -- ESP32 (ESP32 C3 since board package 2.0.2 from Espressif) +- ESP32 (ESP32-C3 since board package 2.0.2 from Espressif) - Sparkfun Pro Micro - Nano Every, Uno WiFi Rev2, nRF5 BBC MicroBit, Nano33_BLE - BluePill with STM32 @@ -758,37 +762,37 @@ The TinyReceiver example uses the **TinyReceiver** library, which can **only re The code for the timer and the **timer selection** is located in [private/IRTimer.hpp](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/private/IRTimer.hpp). It can be adjusted here.
**Be aware that the hardware timer used for receiving should not be used for analogWrite()!**.
-| Board/CPU | Receive
& PWM Timers| Hardware-PWM Pin | analogWrite()
pins occupied by timer | -|--------------------------------------------------------------------------|-------------------|---------------------|-----------------------| -| [ATtiny84](https://github.com/SpenceKonde/ATTinyCore) | **1** | **6** | -| [ATtiny85 > 4 MHz](https://github.com/SpenceKonde/ATTinyCore) | **0**, 1 | **0**, 4 | **0**, 1 & 4 | -| [ATtiny88 > 4 MHz](https://github.com/SpenceKonde/ATTinyCore) | **1** | **PB1 / 8** | **PB1 / 8 & PB2 / 9** | -| [ATtiny167 > 4 MHz](https://github.com/SpenceKonde/ATTinyCore) | **1** | **9**, 8 - 15 | **8 - 15** | -| [ATtiny1604](https://github.com/SpenceKonde/megaTinyCore) | **TCB0** | **PA05** | -| [ATtiny1614, ATtiny816](https://github.com/SpenceKonde/megaTinyCore) | **TCA0** | **PA3** | -| [ATtiny3217](https://github.com/SpenceKonde/megaTinyCore) | **TCA0**, TCD | % | -| [ATmega8](https://github.com/MCUdude/MiniCore) | **1** | **9** | +| Board/CPU | Receive
& PWM Timers| Hardware-PWM Pin | analogWrite()
pins occupied by timer | +|-|-|-|-| +| [ATtiny84](https://github.com/SpenceKonde/ATTinyCore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/ATtiny_x4.md) | **1** | **6** | | +| [ATtiny85 > 4 MHz](https://github.com/SpenceKonde/ATTinyCore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/ATtiny_x5.md) | **0**, 1 | **0**, 4 | **0**, 1 & 4 | +| [ATtiny88 > 4 MHz](https://github.com/SpenceKonde/ATTinyCore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/ATtiny_x8.md) | **1** | **PB1 / 8** | **PB1 / 8 & PB2 / 9** | +| [ATtiny167 > 4 MHz](https://github.com/SpenceKonde/ATTinyCore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/ATtiny_x7.md) | **1** | **9**, 8 - 15 | **8 - 15** | +| [ATtiny1604](https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/ATtiny_x04.md) | **TCB0** | **PA05** | +| [ATtiny1614, ATtiny816](https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/ATtiny_x14.md) | **TCA0** | **PA3** | +| [ATtiny3217](https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/ATtiny_x17.md) | **TCA0**, TCD | % | +| [ATmega8](https://github.com/MCUdude/MiniCore#supported-microcontrollers) | **1** | **9** | +| [ATmega1284](https://github.com/MCUdude/MightyCore#supported-microcontrollers) | 1, **2**, 3 | 13, 14, 6 | +| [ATmega164, ATmega324, ATmega644](https://github.com/MCUdude/MightyCore#supported-microcontrollers) | 1, **2** | 13, **14** | +| [ATmega8535 ATmega16, ATmega32](https://github.com/MCUdude/MightyCore#supported-microcontrollers) | **1** | **13** | +| [ATmega64, ATmega128, ATmega1281, ATmega2561](https://github.com/MCUdude/MegaCore#supported-microcontrollers) | **1** | **13** | +| [ATmega8515, ATmega162](https://github.com/MCUdude/MajorCore#pinout ) | **1** | **13** | | ATmega168, **ATmega328** | 1, **2** | 9, **3** | 9 & 10, **3 & 11** | -| [ATmega1284](https://github.com/MCUdude/MightyCore) | 1, **2**, 3 | 13, 14, 6 | -| [ATmega164, ATmega324, ATmega644](https://github.com/MCUdude/MightyCore) | 1, **2** | 13, **14** | -| [ATmega8535 ATmega16, ATmega32](https://github.com/MCUdude/MightyCore) | **1** | **13** | -| [ATmega64, ATmega128, ATmega1281, ATmega2561](https://github.com/MCUdude/MegaCore) | **1** | **13** | -| [ATmega8515, ATmega162](https://github.com/MCUdude/MajorCore) | **1** | **13** | -| ATmega1280, ATmega2560 | 1, **2**, 3, 4, 5 | 5, 6, **9**, 11, 46 | -| ATmega4809 | **TCB0** | **A4** | -| Leonardo (Atmega32u4) | 1, 3, **4_HS** | 5, **9**, 13 | -| Zero (SAMD) | **TC3** | \*, **9** | -| [ESP32](http://esp32.net/) | **Ledc chan. 0** | All pins | -| [Sparkfun Pro Micro](https://www.sparkfun.com/products/12640) | 1, **3** | **5**, 9 | +| ATmega1280, ATmega2560 | 1, **2**, 3, 4, 5 | 5, 6, **9**, 11, 46 | | +| ATmega4809 | **TCB0** | **A4** | | +| Leonardo (Atmega32u4) | 1, 3, **4_HS** | 5, **9**, 13 | | +| Zero (SAMD) | **TC3** | \*, **9** | | +| [ESP32](http://esp32.net/) | **Ledc chan. 0** | All pins | | +| [Sparkfun Pro Micro](https://www.sparkfun.com/products/12640) | 1, **3** | **5**, 9 | | | [Teensy 1.0](https://www.pjrc.com/teensy/pinout.html) | **1** | **17** | 15, 18 | | [Teensy 2.0](https://www.pjrc.com/teensy/pinout.html) | 1, 3, **4_HS** | 9, **10**, 14 | 12 | | [Teensy++ 1.0 / 2.0](https://www.pjrc.com/teensy/pinout.html) | 1, **2**, 3 | **1**, 16, 25 | 0 | | [Teensy-LC](https://www.pjrc.com/teensy/pinout.html) | **TPM1** | **16** | 17 | -| [Teensy 3.0 - 3.6](https://www.pjrc.com/teensy/pinout.html) | **CMT** | **5** | +| [Teensy 3.0 - 3.6](https://www.pjrc.com/teensy/pinout.html) | **CMT** | **5** | | | [Teensy 4.0 - 4.1](https://www.pjrc.com/teensy/pinout.html) | **FlexPWM1.3** | **8** | 7, 25 | -| [BluePill / STM32F103C8T6](https://github.com/stm32duino/Arduino_Core_STM32) | **3** | % | **PA6 & PA7 & PB0 & PB1** | +| [BluePill / STM32F103C8T6](https://github.com/stm32duino/Arduino_Core_STM32) | **3** | % | **PA6 & PA7 & PB0 & PB1** | | [BluePill / STM32F103C8T6](https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill) | **TIM4** | % | **PB6 & PB7 & PB8 & PB9** | -| [RP2040 / Pi Pico](https://github.com/earlephilhower/arduino-pico) | [default alarm pool](https://raspberrypi.github.io/pico-sdk-doxygen/group__repeating__timer.html) | All pins | No pin | +| [RP2040 / Pi Pico](https://github.com/earlephilhower/arduino-pico) | [default alarm pool](https://raspberrypi.github.io/pico-sdk-doxygen/group__repeating__timer.html) | All pins | No pin | | [RP2040 / Mbed based](https://github.com/arduino/ArduinoCore-mbed) | Mbed Ticker | All pins | No pin | ### No timer required for sending @@ -868,16 +872,16 @@ Created with sigrok PulseView with IR_NEC decoder by DjordjeMandic.

# Quick comparison of 5 Arduino IR receiving libraries -[Here](https://github.com/crankyoldgit/IRremoteESP8266) you find an **ESP8266/ESP32** version of IRremote with an **[impressive list of supported protocols](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/SupportedProtocols.md)**. - **This is a short comparison and may not be complete or correct.** I created this comparison matrix for [myself](https://github.com/ArminJo) in order to choose a small IR lib for my project and to have a quick overview, when to choose which library.
-It is dated from **24.06.2022**. If you have complains about the data or request for extensions, please send a PM or open a discussion. +It is dated from **24.06.2022** and updated 10/2023. If you have complains about the data or request for extensions, please send a PM or open a discussion. -| Subject | [IRMP](https://github.com/IRMP-org/IRMP) | [IRLremote](https://github.com/NicoHood/IRLremote) | [IRLib2](https://github.com/cyborg5/IRLib2)
**mostly unmaintained** | [IRremote](https://github.com/Arduino-IRremote/Arduino-IRremote) | [Minimal NEC](https://github.com/Arduino-IRremote/Arduino-IRremote/tree/master/examples/TinyReceiver) | [IRsmallDecoder](https://github.com/LuisMiCa/IRsmallDecoder) -|---------|------|-----------|--------|----------|----------|----------| -| Number of protocols | **50** | Nec + Panasonic + Hash \* | 12 + Hash \* | 17 + PulseDistance + Hash \* | NEC | NEC + RC5 + Sony + Samsung | +[Here](https://github.com/crankyoldgit/IRremoteESP8266) you find an **ESP8266/ESP32** version of IRremote with an **[impressive list of supported protocols](https://github.com/crankyoldgit/IRremoteESP8266/blob/master/SupportedProtocols.md)**. + +| Subject | [IRMP](https://github.com/IRMP-org/IRMP) | [IRLremote](https://github.com/NicoHood/IRLremote) | [IRLib2](https://github.com/cyborg5/IRLib2)
**mostly unmaintained** | [IRremote](https://github.com/Arduino-IRremote/Arduino-IRremote) | [TinyIR](https://github.com/Arduino-IRremote/Arduino-IRremote/tree/master/examples/TinyReceiver/TinyReceiver.ino) | [IRsmallDecoder](https://github.com/LuisMiCa/IRsmallDecoder) +|-|-|-|-|-|-|-| +| Number of protocols | **50** | Nec + Panasonic + Hash \* | 12 + Hash \* | 17 + PulseDistance + Hash \* | NEC + FAST | NEC + RC5 + Sony + Samsung | | Timing method receive | Timer2 or interrupt for pin 2 or 3 | **Interrupt** | Timer2 or interrupt for pin 2 or 3 | Timer2 | **Interrupt** | **Interrupt** | | Timing method send | PWM and timing with Timer2 interrupts | Timer2 interrupts | Timer2 and blocking wait | PWM with Timer2 and/or blocking wait with delay
Microseconds() | blocking wait with delay
Microseconds() | % | | Send pins| All | All | All ? | Timer dependent | All | % | @@ -889,8 +893,8 @@ It is dated from **24.06.2022**. If you have complains about the data or request | FLASH usage (simple NEC example with 5 prints) | 1820
(4300 for 15 main / 8000 for all 40 protocols)
(+200 for callback)
(+80 for interrupt at pin 2+3)| 1270
(1400 for pin 2+3) | 4830 | 1770 | **900** | ?1100? | | RAM usage | 52
(73 / 100 for 15 (main) / 40 protocols) | 62 | 334 | 227 | **19** | 29 | | Supported platforms | **avr, megaavr, attiny, Digispark (Pro), esp8266, ESP32, STM32, SAMD 21, Apollo3
(plus arm and pic for non Arduino IDE)** | avr, esp8266 | avr, SAMD 21, SAMD 51 | avr, attiny, [esp8266](https://github.com/crankyoldgit/IRremoteESP8266), esp32, SAM, SAMD | **All platforms with attach
Interrupt()** | **All platforms with attach
Interrupt()** | -| Last library update | 6/2022 | 4/2018 | 3/2022 | 6/2022 | 6/2022 | 2/2022 | -| Remarks | Decodes 40 protocols concurrently.
39 Protocols to send.
Work in progress. | Only one protocol at a time. | Consists of 5 libraries. **Project containing bugs - 45 issues, no reaction for at least one year.** | Universal decoder and encoder.
Supports **Pronto** codes and sending of raw timing values. | Requires no timer. | Requires no timer. | +| Last library update | 5/2023 | 4/2018 | 11/2022 | 9/2023 | 5/2023 | 2/2022 | +| Remarks | Decodes 40 protocols concurrently.
39 Protocols to send.
Work in progress. | Only one protocol at a time. | Consists of 5 libraries. **Project containing bugs - 63 issues, 10 pull requests.* | Universal decoder and encoder.
Supports **Pronto** codes and sending of raw timing values. | Requires no timer. | Requires no timer. | \* The Hash protocol gives you a hash as code, which may be sufficient to distinguish your keys on the remote, but may not work with some protocols like Mitsubishi diff --git a/src/IRReceive.hpp b/src/IRReceive.hpp index 227a3ce..f466a70 100644 --- a/src/IRReceive.hpp +++ b/src/IRReceive.hpp @@ -51,7 +51,7 @@ //#define _IR_TIMING_TEST_PIN 7 // "pinModeFast(_IR_TIMING_TEST_PIN, OUTPUT);" is executed at start() // /* - * Check for additional characteristics of timing like length of mark for a constant mark protocol, + * Check for additional required characteristics of timing like length of mark for a constant mark protocol, * where space length determines the bit value. Requires up to 194 additional bytes of program memory. */ //#define DECODE_STRICT_CHECKS diff --git a/src/IRSend.hpp b/src/IRSend.hpp index 7088146..0a8ac01 100644 --- a/src/IRSend.hpp +++ b/src/IRSend.hpp @@ -935,6 +935,13 @@ void IRsend::sendBiphaseData(uint16_t aBiphaseTimeUnit, uint32_t aData, uint_fas * This function may affect the state of feedback LED. * Period time is 26 us for 38.46 kHz, 27 us for 37.04 kHz, 25 us for 40 kHz. * On time is 8 us for 30% duty cycle + * + * The mark() function relies on the correct implementation of: + * delayMicroseconds() for pulse time, and micros() for pause time. + * The delayMicroseconds() of pulse time is guarded on AVR CPU's with noInterrupts() / interrupts(). + * At the start of pause time, interrupts are enabled once, the rest of the pause is also guarded on AVR CPU's with noInterrupts() / interrupts(). + * The maximum length of an interrupt during sending should not exceed 26 us - 8 us = 18 us, otherwise timing is disturbed. + * This disturbance is no problem, if the exceedance is small and does not happen too often. */ void IRsend::mark(uint16_t aMarkMicros) { @@ -1002,7 +1009,7 @@ void IRsend::mark(uint16_t aMarkMicros) { // 4.3 us from do{ to pin setting if sendPin is no constant digitalWriteFast(sendPin, HIGH); # endif - delayMicroseconds(periodOnTimeMicros); // On time is 8 us for 30% duty cycle. This is normally implemented by a blocking wait. + delayMicroseconds (periodOnTimeMicros); // On time is 8 us for 30% duty cycle. This is normally implemented by a blocking wait. /* * Output the PWM pause diff --git a/src/IRremote.h b/src/IRremote.h index 26b1fe3..3af3f58 100644 --- a/src/IRremote.h +++ b/src/IRremote.h @@ -9,6 +9,15 @@ #include "IRremote.hpp" +#warning Thank you for using the IRremote library! +#warning It seems, that you are using a old version 2.0 code / example. +#warning This version is no longer supported! +#warning Please use one of the new code examples from the library available at "File > Examples > Examples from Custom Libraries / IRremote". +#warning Or downgrade your library to version 2.6.0. +#warning Start with the SimpleReceiver or SimpleSender example. +#warning The examples are documented here: https://github.com/Arduino-IRremote/Arduino-IRremote#examples-for-this-library +#warning A guide how to convert your 2.0 program is here: https://github.com/Arduino-IRremote/Arduino-IRremote#converting-your-2x-program-to-the-4x-version + /********************************************************************************************************************** * The OLD and DEPRECATED decode function with parameter aResults, kept for backward compatibility to old 2.0 tutorials * This function calls the old MSB first decoders and fills only the 3 variables: diff --git a/src/IRremoteInt.h b/src/IRremoteInt.h index 7ff756e..9197129 100644 --- a/src/IRremoteInt.h +++ b/src/IRremoteInt.h @@ -124,6 +124,8 @@ typedef uint64_t IRRawDataType; /* * Debug directives + * Outputs with IR_DEBUG_PRINT can only be activated by defining DEBUG! + * If LOCAL_DEBUG is defined in one file, all outputs with IR_DEBUG_PRINT are still suppressed. */ #if defined(DEBUG) || defined(TRACE) # define IR_DEBUG_PRINT(...) Serial.print(__VA_ARGS__) @@ -162,7 +164,7 @@ struct decode_results { uint16_t magnitude; // deprecated, moved to decodedIRData.extra ///< Used by MagiQuest [16-bits] bool isRepeat; // deprecated, moved to decodedIRData.flags ///< True if repeat of value is detected -// next 3 values are copies of irparams values - see IRremoteint.h +// next 3 values are copies of irparams_struct values - see above uint16_t *rawbuf; // deprecated, moved to decodedIRData.rawDataPtr->rawbuf ///< Raw intervals in 50uS ticks uint_fast8_t rawlen; // deprecated, moved to decodedIRData.rawDataPtr->rawlen ///< Number of records in rawbuf bool overflow; // deprecated, moved to decodedIRData.flags ///< true if IR raw code too long diff --git a/src/ir_Kaseikyo.hpp b/src/ir_Kaseikyo.hpp index 294ea94..4c1b9b8 100644 --- a/src/ir_Kaseikyo.hpp +++ b/src/ir_Kaseikyo.hpp @@ -75,22 +75,21 @@ */ // http://www.hifi-remote.com/johnsfine/DecodeIR.html#Panasonic // http://www.hifi-remote.com/johnsfine/DecodeIR.html#Kaseikyo +// LSB first // The first two (8-bit) bytes contains the vendor code. +// The next 4 bit is VendorID parity. +// The last byte is parity (XOR) of the 3 bytes before. // There are multiple interpretations of the next fields: // IRP: {37k,432}<1,-1|1,-3>(8,-4,M:8,N:8,X:4,D:4,S:8,F:8,G:8,1,-173)+ {X=M:4:0^M:4:4^N:4:0^N:4:4} -// 1. interpretation: After the vendor code, the next byte is 4 bit VendorID parity and 4 bit Device and Subdevice -// The 5th byte is the function and the last (6.th) byte is xor of the three bytes before it. -// 0_______ 1_______ 2______ 3_______ 4_______ 5 +// 1. interpretation: 4 bit Device, 8 bitSubdevice and 8 bit function. +// 0_______ 1_______ 2______ 3_______ 4_______ 5_______ // 01234567 89ABCDEF 01234567 01234567 01234567 01234567 -// 01000000 00100100 Dev____ Sub_Dev_ Fun____ XOR( B2, B3, B4) - showing Panasonic vendor code 0x2002 +// 01000000 00100100 0110Dev_ Sub_Dev_ Fun____ XOR( B2, B3, B4) - Byte 0,1 and vendor parity showing Panasonic vendor code 0x2002. +// 1. interpretation: // see: http://www.remotecentral.com/cgi-bin/mboard/rc-pronto/thread.cgi?26152 -// -// 2. interpretation: LSB first, start bit + 16 VendorID + 4 VendorID parity + 4 Genre1 + 4 Genre2 + 10 Command + 2 ID + 8 Parity + stop bit +// 2. interpretation: // see: https://www.mikrocontroller.net/articles/IRMP_-_english#KASEIKYO -// 32 bit raw data LSB is VendorID parity. -// -// We reduce it to: IRP: {37k,432}<1,-1|1,-3>(8,-4,V:16,X:4,D:4,S:8,F:8,(X^D^S^F):8,1,-173)+ {X=M:4:0^M:4:4^N:4:0^N:4:4} -// start bit + 16 VendorID + 4 VendorID parity + 12 Address + 8 Command + 8 Parity of VendorID parity, Address and Command + stop bit +// Implemented is: // #define KASEIKYO_VENDOR_ID_BITS 16 #define KASEIKYO_VENDOR_ID_PARITY_BITS 4 @@ -140,9 +139,9 @@ void IRsend::sendKaseikyo(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumb #if __INT_WIDTH__ < 32 LongUnion tSendValue; // Compute parity - tSendValue.UWord.LowWord = (aAddress << KASEIKYO_VENDOR_ID_PARITY_BITS) | tVendorParity; // set low nibble to parity + tSendValue.UWord.LowWord = (aAddress << KASEIKYO_VENDOR_ID_PARITY_BITS) | tVendorParity; // set low nibble with vendor parity tSendValue.UBytes[2] = aCommand; - tSendValue.UBytes[3] = aCommand ^ tSendValue.UBytes[0] ^ tSendValue.UBytes[1]; // Parity + tSendValue.UBytes[3] = aCommand ^ tSendValue.UBytes[0] ^ tSendValue.UBytes[1]; // 8 bit parity of 3 bytes command, address and vendor parity IRRawDataType tRawKaseikyoData[2]; tRawKaseikyoData[0] = (uint32_t) tSendValue.UWord.LowWord << 16 | aVendorCode; // LSB of tRawKaseikyoData[0] is sent first tRawKaseikyoData[1] = tSendValue.UWord.HighWord; diff --git a/src/ir_NEC.hpp b/src/ir_NEC.hpp index b689425..a0627e6 100644 --- a/src/ir_NEC.hpp +++ b/src/ir_NEC.hpp @@ -33,9 +33,9 @@ #define _IR_NEC_HPP #if defined(DEBUG) && !defined(LOCAL_DEBUG) -#define LOCAL_DEBUG +#define LOCAL_DEBUG // IR_DEBUG_PRINT is a real print function here. Add local debug output. #else -//#define LOCAL_DEBUG // This enables debug output only for this file +//#define LOCAL_DEBUG // This enables debug output only for this file. IR_DEBUG_PRINT is still a void function here. #endif /** \addtogroup Decoder Decoders and encoders for different protocols @@ -71,17 +71,20 @@ */ // http://www.hifi-remote.com/wiki/index.php/NEC // https://www.sbprojects.net/knowledge/ir/nec.php -// for Apple see https://en.wikipedia.org/wiki/Apple_Remote - Fixed address 0x87EE, 8 bit device ID, 7 bit command, 1 bit parity - untested! -// ONKYO like NEC but 16 independent address and command bits -// APPLE like ONKYO with special NEC repeat but with constant address of 0x87EE and and 16 bit command interpreted as MSB = 8 bit device ID, LSB = 8 bit command -// PIONEER (not implemented) is NEC2 with 40 kHz -// LSB first, 1 start bit + 16 bit address (or 8 bit address and 8 bit inverted address) + 8 bit command + 8 bit inverted command + 1 stop bit. +// NEC: LSB first, (or ) . +// ONKYO like NEC but 16 independent address and command bits: // Standard NEC sends a special fixed repeat frame. // NEC2 sends the same full frame after the 110 ms. I have a DVD remote with NEC2. // NEC and NEC 2 only differ in the repeat frames, so the protocol can only be detected correctly after the first repeat. +// PIONEER (not implemented) is NEC2 with 40 kHz // +// For Apple see https://en.wikipedia.org/wiki/Apple_Remote - <0x87EE:16> - not implemented! +// The parity is not implemented, so we get: <0x87EE:16> +// +// IRP notation: // IRP: NEC {38.0k,564}<1,-1|1,-3>(16,-8,D:8,S:8,F:8,~F:8,1,^108m,(16,-4,1,^108m)*) ==> "*" means send special repeat frames o ore more times // IRP: NEC2 {38.0k,564}<1,-1|1,-3>(16,-8,D:8,S:8,F:8,~F:8,1,^108m)+ ==> "+" means send frame 1 or more times (special repeat is missing here!) +// Interpretation of IRP notation: // {38.0k,564} ==> 38.0k -> Frequency , 564 -> unit in microseconds (we use 560), no "msb", so "lsb" is assumed // <1,-1|1,-3> ==> Zero is 1 unit mark and space | One is 1 unit mark and 3 units space // 16,-8 ==> Start bit durations @@ -137,7 +140,7 @@ void IRsend::sendNECRepeat() { } /** - * Static function for sending special repeat frame. + * Static function variant of IRsend::sendNECRepeat * For use in ProtocolConstants. Saves up to 250 bytes compared to a member function. */ void sendNECSpecialRepeat() { @@ -199,14 +202,13 @@ void IRsend::sendOnkyo(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumber * There is NO delay after the last sent repeat! * https://en.wikipedia.org/wiki/Apple_Remote * https://gist.github.com/darconeous/4437f79a34e3b6441628 - * @param aAddress is the DeviceId* * @param aNumberOfRepeats If < 0 then only a special repeat frame without leading and trailing space * will be sent by calling NECProtocolConstants.SpecialSendRepeatFunction(). */ void IRsend::sendApple(uint8_t aDeviceId, uint8_t aCommand, int_fast8_t aNumberOfRepeats) { LongUnion tRawData; - // Address 16 bit LSB first + // Address 16 bit LSB first fixed value of 0x87EE tRawData.UWord.LowWord = APPLE_ADDRESS; // send Apple code and then 8 command bits LSB first @@ -217,7 +219,7 @@ void IRsend::sendApple(uint8_t aDeviceId, uint8_t aCommand, int_fast8_t aNumberO } /* - * Sends NEC1 protocol + * Sends NEC protocol * @param aNumberOfRepeats If < 0 then only a special repeat frame without leading and trailing space * will be sent by calling NECProtocolConstants.SpecialSendRepeatFunction(). */