Repository: NicoHood/IRLremote Branch: master Commit: 0c7c61e5773b Files: 30 Total size: 228.6 KB Directory structure: gitextract_k7srl98y/ ├── .github/ │ └── FUNDING.yml ├── Readme.md ├── dev/ │ └── Interpreting Decoded IR Signals (v2.43).htm ├── examples/ │ ├── Convert_Old_Nec/ │ │ └── Convert_Old_Nec.ino │ ├── NecAPI/ │ │ └── NecAPI.ino │ ├── Receive/ │ │ └── Receive.ino │ ├── Receive_Raw/ │ │ └── Receive_Raw.ino │ ├── Send_Button/ │ │ └── Send_Button.ino │ ├── Send_Serial/ │ │ └── Send_Serial.ino │ └── Transceive/ │ └── Transceive.ino ├── extra/ │ └── old/ │ ├── IRL_Hash.hpp │ ├── IRL_RawIR.hpp │ ├── IRL_Sony.hpp │ ├── IRLremote.cpp │ ├── IRLremoteReceive.hpp │ └── IRLremoteTransmit.hpp ├── keywords.txt ├── library.properties └── src/ ├── IRL_Decode.h ├── IRL_Hash.h ├── IRL_Keycodes.h ├── IRL_Nec.h ├── IRL_NecAPI.h ├── IRL_Panasonic.h ├── IRL_Platform.h ├── IRL_Protocol.h ├── IRL_Receive.h ├── IRL_Time.h ├── IRLremote.cpp └── IRLremote.h ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: nicohood # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: nicohood # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: https://www.buymeacoffee.com/nicohood # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] ================================================ FILE: Readme.md ================================================ # IRLremote 2.0.2 ![Infrared Picture](header.jpg) New lightweight IR library with different, smarter implementation. This library is way more efficient than the "standard" IR library from Ken Shirriff. Buy Me A Coffee # Table of Contents 1. [Overview](#overview) 2. [Library Installation](#library-installation) 3. [API Documentation](#api-documentation) * [Receive Protocols](#receive-protocols) * [Setup Receiving](#setup-receiving) * [Read IRLremote](#read-irlremote) * [Time Functions](#time-functions) * [Sending](#sending) * [Adding new protocols](#adding-new-protocols) 4. [How it works](#how-it-works) 5. [Links](#links) 6. [Version History](#version-history) 7. [License and Copyright](#license-and-copyright) ## Overview **The main improvements are:** * Faster decoding (on the fly) * Huge Ram improvements (13 bytes ram to decode NEC) * Huge Flash improvements (less than 1kb flash to decode NEC) * Receiving and sending possible * Very accurate even when pointing in different directions * Easy to use/customizable * Maximum error correction * Uses PinInterrupt or PinChangeInterrupts/No timer needed * Usable on almost any pin * Perfect for Attinys * All mainstream protocols supported * Very accurate hash decoding for unknown protocols * IDE 1.6.x compatible (not 1.0.5 compatible) **Supported Protocols** * NEC * Panasonic * ~~Sony 12~~ (TODO) * Hash (For any unknown protocol) * ~~RawIR (For dumping the raw data)~~ (TODO) * Ask me for more **Planned features:** * Test sending functions (for Panasonic, Sony etc) * Add more protocols (RC06) * Improve bit banging PWM? * Add Raw dump sending option * Implement Sony 15, 20 properly ## Library Installation Install the library as you are used to. More information can be found [here](http://arduino.cc/en/guide/libraries). ## API Documentation For a very fast library example see the [Receiving example](/examples/Receive/Receive.ino). ### Receive Protocols You can choice between multiple protocols. All protocols are optimized in a way that the recognition of the selected protocol is set to a maximum. This means you can only decode a single protocol at a time but with best recognition. ##### Supported Protocols: * NEC * Panasonic * IRHash ##### Examples: ```cpp // Choose the IR protocol of your remote CNec IRLremote; //CPanasonic IRLremote; //CHashIR IRLremote; ``` ### Setup Receiving To use the receiving you have to choose a **[PinInterrupt](http://arduino.cc/en/pmwiki.php?n=Reference/AttachInterrupt)** or **[PinChangeInterrupt](https://github.com/NicoHood/PinChangeInterrupt)** pin. They work a bit different under the hood but the result for IR is the same. In order to use PinChangeInterrupts you also have to [install the library](https://github.com/NicoHood/PinChangeInterrupt). You can also terminate the receiver. This sets pins to input again to safely remove connections. This is **normally not required**. ##### Function Prototype: ```cpp bool begin(uint8_t pin); bool end(uint8_t pin); ``` ##### Examples: ```cpp // Choose a valid PinInterrupt or PinChangeInterrupt pin of your Arduino board #define pinIR 2 // Start reading the remote // PinInterrupt or PinChangeInterrupt will automatically be selected // False indicates a wrong selected interrupt pin if (!IRLremote.begin(pinIR)) Serial.println(F("You did not choose a valid pin.")); // End reading the remote IRLremote.end(pinIR); ``` ### Read IRLremote If there is input available you can read the data of the remote. It will return the received data and automatically continue reading afterwards. Check if the remote is available before, otherwise you will get an empty structure back. The returned data type will differ with the selected protocol. Each protocol has an address and a command member, but their size may differ. See the protocol section for more information. ##### Function Prototype: ```cpp bool available(void); // Valid datatypes depending on the selected protocol: Nec_data_t read(void); Panasonic_data_t read(void); HashIR_data_t read(void); ``` ##### Examples: ```cpp // Check if new IR protocol data is available if (IRLremote.available()) { // Get the new data from the remote auto data = IRLremote.read(); // Print the protocol data Serial.print(F("Address: 0x")); Serial.println(data.address, HEX); Serial.print(F("Command: 0x")); Serial.println(data.command, HEX); Serial.println(); } ``` ### Time Functions The API provides a few interfaces to check some timings between the last Event or if the remote is currently still receiving. This is especially useful when you want to build higher level APIs around the remote or when you have other interrupt sensitive code that disables interrupts which affects the IR reading quality. ##### Function Prototype: ```cpp bool receiving(void); uint32_t timeout(void); uint32_t lastEvent(void); uint32_t nextEvent(void); ``` ##### Examples: ```cpp // Check if we are currently receiving data if (!IRLremote.receiving()) { FastLED.show(); } // Return relativ time between last event time (in micros) if (IRLremote.timeout() > 1000000UL) { // Reading timed out 1s, release button from debouncing digitalWrite(BUILTIN_LED, LOW); } // Return absolute last event time (in micros) Serial.println(IRLremote.lastEvent, HEX); Serial.println(micros(), HEX); // Return when the next event can be expected. // Zero means at any time. // Attention! This value is a little bit too high in general. // Also for the first press it is even higher than it should. if (IRLremote.nextEvent() == 0) { // We timed out, this is the last event in this series of reading digitalWrite(BUILTIN_LED, LOW); } ``` ### Sending **For sending see the SendSerial/Button examples.** Sending is currently **beta**. The library focuses more on decoding, rather than sending. You first have to read the codes of your remote with one of the receiving examples. Choose your protocol in the sending sketch and use your address and command if choice. Sending for Panasonic and Sony12 is not confirmed to work, since I have no device here to test. Let me know if it works! ### Adding new protocols You can also ask me to implement any new protocol, just file an issue on Github or contact me directly. Or you can just choose the hash option which works very reliable for unknown protocols. More projects + contact can be found here: http://www.NicoHood.de How it works ============ **The idea is: minimal implementation with maximal recognition. You can still decode more than one protocol at the same time.** The trick is to only check the border between logical zero and logical one to terminate space/mark and rely on the lead/length/checksum as error correction. Lets say a logical 0 is 500ms and 1 is 1000ms. Then the border would be 750ms to get maximum recognition instead of using just 10%. Other protocols use different timings, leads, length, checksums so it shouldn't interfere with other protocols even with this method. This gives the library very small implementation with maximum recognition. You can point into almost every possible direction in the room without wrong signals. It saves a lot of ram because it decodes the signals "on the fly" when an interrupt occurs. That's why you should not add too many protocols at once to exceed the time of the next signal. However its so fast, its shouldn't make any difference since we are talking about ms, not us. **In comparison to Ken's lib**, he records the signals (with timer interrupts) in a buffer which takes a lot of ram. Then you need to check in the main loop if the buffer has any valid signals. It checks every signal, that's why its slow and takes a lot of flash. And it also checks about 10~20% from the original value. Lets say a pulse is 100ms. Then 80-120ms is valid. That's why the recognition is worse. And he also doesn't check the protocol intern error correction. For example NEC has an inverse in the command: the first byte is the inverse of the 2nd byte. Its easy to filter wrong signals then. So every protocol has its built in checksums, which we will use. And I also check for timeouts and start new readings if the signal timed out. The only positive thing is that with the timer the pin is more flexible. However i will try to implement a PCINT version later. For sending I decided to use Bitbang. This works on every MCU and on any PIN. He used proper timers, but only PIN 3 is usable for sending (an interrupt pin). Bitbang might have problems with other interrupts but should work relyable. You can turn off interrupts before sending if you like to ensure a proper sending. Normal IR devices shouldn't complain about a bit intolerance in the PWM signal. Just try to keep interrupts short. This text should not attack the library from Ken. It's a great library with a lot of work and the most used IR library yet. It is just worth a comparison and might be still useful like the old SoftSerial against the new one. Links ===== * https://github.com/z3t0/Arduino-IRremote * http://www.mikrocontroller.net/articles/IRMP#Literatur * JCV/Panasonic/Japan/KASEIKYO * http://www.mikrocontroller.net/attachment/4246/IR-Protokolle_Diplomarbeit.pdf * http://www.roboternetz.de/phpBB2/files/entwicklung_und_realisierung_einer_universalinfrarotfernbedienung_mit_timerfunktionen.pdf * Sony * http://picprojects.org.uk/projects/sirc/sonysirc.pdf * http://www.benryves.com/products/sonyir/ * http://www.righto.com/2010/03/understanding-sony-ir-remote-codes-lirc.html * http://mc.mikrocontroller.com/de/IR-Protokolle.php#SIRCS * NEC * http://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol * http://www.sbprojects.com/knowledge/ir/nec.php Version History =============== ``` 2.0.2 Release (08.04.2018) * Added ESP8266 #20 2.0.1 Release (16.01.2018) * Fix makefile compilation 2.0.0 Release (07.03.2017) * Focus on single protocol implementation * Added better keycode definitions #11 * Updated keywords.txt * Tabs -> Spaces * Added receive and time interface templates 1.9.0 Release (Never officially released) * Added API as class * Fixed NEC Timeout value * NEC repeat code now integrated * Fixed Sony12 address * Added debounce * More flexible selection of protocols * PinChangeInterrupt library dynamically used * Added F() makro for examples * Removed older examples * Removed the general decoding function to improve decoding functionality * New inputs are generated at runtime, saves flash and ram * Faster interrupt if valid signal was received * Improved NEC sending * Added to Arduino IDE 1.6.x library manager * Some other complex library structure changes * Made reading interrupt save * Improved RawIR * Added hash function for unknown protocols 1.7.4 Release (19.04.2015) * Updated examples * Added PinChangeInterrupt example * Removed NoBlocking API and integrated this into the examples * Added IRL_VERSION definition * Added library.properties * Improved Raw Example 1.7.3 Release (27.11.2014) * Fixed critical Typo in decoding function * Fixed weak function variable type * Updated Raw Example slightly 1.7.2 Release (18.11.2014) * Added always inline macro * Changed duration to 16 bit * Added easier PCINT map definitions * Fixed ARM compilation for receiving (sending is still not working) 1.7.1 Release (15.11.2014) * Added 16u2 HoodLoader2 example 1.7 Release (15.11.2014) * Changed IR bit order from MSB to correct LSB * This improved the overall handling and also reduced flash usage * Improved, extended sending function * Added Receive Send Example * Added smaller Basic PCINT function 1.6 Release (14.11.2014) * Reworked decoding template * Added Sony 12 protocol * Added PCINT example for advanced users 1.5.1 Release (21.09.2014) * improved Bitbang PWM * fixed SendSerial example 1.5.0 Release (20.09.2014) * huge Ram and Flash improvements * new library structure * compacter code/new structure * more examples * more than one protocol possible at the same time * customizable decoding functions 1.4.7 Release (13.09.2014) * changed NEC to template 1.4.6 Release (30.08.2014) * fixed writing address + command bug * added sending function for NEC * added Led example 1.4.5 Release (30.08.2014) * fixed raw protocol 1.4.4 Release (07.08.2014) * added raw protocol (broken) 1.4.3 Release (06.08.2014) * changed and improved a lot of stuff * rearranged classes * removed older versions 1.0 - 1.3 (17.03.2014 - 03.5.2014) * Release and minor fixes ``` License and Copyright ===================== If you use this library for any cool project let me know! ``` Copyright (c) 2014-2015 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` ================================================ FILE: dev/Interpreting Decoded IR Signals (v2.43).htm ================================================ Interpreting Decoded IR Signals (v2.43)

Introduction

48-NEC
48-NEC1
48-NEC2
AdNotam
AirAsync
AirB?-????
Aiwa
AK
Akai
Amino
Anthem
Apple
Archer
Async
Blaupunkt
Bose
CanalSat
Denon
Denon{1}
Denon{2}
Denon-K
Dgtec
DirecTV
Dishplayer
Dish_Network
Emerson
F12
Fujitsu
Fujitsu-56
G.I. Cable
G.I. Cable{1}
G.I.4DTV
Grundig16
Grundig16-30
GXB
IODATAn
IODATAn-x-y
Jerrold
JVC
JVC{2}
JVC-48
JVC-56
Kaseikyo
Kaseikyo-???-???
Kaseikyo56
Kaseikyo56-???-???
Kathrein
Konka
Lumagen
Lutron
Matsui
MCE
Metz19
Mitsubishi
Mitsubishi-K
NEC
NEC1
NEC2
NECx
NECx1
NECx2
Nokia
Nokia12
Nokia32
NRC16
NRC17
OrtekMCE
Pace MSS
Panasonic
Panasonic2
Panasonic_Old
PCTV
pid-0001
pid-0003
pid-0004
pid-002A
pid-0083
Pioneer
Proton
RC5
RC5-7F
RC5-7F-57
RC5x
RC5-?-??
RC6
RC6-6-20
RC6-?-??
RCA
RCA(Old)
RCA-38
RCA-38(Old)
RECS80
Replay
Samsung20
Samsung36
Sampo
ScAtl-6
Sejin-M-38
Sejin-M-56
Sharp
Sharp{1}
Sharp{2}
SharpDVD
SIM2
Solidtek16
Solidtek20
Somfy
Sony8
Sony12
Sony15
Sony20
StreamZap
Sunfire
TDC-38
TDC-56
Teac-K
Thomson
Thomson7
Tivo
Velleman
Velodyne
Viewstar
X10
X10.n
XMP
XMP-1
XMP-2
XX
Zaptor
Zenith
?1-??-??-??

Introduction

The primary purpose of this document is to explain any peculiarities of the decoding of each protocol. Click in the list above on each protocol name to get any information specific to decodes with that name.

If you don't understand the advanced information (IRP notation, etc.) at the start of each of those entries, don't worry about that and please don't let it stop you from reading the text below that. In many cases there is important protocol-specific information you will need in order to use the data from the decode.

Decode problems

The decoder only looks at one IR signal at a time. Sometimes it gives contradictory results for a signal. The best way to determine which result is correct is to compare with the decodes of other signals for the same device.

Spurious decodes and non-robust protocols

Most IR protocols have enough internal consistency checks that the decoder can reliably tell whether that protocol is present in a learned signal and can reliably decode the device, subdevice and OBC numbers. If the signal is learned badly enough, the decoder may fail to find that protocol in the signal. But it is very unlikely to decode it with the wrong numbers or to imagine that protocol is a bad learn of something else.

Some protocols are not robust. A totally unrelated IR signal can accidentally fit the pattern of such a protocol resulting in a spurious decode. When you get a decode for a non-robust protocol you need to exercise some judgment about whether to believe or ignore that decode. Usually you can decide based on decodes of other signals of the same device.

EFC, JP1, KeyMoves, Upgrades, etc.

Much of this document assumes DecodeIr is being used with JP1 or at least with a JP1 capable remote. But some people will be using DecodeIr with other types of remote.

If your remote is not OneForAll brand and is not one of the models of Radio Shack (or a few other brands) that uses the same design as OneForAll, then everything this document says about JP1, KeyMoves, Upgrades, KM, RM (RemoteMaster), and EFC numbers has no meaning for your use. Just ignore those references and the rest of this doc should apply to your use. Also ignore the EFC numbers in the actual output from DecodeIr.

If you are using a OneForAll type remote but have neither a JP1 cable nor a remote model that can be upgraded by .wav file, then nothing about Upgrades, KM, RM, and OBC numbers applies to your use. If the decodes you get include EFC numbers and you know (or can ask in a forum) which setup code is right (corresponds to the protocol, device and subdevice of the decode) then you can use those EFC numbers in KeyMoves. Note that the decoding process cannot directly tell you which setup code is needed to generate the signal. If you post a question in an appropriate forum with the protocol name, device number, subdevice number, and which model OneForAll type remote you have, someone will probably identify the setup code for you.

Toggle bits

Several different protocols include something called a toggle bit. This means that each command has two or more different forms. Some protocols (e.g. RC5) alternate the toggle on each key press, while others change the toggle to indicate a start or end frame.

An alternating toggle lets the device receiving the commands distinguish between a long press of a button and two short presses. For example, if you press and hold the '1' button the remote continuously sends repeats of a single form of the '1' command. But if you press '1', release it and press it again the remote will switch to the other form of the command for the second press.

When you learn such a command you are capturing just one form of the command and every use will send that same form. If you use that learned signal and press the same button twice in a row, the device receiving the signal will see that as one long press rather than two short ones. For keys, such as digits, where one long press has a different meaning than two short presses, that gets quite inconvenient.

With OneForAll type remotes, using an upgrade or KeyMove will solve that problem.

For some of these protocols, for some models of Pronto remote, there is a condensed encoding of the Pronto Hex that will solve the problem.

Repeat frames and dittos

DecodeIR v2.37 and later versions have a look-ahead facility that is not present in earlier ones. This distinguishes between two styles of data passed to them by the calling application. The remote control programming applications IR.exe and RMIR pass signals learned by a UEI remote that has itself performed a partial analysis of the signal. The data is passed in a structured form, divided into Once, Repeat and Extra sections. The data in each of these sections can be viewed in IR.exe if the "Force Learned Timings" option on the Advanced menu is selected. Because of this analysis, DecodeIR does not see the original signal in full and cannot determine such things as the number of repeats of the signal that were sent. Other applications such as the IRScope software for the IR Widget send the entire signal as unstructured data, which enables IR.exe to identify the number of repeats.

The look-ahead facility checks successive frames within a single signal to see if they are repeats either identical repeats or, in certain protocols, frames of a repeat sequence that have a distinctive marker in either the start or end frame, or both, of the sequence. If a protocol has distinctive start or end frame markers and either or both of the start and end frames are missing, this is reported in the Misc field of the decode (but at present this may not be implemented for all protocols with such markers). If the data has been passed in an unstructured form then the number of repeats in the signal will also be reported in the Misc field in a form like "4 frames", or in version 2.39 and later, "+ 3 copies".

In the case of unstructured data, DecodeIR v2.38 extends the look-ahead to protocols in which repeat action is signalled not by a full repeat of the frame but by a much shorter frame that does not carry the signal data (or occasionally carries just part of this data). These frames serve as "ditto marks". If present then the number of such frames is reported in the Misc field in a form like "3 dittos", or in version 2.39 and later, "+ 3 dittos". If there are no repeat frames or ditto marks, then to avoid ambiguity this is reported as "no repeat".

Mini Combos

Some UEI protocol executors are "mini-combos". This means they support more than one device number within one setup code using single-byte hex commands. There will be more than one possible EFC number for each OBC number. DecodeIr can't determine the correct EFC number by looking at the IR signal, because it isn't a characteristic of the signal. It is a characteristic of the fixed data used in creation of the setup code.

DecodeIr will list two or three different EFC numbers for each OBC number. The sequence of those two or three EFC numbers is consistent across all the decodes. So once you find out which position in that list is correct for one OBC of a given device number and setup code, that position will be correct for the EFC list of any other OBC of the same device and setup code (except that for RC-5 the decision of whether or not the OBC number is above 63 is treated as being part of the device number).

Brief and incomplete guide to reading IRP

General: {carrier frequency, time unit, sequencing rule} Mitsubishi:{32.6k,300}<1,-3|1,-7>(D:8,F:8,1,-80)+
Carrier Frequency: Hz; e.g. 38.3k; default is 0k--no modulation
Time Unit: Integer that can represent durations. Suffix u (default) is microseconds, p denotes number of pulses of the carrier.
Sequencing Rule: lsb|msb; lsb (default) means the least significant bit of a binary form is sent first.
BitSpec: Rule for the translating bit sequences to duration sequences. <ZeroPulseSeq|OnePulseSeq|TwoPulseSeq....>. Most IR protocols use only <ZeroPulseSeq|OnePulseSeq>, and the sequence is simply OnDuration,OffDuration. Example: NEC uses <1,-1|1,-3>
Bitfield: D:NumberOfBits:StartingBit. E.g. if D=71= 01000111, D:2:5 means x10xxxxx. D:2:5 = 10b = 2. ~ is the bitwise complement operator. ~D =10111000. Specifying the StartingBit is optional. D:6 is equivalent to D:6:0.
IRStream: The sequence of data. Enclosed in parentheses, items separated by commas. A trailing + means send one or more times. A trailing 3 means send 3 times; 3+ means at least 3 times. A trailing * means send zero or more times. NEC2: {38.4k,564}<1,-1|1,-3>(16,-8,D:8,S:8,F:8,~F:8,1,-78)+
Durations: no suffix means duration is expressed in Time Units, as defined above. m is milliseconds, u microsec, p pulses. No prefix means a flash, a preceeding - (minus) means a gap.
Extent: A gap which trails a signal. The trailing gap is adjusted to make the total length of signal plus trailing gap equal to the extent. Notation is like a gap duration, except ^ replaces the minus sign. RC-5:(1:1,~F:1:6,T:1,D:5,F:6,^114m)+
Expressions: names, numbers and bitfields connected by standard symbols for arithmetic and logical operations. Enclosed in parentheses. Panasonic: {37k,432}<1,-1|1,-3>(8,-4,2:8,32:8,D:8,S:8,F:8,(D^S^F):8,1,-173)+
Permitted operators in decreasing order of precedence:
unary (negation)
** (exponentiation)
* /, % (multiplication, integer division, modulo) (* is also used in IRStreams)
+, (addition, subtraction (+ is also used in IRStreams)
& (bitwise AND)
^ (exclusive OR) (also used in extents)
| (OR)
~ (complement) is permitted in Bitfields

Definitions: expressions separated by commas, enclosed in curly brackets. GI Cable: {38.7k,490}<1,-4.5|1,-9>(18,-9,F:8,D:4,C:4,1,-84,(18,-4.5,1,-178)*) {C = -(D + F:4 + F:4:4)}
Assignments: For example T=T+1, which can be used to describe the RC-5 toggle bit.
Variations: Up to 3 expressions enclosed in square brackets. The first variation is sent on the first transmission, second for middle transmissons, and the third for the final transmission. E.g. the Zaptor toggle bit is zero until the last frame: [T=0] [T=0] [T=1]
The IRP specification by Graham Dixon
Practical explanation of IR signals and IRP by Vicky Getz

48-NEC

If you get a decode whose protocol name is simply "48-NEC" that indicates the learned signal is not complete (usually caused by not holding the original remote's button long enough during learning). Enough of the signal is present to accurately determining the device, subdevice and OBC numbers. But not enough is present to determine whether the protocol is 48-NEC1 or 48-NEC2.

48-NEC1

IRP notation: {564}<1,-1|1,-3>(16,-8,D:8,S:8,F:8,~F:8,E:8,~E:8,1,-??,(16,-4,1,-??)*)
EFC translation: LSB

This protocol signals repeats by the use of dittos.

48-NEC2

IRP notation: {564}<1,-1|1,-3>(16,-8,D:8,S:8,F:8,~F:8,E:8,~E:8,1,-??)+
EFC translation: LSB

AdNotam

IRP notation: {35.7Khz,895,msb}<1,-1|1,-3>(0:1,1:1,D:6,F:6,^114m)+

Very similar to RC5, except AdNotam uses two start bits, and no toggle bit.

AirAsync

IRP notation: {37.7Khz,840}<1|-1>( 1,B:8,-2 ... )

This protocol uses asynchronous data transmission that sends an 8-bit byte with 1 start bit, 8 data bits and 2 stop bits. The minimum signal is one byte. The protocol is reported as AirAsyncn-xx.yy. ... where n is the number of bytes and xx, yy, ... are the byte values in hexadecimal notation.

AirB?-????

This is not a robust protocol, so spurious decodes are likely. If you see this decode from something other than an IR keyboard, you should probably ignore it.

Aiwa

UEI protocol: 005E or 009E
IRP notation: {38k,550}<1,-1|1,-3>(16,-8,D:8,S:5,~D:8,~S:5,F:8,~F:8,1,-42,(16,-8,1,-165)*)
EFC translation: LSB

This protocol signals repeats by the use of dittos.

The EFC numbering varies among the KM and RM versions of Aiwa. Using OBC numbers is less confusing.

When using a non-combo version of Aiwa in KM, you must combine the device and subdevice numbers as device+256*subdevice to get the number KM calls "Device Code". (Since subdevice is usually zero, that combination is trivial). In Aiwa combo in KM you use the subdevice as "parameter" (on the setup sheet) and put the device in the byte2 column on the functions sheet. RM follows DecodeIr's naming of Device and Subdevice.

AK

Documentation not written yet.

Akai

UEI protocol: 000D
IRP notation: {38k,289}<1,-2.6|1,-6.3>(D:3,F:7,1,^25.3m)+
EFC translation: LSB comp prefixed with last device bit

This is not a robust protocol, so spurious decodes are likely.

As of version 8.31, KM does not translate device to fixed data, nor OBC to EFC according to the same rules used by DecodeIr. RM does translate consistently with DecodeIr, so you may find it easier to use RM. If you use KM, you must change the device number as follows:

Also (in KM) you should use the EFC number from the decode not the OBC number. Akai protocol uses the same EFC numbering across all JP1 remotes, so use of EFC is safe. KM uses different OBC numbering than RM and DecodeIr, so use of OBCs isn't safe.

Amino

UEI protocol: 019C
IRP notation: {56.0k,268,msb}<-1,1|1,-1>[T=1] [T=0] (7,-6,3,D:4,1:1,T:1,1:2,0:8,F:8,15:4,C:4,-79m)+
-----Variant: {36.0k,268,msb}<-1,1|1,-1>[T=1] [T=0] (7,-6,3,D:4,1:1,T:1,1:2,0:8,F:8,15:4,C:4,-79m)+
{C =(D:4+4*T+9+F:4+F:4:4+15)&15} [the arithmetic sum of the first 7 nibbles mod 15]
T=1 for the first frame and T=0 for all repeat frames.
DecodeIR v2.43 checks T and will report in the Misc field if the start or end frame is missing. Amino equipment use both 36 and 56KHz, but the duration of the half-bit is always 268. Zaptor is a closely related protocol which for which the half-bit duration is 330. IRDecode v2.43 distinguishes between Amino and Zaptor in order of priority by 1)the position of the toggle bit, 2)the value of the next to last nibble, and 3)the measured duration of a half-bit.
EFC translation: MSB

Anthem

UEI protocol: 0123
IRP notation: {38.0k,605}<1,-1|1,-3>((8000u,-4000u,D:8,S:8,E:8,C:8,1,-25m)3, -75m)+ {E=(64*U:2+F:6), C=~(D+S+E+255):8}
Anthem framing is very similar to NEC, and also uses 32 bits of data. However, the leadout is much shorter. The signal is sent at least3 times.

Apple

UEI protocol: 01E0
IRP notation: {38.4k,564}<1,-1|1,-3>(16,-8,D:8,S:8,C:1,F:7,I:8,1,-78,(16,-4,1,-173)*)
C=1 if the number of 1 bits in the fields F and I is even. I is the remote ID.

Apple uses the same framing as NEC1, with D=238 in normal use, 224 while pairing. S=135

Archer

IRP notation: {0k,12}<1,-3.3m|1,-4.7m>(F:5,1,-9.7m)+
EFC translation: 5-bit LSB

This is not a robust protocol, so spurious decodes are likely.

Async

This protocol uses asynchronous data transmission that sends an 8-bit byte with 1 start bit, 8 data bits and 1 stop bit. The minimum signal is four bytes. The protocol is reported as Asyncn:min-max:aa.bb...yy.zz where n is the number of bytes, min-max is the range of durations in microseconds that was taken as a single bit and aa.bb...yy.zz are the first two and last two byte values in hexadecimal notation.

Blaupunkt

IRP notation: {30.3k,528}<-1,1|1,-1>(1,-5,1023:10,-39,1,-5,1:1,F:7,D:2,-230)

Bose

IRP notation: {500,msb}<1,-1|1,-3>(2,-3,F:8,~F:8,1,-???)+
EFC translation: MSB The decode is intended to be consistent with the posted KM file: Bose-Wave-Radio-KM.txt and PB file: Bose_Wave_Radio-PB.txt

CanalSat

UEI protocol: 018C
IRP notation: {55.5k,250,msb}<-1,1|1,-1>(1:1,D:7,S:6,T:1,0:1,F:7,-89m)+
EFC translation: 7-bit MSB.

The repeat frames are not all identical. T toggles within a single signal, with T=0 for the start frame and T=1 for all repeats. DecodeIR v2.37 and later check T and will report in the Misc field if the start frame is missing.

Denon, Denon{1} and Denon{2}

IRP notation: {38k,264}<1,-3|1,-7>(D:5,F:8,0:2,1,-165,D:5,~F:8,3:2,1,-165)+
EFC translation: LSB

A Denon signal has two halves, either one of which is enough to fully decode the information. A significant fraction of Denon learned signals contain just one half or have the halves separated so that DecodeIr can't process them together. When one half is seen separate from the other, DecodeIr will name the protocol Denon{1} or Denon{2} depending on which half is decoded. Denon, Denon{1} and Denon{2} all represent the same protocol when they are correct. But only Denon is robust. A Denon{1} or Denon{2} decode might be spurious.

Denon-K

UEI protocol: 00CD
IRP notation: {37k,432}<1,-1,1,-3>(8,-4,84:8,50:8,0:4,D:4,S:4,F:12,((D*16)^S^(F*16)^(F:8:4)):8,1,-173)+
EFC translation: LSB comp

Denon-K is the member of the Kaseikyo family with OEM_code1=84 and OEM_code2=50.

Denon-K uses the same check byte rules as Panasonic protocol, but uses the data bits differently. The Panasonic Combo protocol in KM can be used with some difficulty to produce Denon-K signals. The Denon-K choice in RM uses the same protocol executor as Panasonic combo, but computes the hex commands based on Denon's use of the Kaseikyo data bits.

Dgtec

UEI protocol: 016A
IRP notation: {38k,560}<1,-1|1,-3>(16,-8,D:8,F:8,~F:8,1,^108m,(16,-4,1,^108m)+)
EFC translation: LSB comp

This protocol signals repeats by the use of dittos.

DirecTV

IRP notation: {38k,600,msb}<1,-1|1,-2|2,-1|2,-2>(5,(5,-2,D:4,F:8,C:4,1,-50)+) {C=7*(F:2:6)+5*(F:2:4)+3*(F:2:2)+(F:2)}
EFC translation: MSB

There are six variants of the DirecTV protocol, distinguished in RemoteMaster by the parameter "Parm" on the Setup page. The Parm value is shown in the Misc field of DecodeIR. The IRP notation above corresponds to the default Parm=3. The various Parm values correspond to three different frequencies (the 38k in the above) and two different lead-out times (the -50 in the above). The corresponding values are:

Portions of a dirty learn of a Sony signal may look like a DirecTV signal. So, if you get a DirecTV decode together with a plausible Sony decode, believe the Sony decode and ignore the DirecTV. If you get a DirecTV decode without a Sony decode for some functions of a Sony device, try relearning them; a DirecTV decode for a signal meant for a Sony device is not likely to be correct.

This protocol was called Russound in versions of DecodeIR earlier than 2.40.

Dishplayer

UEI protocol: 010F
IRP notation: {38.4k,535,msb}<1,-5|1,-3>(1,-11,(F:6,U:5,D:2,1,-11)+)
EFC translation: Not available in this version of DecodeIr

This is not a robust protocol, so spurious decodes are likely.

Dish_Network

UEI protocol: 0002
IRP notation: {57.6k,400}<1,-7|1,-4>(1,-15,(F:-6,U:5,D:5,1,-15)+)
EFC translation: MSB comp 6 function bits followed by LSB comp low 2 unit bits.

This is not a robust protocol, so spurious decodes are likely.

The unit number shows up in the Subdevice field of DecodeIr's output. In KM, the "unit code" is one greater than the unit number. So you must take the Subdevice from the decode and add one to it and use that as the "unit code" in KM.

There are two variants of the protocol executor for DishNetwork with different but compatible EFC numbering. The decoded EFC should work for both. But the results may be less confusing if you use OBC numbers in KM or RM.

EchoStar

UEI protocol: 0182
As of 2.42 DecodeIR shows this as RC5-7F

Emerson

UEI protocol: 0065
IRP notation: {36.7k,872}<1,-1|1,-3>(4,-4,D:6,F:6,~D:6,~F:6,1,-39)+
EFC translation: 6-bit LSB comp with 2-bit mini-combo

Lists three different EFCs because this protocol is a mini combo.

F12

UEI protocol: 001A
IRP notation: (Toshiba specification) K=(D:3,H:1,A:1,B:2,F:6) {37.9k,422}<1,-3|3,-1>(K,-34,K) for A=1 or B=1
{37.9k,422}<1,-3|3,-1>(K,-34,K,-88,K,-34,K)+ for H=1. Exactly one of H, A, or B can have a value of 1. If H=1 the signal can be sent repeatedly, and F can take any 6 bit value. If A or B=1, the signal is sent once only per button press, and only a single bit of F can be non-zero.

IRP notation: (JP1) K=(D:3,H:1,F:8) {37.9k,422}<1,-3|3,-1>(K,-34,K) for H=0.
{37.9k,422}<1,-3|3,-1>(K,-34,K,-88,K,-34,K)+ for H=1.
A and B are subsumed into F, and the value of H is computed in the executor. H=A^B.
EFC translation: lsb, but not computed in DecodeIR.
DecodeIR reports H as the subdevice. This is useful when making a Pronto Hex file, or other description based on durations. Remotes with executors (e.g. UEI remotes) normally compute the value of H in the executor, and the "subdevice" is not needed as a parameter.

Fujitsu

UEI protocol: 00F8
IRP notation: {37k,432}<1,-1,1,-3>(8,-4,20:8,99:8,X:4,E:4,D:8,S:8,F:8,1,-110)+
EFC translation: LSB comp

Fujitsu is the member of the Kaseikyo family with OEM_code1=20 and OEM_code2=99.

There is no check byte, so the risk of an incorrectly decoded OBC is much higher than in other Kaseikyo protocols.

00F8 requires 2-byte hex commands, so the decoded EFC number is generally not useful. Use OBC number in upgrades or to compute Hex commands.

Fujitsu-56

IRP notation: {37k,432}<1,-1,1,-3>(8,-4,20:8,99:8,H:4,E:4,D:8,S:8,X:8,F:8,1,-110)+

G.I. Cable and G.I. Cable{1}

UEI protocol: 00C4
IRP notation: {38.7k,490}<1,-4.5|1,-9>(18,-9,F:8,D:4,C:4,1,-84,(18,-4.5,1,-178)*) {C = -(D + F:4 + F:4:4)}
EFC translation: LSB

This protocol signals repeats by the use of dittos. When the {1} is shown as part of the protocol name for G.I. Cable, it just means that the repeat part of the signal is not present. That doesn't indicate any difference in the actual protocol nor even any unreliability in the decode. It may indicate that use of the learned signal will be less reliable, so you have more than usual reason to replace it with a KeyMove, Upgrade or cleaned up version.

G.I.4DTV

UEI protocol: 00A4
IRP notation: {37.3k,992}<1,-1|1,-3>(5,-2,F:6,D:2,C:4,1,-60)+
EFC translation: NONE

This is a moderately robust protocol, but spurious decodes are still possible.

The official (UEI) protocol executor for G.I.4DTV does not support EFC numbers. If you are creating an upgrade in KM or RM you should use OBC numbers, not EFC numbers. If you need the Hex Cmd for a KeyMove, you should use the functions sheet of KM or RM to compute it for you from the OBC and device number.

Grundig16 and Grundig16-30

UEI protocol: Grundig16 0112, Grundig16-30 00AB
IRP notation for Grundig16: {35.7k,578,msb}<-4,2|-3,1,-1,1|-2,1,-2,1|-1,1,-3,1> (806u,-2960u,1346u,T:1,F:8,D:7,-100)+
IRP notation for Grundig16-30: {30.3k,578,msb}<-4,2|-3,1,-1,1|-2,1,-2,1|-1,1,-3,1> (806u,-2960u,1346u,T:1,F:8,D:7,-100)+
EFC translation: MSB but with bit pairs translated data->hex by 00->00, 01->11, 10->01, 11-> 10 and off by one position.

These are two variants of the same protocol, differing only in frequency. The IRP notation is corrected from previous versions of this document, to bring it into line with what DecodeIR actually does.

GXB

IRP notation: {38.3k,520,msb}<1,-3|3,-1>(1,-1,D:4,F:8,P:1,1,^???)+

Decoder for a nonstandard Xbox remote.

IODATAn and IODATAn-x-y

UEI protocol: not known.
IRP notation: {38k,550}<1,-1|1,-3>(16,-8,x:7,D:7,S:7,y:7,F:8,C:4,1,^108m)+ {n = F:4 ^ F:4:4 ^ C:4}
EFC translation: LSB

This is potentially a class of protocols distinguished by values of n, x and y with n = 0..15 and x, y = 0..127. If x and y are both zero, they are omitted. The only known example is IODATA1.

Jerrold

UEI protocol: 0006
IRP notation: {0k,44}<1,-7.5m|1,-11.5m>(F:5,1,-23.5m)+

This is not a robust protocol, so spurious decodes are likely.

JVC and JVC{2}

UEI protocol: 0034
IRP notation: {38k,525}<1,-1|1,-3>(16,-8,(D:8,F:8,1,-45)+)
EFC translation: LSB comp

JVC{2} indicates a JVC signal from which the lead-in is missing. The JVC protocol has lead-in on only the first frame, so it is quite easy to have it missing from a learned signal. So when JVC{2} is correct, it means the same as JVC. But JVC{2} is not robust, so spurious decodes are likely. It is also very similar in structure and timing to Mitsubishi protocol, so that DecodeIr has difficulty distinguishing one from the other. The device number, OBC and EFC are all encoded the same way between the two. So if you have JVC{2} decodes that you have reason to suspect should actually be Mitsubishi, you can try using them as Mitsubishi without changing the numbers. However, true Mitsubishi signals will not misdecode as JVC, just as JVC{2}. So if some of the signals for your device decode as JVC and others as JVC{2}, you should trust all those decodes and not try Mitsubishi.

JVC-48

UEI protocol: 001F or 00C9 or 00CD
IRP notation: {37k,432}<1,-1|1,-3>(8,-4,3:8,1:8,D:8,S:8,F:8,(D^S^F):8,1,-173)+
EFC translation: LSB comp

JVC-48 is the member of the Kaseikyo family with OEM_code1=3 and OEM_code2=31.

Panasonic protocol uses the same check byte rules as JVC-48, so you might want use the (more flexible) Panasonic entries in KM or RM to produce a JVC-48 upgrade (by changing the OEM_code1 and OEM_code2 values). For simple JVC-48 upgrades you get exactly the same results by directly selecting the "JVC-48" protocol.

JVC-56

IRP notation: {37k,432}<1,-1|1,-3>(8,-4,3:8,1:8,D:8,S:8,X:8,F:8,(D^S^X^F):8,1,-173)+

Kaseikyo

Kaseikyo is a family of protocols that includes Panasonic, Mitsubishi-K, Fujitsu, Sharp-DVD and Teac-K. Each protocol in the Kaseikyo family is identified by two numbers, known as OEM_code1 and OEM_code2.

Most members of the family have minor structural differences from the generic form. In those cases DecodeIR checks for the specific details (based on the OEM codes) and if they are correct reports the protocol by name (see Panasonic and Teak-K below).

In the few cases where the structure exactly fits my understanding of the Kaseikyo spec, DecodeIR reports it as Kaseikyo-???-??? replacing the first ??? by the OEM_code1 and the second ??? by the OEM_code2.

Kaseikyo-???-???

IRP notation: {37k,432}<1,-1|1,-3>(8,-4,M:8,N:8,X:4,D:4,S:8,F:8,E:4,C:4,1,-173)+ {X=M:4:0^M:4:4^N:4:0^N:4:4,C=D^S:4:0^S:4:4^F:4:0^F:4:4^E}
EFC translation: LSB comp

This is the nominal form of the Kaseikyo. It is most commonly seen with OEM codes 170.90, which indicates "Sharp". I assume (haven't tested) that the SharpDVD protocol in KM generates these Kaseikyo-170-90 signals. We have also seen this protocol with OEM codes 3.32. I'm not sure what manufacturer that indicates.

The Kaseikyo protocol in KM seems to be designed to produce this nominal form of Kaseikyo for any specified OEM codes and any constant value of E. That should be the way to reproduce any Kaseikyo-???-??? decode other than SharpDVD, and might be better than SharpDVD for the Kaseikyo-170-90 signals.

Kaseikyo56

Kaseikyo56 is a lengthened version of the Kaseikyo family of protocols. It has the same OEM codes indicating the same manufacturers as Kaseikyo, and it has the same variation (by manufacturer) in check byte and other details as Kaseikyo.

Kaseikyo56-???-???

IRP notation: {37k,432}<1,-1|1,-3>(8,-4,M:8,N:8,H:4,D:4,S:8,X:8,F:8,E:4,C:4,1,-173)+

Kathrein

UEI protocol: 0066
IRP notation: {38k,540}<1,-1|1,-3>(16,-8,D:4,~D:4,F:8,~F:8,1,^105m,(16,-8,F:8,1,^105m)+)
EFC translation: LSB comp

This protocol signals repeats by the use of dittos. It is unusual in that the ditto frame carries part of the signal data, specifically the function code (OBC) but not the device code.

Konka

UEI protocol: 019B
IRP notation: {38k,500,msb}<1,-3|1,-5>(6,-6,D:8,F:8,1,-8,1,-46)+
EFC translation: MSB

Lumagen

IRP notation: {38.4k,416,msb}<1,-6|1,-12>(D:4,C:1,F:7,1,-26)+ {C = odd parity for F}
EFC translation: MSB prepended with C bit.

This is a moderately robust protocol, but spurious decodes are still possible.

Lutron

IRP notation: {40k,2300,msb}<-1|1>(255:8,X:24,0:4)+
EFC translation: MSB of decoded signal.

This is an unusual protocol in that an 8-bit device code and 8-bit OBC are encoded in a 24-bit error-correcting code as the X of the IRP notation. This is constructed as follows. First two parity bits are appended to the 16 data bits to give even parity for the two sets of 9 bits taken alternately. The resulting 18-bit sequence is then treated as 6 octal digits (0-7) expressed in 3-bit binary code. These are then re-coded in the 3-bit Gray code (also called, more descriptively, the reflected-binary code) with a parity bit to give odd parity, so giving 6 4-bit groups treated as a single 24-bit sequence. The whole thing allows any single-bit error in transmission to be identified and corrected.

Matsui

IRP notation: {38K,525}<1,-1|1,-3>(D:3,F:7,1,^30.5m)+
EFC translation: Not available in this version of DecodeIr

This is not a robust protocol, so spurious decodes are likely.

MCE (RC6-6-32)

IRP notation: {36k,444,msb}<-1,1|1,-1>(6,-2,1:1,6:3,-2,2,OEM1:8,OEM2:8,T:1,D:7,F:8,-???)+

MCE is a member of the RC6 family. Technically it is RC6-6-32 with the standard toggle bit zero, with the OEM1 field equal to 128, and with a nonstandard (for the RC6 family) toggle bit added. If all those rules are met, DecodeIr will display the name as "MCE" and with the OEM2 field moved to the subdevice position. Otherwise it will display RC6-6-32.

As of version 8.31, KM does not have built-in support for this protocol, but there are KM format upgrade files available for Media Center (built by an expert who isn't limited to KM's built-in protocols). Those upgrades should be adaptable to any RC6-6-32 code set (by changing the fixed data), if the one you have doesn't already match the upgrade.

RM version 1.16 has support for RC6-6-32, which can be used for MCE upgrades. Version 1.17 will also have direct support for MCE

Metz19

IRP notation: (37.9K,106,msb)<4,-9|4,-16>(8,-22,T:1,D:3,~D:3,F:6,~F:6,4,-125m)+
The toggle bit T is inverted each time a new button press occurs.

Mitsubishi

UEI protocol: 0014
IRP notation: {32.6k,300}<1,-3|1,-7>(D:8,F:8,1,-80)+
EFC translation: LSB comp

This is not a robust protocol, so spurious decodes are likely. It is also very similar in structure and timing to JVC{2} protocol, so that DecodeIr has difficulty distinguishing one from the other. The device number, OBC and EFC are all encoded the same way between the two. So if you have Mitsubishi decodes that you have reason to suspect should actually be JVC, you can try using them as JVC without changing the numbers.

Mitsubishi-K

IRP notation: {37k,432}<1,-1|1,-3>(8,-4,35:8,203:8,X:4,D:8,S:8,F:8,T:4,1,-100)+
EFC translation: not available yet

Mitsubishi-K is the member of the Kaseikyo family with OEM_code1=35 and OEM_code2=203.

NEC

NEC is a family of similar protocols including NEC1, NEC2, Tivo, Pioneer, Apple, NECx1 and NECx2. If you get a decode whose protocol name is simply "NEC" that indicates the learned signal is not complete (usually caused by not holding the original remote's button long enough during learning). Enough of the signal is present to accurately determine the device, subdevice and OBC numbers. But not enough is present to determine whether the protocol is NEC1 or NEC2.

Difference between NEC1 and NEC2

The difference between NEC1 and NEC2 only affects the signal sent by a long keypress. A short press sends the same signal in NEC1 and NEC2.

Variant IRstreams in NEC protocols

For NEC1, NEC2, NECx1, and NECx2 protocols, the IRstream contains D:8,S:8,F:8,~F:8
However, some manufacturers (especially Yamaha and Onkyo) are breaking the "rule" that the 4th byte should be ~F:8
Version 2.42 decodes these variants by adding suffixes to the protocol name depending on the IRstream:
-y1: D:8,S:8,F:8,~F:7,F:1:7 (complement all of F except the MSB)
-y2: D:8,S:8,F:8,F:1,~F:7:1 (complement all of F except the LSB)
-y3: D:8,S:8,F:8,F:1,~F:6:1,F:1:7 (complement all of F except MSB and LSB)
-f16: D:8,S:8,F:8,E:8 (no relationship between the 3rd and 4th bytes)

NEC1

IRP notation: {38.4k,564}<1,-1|1,-3>(16,-8,D:8,S:8,F:8,~F:8,1,-78,(16,-4,1,-173)*)
EFC translation: LSB comp

A few devices use NEC1 protocol at 40Khz, rather than the typical frequency. When getting a decode of NEC1, if you notice that the frequency is closer to 40Khz than to 38Khz, examine multiple learns from the same device to estimate whether the 40Khz frequency is a learning error or a true characteristic of the device. If the 40Khz is correct, there are methods in JP1, or MakeHex (whichever you are using) to reproduce NEC1 at 40Khz rather than the usual frequency.

NEC2

IRP notation: {38.4k,564}<1,-1|1,-3>(16,-8,D:8,S:8,F:8,~F:8,1,-78)+
EFC translation: LSB comp

Pioneer is distinguished from NEC2 only by frequency. So if your learning system does not learn frequency accurately, it won't accurately distinguish Pioneer from NEC2. All Pioneer signals should have a device number in the range 160 to 175 and no subdevice. No NEC2 signal should fit those rules. So you usually can determine whether the decision (by frequency) was wrong by checking the device numbers.

NECx

If you get a decode whose protocol name is simply "NECx" that indicates the learned signal is not complete (usually caused by not holding the original remote's button long enough during learning). Enough of the signal is present to accurately determining the device, subdevice and OBC numbers. But not enough is present to determine the exact protocol, which is probably NECx1 or NECx2. This incomplete learn also makes it harder to distinguish NEC from NECx, so a decode of "NECx" might be NEC1 or NEC2 or even Tivo or Pioneer.

NECx1

IRP notation: {38.4k,564}<1,-1|1,-3>(8,-8,D:8,S:8,F:8,~F8,1,^108m,(8,-8,D:1,1,^108m)*)
EFC translation: LSB comp
Most, but not all NECx1 signals have S=D

NECx2

IRP notation: {38.4k,564}<1,-1|1,-3>(8,-8,D:8,S:8,F:8,~F8,1,^108m)+
EFC translation: LSB comp
Most, but not all NECx2 signals have S=D

Nokia

IRP notation: {36k,msb}<164,-276|164,-445|164,-614|164,-783>(412,-276,D:8,S:8,F:8,164,-???)+
EFC translation: MSB

Nokia12

IRP notation: {36k,msb}<164,-276|164,-445|164,-614|164,-783>(412,-276,D:4,F:8,164,-???)+
EFC translation: MSB

Nokia32

UEI protocol: 0173
IRP notation: {36k,msb}<164,-276|164,-445|164,-614|164,-783>(412,-276,D:8,S:8,X:8,F:8,164,^100m)+
EFC translation: MSB

NRC16

Documentation not written yet.

NRC17

UEI protocol: 00BD

OrtekMCE

UEI protocol: not known.
IRP notation: {38.6k,480}<1,-1|-1,1>(4,-1,D:5,P:2,F:6,C:4,-48m)+
EFC translation: 6-bit LSB comp

The repeat frames are not all identical. P is a position code: 0 for the start frame of a repeat sequence, 2 for the end frame and 1 for all frames in between. C is a checksum, 3 more than the number of 1 bits in D, P, F together. DecodeIR v2.37 and later check P and will report in the Misc field if either the start or end frame, or both, is/are missing.

Pace MSS

IRP notation: {38k,630,msb}<1,-7|1,-11>(1,-5,1,-5,T:1,D:1,F:8,1,^120m)+
EFC translation: Not available in this version of DecodeIr

This is a moderately robust protocol, but spurious decodes are still possible.

Panasonic

UEI protocol: 001F or 00C9 or 00CD
IRP notation: {37k,432}<1,-1|1,-3>(8,-4,2:8,32:8,D:8,S:8,F:8,(D^S^F):8,1,-173)+
EFC translation: LSB comp

Panasonic protocol is the most commonly seen member of the Kaseikyo family

OEM_code1 is 2 and OEM_code2 is 32 (or DecodeIr won't display the name as "Panasonic"). So those values in KM or RM can be changed from the default 2 and 32 only when using the Panasonic entry in KM or RM to produce some Kaseikyo variant OTHER THAN Panasonic. When creating a Panasonic upgrade, don't change those from the default values.

Panasonic2

IRP notation: {37k,432}<1,-1|1,-3>(8,-4,2:8,32:8,D:8,S:8,X:8,F:8,(D^S^X^F):8,1,-173)+

Panasonic_Old

UEI protocol: 0000
IRP notation: {57.6k,833}<1,-1|1,-3>(4,-4,D:5,F:6,~D:5,~F:6,1,-???)+
EFC translation: 6-bit LSB comp with 2-bit mini-combo

Lists three different EFCs because this protocol is a mini combo.

PCTV

IRP notation: {38.4k,832}<0,-1|1,-0>(2,-8,1,D:8,F:8,2,-???)

pid-0001

UEI protocol: 0001
IRP notation: {0k,msb}<24,-9314|24,-13486>(24,-21148,(F:5,1,-28m)+)
EFC translation: 5-bit MSB comp

As of version 8.31 KM has seriously wrong OBC translation for pid-0001, so use only EFC's with KM.

pid-0003

UEI protocol: 0003
IRP notation: {40.2k,389}<2,-2|3,-1>(F:8,~F:8,^102k)+
EFC translation: LSB

pid-0004

UEI protocol: 0004
IRP notation: {0k,msb}<12,-130|12,-372>(F:6,12,-27k)+
EFC translation: 6-bit MSB comp

pid-002A

UEI protocol: 002A
IRP notation: {0k,10}<1,-5|1,-15>(1,-25, D:5,F:6, 1,-25,1,120m)+
EFC translation: 6-bit LSB comp
Used primarily in Barco remotes.

This is a moderately robust protocol, but spurious decodes are still possible.

pid-0083

UEI protocol: 0083
EFC translation: 5-bit MSB comp
IRP notation: {42.3K, 3000}<1,-3,1,-7|1,-7,1,-3>(F:5,1,-27)+

This protocol is a very limited design. We have seen it used only in the UEI setup code TV/0159, which is for some TVs brand named Fisher, Sanyo and Sears. It is not likely that any other code set uses this protocol. So if you get a correct decode of pid-0083 you probably have a TV that can be controlled by the TV/0159 setup code.

As of version 8.31, KM does not translate OBC to EFC according to the same rules used by DecodeIr. RM does translate consistently with DecodeIr, so you may find it easier to use RM. If you use KM, you should use the EFC number from the decode not the OBC number. Pid-0083 protocol uses the same EFC numbering across all JP1 remotes, so use of EFC is safe. KM uses different OBC numbering than RM and DecodeIr, so use of OBCs isn't safe.

Pioneer

IRP notation: {40k,564}<1,-1|1,-3>(16,-8,D:8,S:8,F:8,~F:8,1,-78)+
EFC translation: LSB comp

Pioneer is distinguished from NEC2 only by frequency. So if your learning system does not learn frequency accurately, it won't accurately distinguish Pioneer from NEC2. All Pioneer signals should have a device number in the range 160 to 175 and no subdevice. No NEC2 signal should fit those rules. So you usually can determine whether the decision (by frequency) was wrong by checking the device numbers.

Many Pioneer commands are sent as combinations of two different Pioneer signals. This version of DecodeIr does not associate the two signals together into one command. It decodes them separately. If you get more than one of the same OBC from decoding a learned signal, that just means the learning system failed to understand the repeat pattern. It does not mean a two part signal. But if there are two different OBCs (with the same or different device numbers) you have a two part Pioneer signal.

Including a two part Pioneer signal in a KeyMove or upgrade is a complex process that requires a good understanding of Pioneer signals and of the Pioneer support in KM. The signals don't vary much among related Pioneer models. So the best way to get an upgrade or hex cmd including such signals is to look through existing Pioneer upgrades in the JP1 group and find one that already includes the same (or nearly same) signal.

Proton

UEI protocol: 005C
IRP notation: {38k,500}<1,-1|1,-3>(16,-8,D:8,1,-8,F:8,1,^63m)+
EFC translation: LSB comp

This is not a robust protocol, so spurious decodes are likely.

RC5

UEI protocol: 00E8
IRP notation: {36k,msb,889}<1,-1|-1,1>(1:1,~F:1:6,T:1,D:5,F:6,^114m)+
EFC translation: 6-bit MSB comp with 2-bit mini-combo

Lists three different EFCs because this protocol is a mini combo.

What we call "device" is really the "System" and what we call "OBC" is really the "Command". If you are using ProntoEdit to create the RC5 signals directly, that GUI uses that correct (System and Command) Philips terminology.

RC5-7F

UEI protocol: 0182
IRP notation: {36k,msb,889}<1,-1|-1,1>(1:1, D:1:5,T:1,D:5,F:7,^114m)+
EFC translation: 7-bit MSB comp

RC5-7F-57

UEI protocol: 0182
IRP notation: {57k,msb,889}<1,-1|-1,1>(1:1, D:1:5,T:1,D:5,F:7,^114m)+
EFC translation: 7-bit MSB comp

RC5x

UEI protocol: 00F2
IRP notation: {36k,msb,889}<1,-1|-1,1>(1:1,~S:1:6,T:1,D:5,-4,S:6,F:6,^114m)+
EFC translation: NONE

The official (UEI) protocol executor for RC5x does not support EFC numbers. If you are creating an upgrade in KM or RM you should use OBC numbers, not EFC numbers. If you need the Hex Cmd for a KeyMove, you should use the functions sheet of KM or RM to compute it for you from the OBC and subdevice number.

In the functions sheet in KM you must put the subdevice number in the byte2 column, which KM calls "unit code".

What we call "Device" is really the "System". What we call Subdevice is really the "Command". What we call "OBC" is really the "Data". If you are using ProntoEdit to create the RC5 signals directly, that GUI uses that correct (System, Command and Data) Philips terminology.

RC5-?-??

Just ignore this decode. It is almost certainly spurious. In case there is a new protocol I don't know about yet in the family with RC5 and StreamZap, it will decode in this form producing data to help me understand that protocol.

RC6

UEI protocol: 0058
IRP notation: {36k,444,msb}<-1,1|1,-1>(6,-2,1:1,0:3,<-2,2|2,-2>(T:1),D:8,F:8,^107m)+
EFC translation: MSB

RC6 is the name used for the first member of the RC6 family of protocols. Technically this is RC6-0-16, but DecodeIr will always display that as simply "RC6"

RC6-6-20

IRP notation: {36k,444,msb}<-1,1|1,-1>(6,-2,1:1,6:3,<-2,2|2,-2>(T:1),D:8,S:4,F:8,-???)+
EFC translation: MSB

This protocol is commonly used in Sky and Sky+ remotes. As of version 8.31, KM does not have built-in support for this protocol, but there are KM format upgrade files available for Sky and Sky+ (built by an expert who isn't limited to KM's built-in protocols). RM has built-in support for RC6-M-20n protocol, which can be used to make Sky and Sky+ upgrades (or any other RC6-6-20 upgrades as long as the T bit is the same for all learned signals, as it is with Sky). To use RC6-M-20n for RC6-6-20, you must leave the M field in RM's setup sheet with its default value of 6, and you must set or leave the T field (if present) to the value shown in all the decodes (which I assume will be 0).

RC6-?-??

IRP notation: {36k,444,msb}<-1,1|1,-1>(6,-2,1:1,M:3,<-2,2|2,-2>(T:1),???:??)+

This is the generic form for a decode of protocols in the RC6 family. DecodeIr uses this form for all RC6 decodes, except RC6-0-16 which is displayed as simply "RC6", RC6-6-24 which is displayed as "Replay" and some RC6-6-32 which display as MCE.

The first ? in the protocol name is the M value in the RC6 spec. The ending ?? represents the number of data bits in the signal.

RCA and RCA(Old)

UEI protocols: 00AF (RCA), 002D(RCA(Old)) and 0114 (RCA Combo)
IRP notation for RCA: {58k,460,msb}<1,-2|1,-4>(8,-8,D:4,F:8,~D:4,~F:8,1,-16)+
IRP notation for RCA(Old): {58k,460,msb}<1,-2|1,-4>(32,(8,-8,D:4,F:8,~D:4,~F:8,2,-16)+)
EFC translation: MSB

These are two very similar forms of RCA protocol which differ only in that RCA(Old) has an extended lead-in and a double-length ON pulse before the lead-out. They are so similar that most RCA devices will accept either. But some RCA devices only accept the one that really matches their own remote. In versions of DecodeIR prior to v2.40, RCA(Old) was decoded as a frame of RCA{1} followed usually by a frame of RCA. The second frame now no longer appears, so the protocol has been renamed to correspond to that used in KM and RM.

RCA-38 and RCA-38(Old)

UEI protocol: not known
IRP notation for RCA-38: {38.7k,460,msb}<1,-2|1,-4>(8,-8,D:4,F:8,~D:4,~F:8,1,-16)+
IRP notation for RCA-38(Old): {38.7k,460,msb}<1,-2|1,-4>(32,(8,-8,D:4,F:8,~D:4,~F:8,2,-16)+)
EFC translation: MSB

These are recently discovered variants of the RCA protocol. They differ from RCA and RCA(Old) only in the frequency, which is 38.7kHz instead of the standard 58kHz.

RECS80

UEI protocol: 0045, 0068, 0090 or ???
IRP notation for 0045: {38k,158,msb}<1,-31|1,-47>(1:1,T:1,D:3,F:6,1,-45m)+
IRP notation for 0068: {33.3k,180,msb}<1,-31|1,-47>(1:1,T:1,D:3,F:6,1,^138m)+
EFC translation: 6-bit MSB comp

RECS80 is a family of related protocols with the same structure, but different timing. See also Velleman

These are moderately non robust protocols, so spurious decodes are possible.

The timing differences are not definitive enough for DecodeIr to identify which RECS80 version is which. Instead it displays the timing information in the "Misc" field of the output. That will be three numbers formatted as in this example: (157/5048/7572).

Using those three numbers and the frequency, you should be able to determine whether the signals fit the 0045 version, the 0068 version, the 0090 version or none of them. You should look at all the learned signals for your device together when doing that. A single device won't mix versions of RECS80, so any differences in frequency or timing between learns is due to the IR learning process, not due to any differences among the correct signals. You should find one RECS80 version that is a good enough fit for all signals of the device.

For 0045,

For 0068,

For 0090,

You may find decodes that don't quite fit either. If it almost fits, it may be worth testing to see if it works, but it's most unlikely to work if the second timing number is above the suggested max or the third timing number is below the suggested min. For example, I found a decode with frequency 41879 and timing numbers (132,5092,7652). The three timing numbers are perfect for protocol 0045, but the frequency is quite wrong. I have no device to test with, but my guess is that it would work anyway. For protocol 0068, the third number 7652 is below the minimum of 7700 making it quite unlikely to work. I found a different device with frequency 33333 and timing (450,5770,8656). For 0068 all but the first number are perfect and I would be quite surprised if it didn't work. For 0045 the second number 5770 is too high for the max of 5500, so it's unlikely to work.

The decodes for RECS80 all report EFCs for protocol 0045. These are not correct EFCs if you select a protocol other than 0045, so it is better to use OBC numbers when creating a JP1 upgrade based on these decodes.

Replay

UEI protocol: 0092
IRP notation: {36k,444,msb}<-1,1|1,-1>(6,-2,1:1,6:3,<-2,2|2,-2>(T:1),D:8,S:8,F:8,-???)+
EFC translation: MSB

Replay is a member of the RC6 family. Technically it is RC6-6-24, but DecodeIr will always display the name as "Replay". ProntoEdit calls this protocol "RC6 mode 6A" and KM has it under the alternate name "RC-6a" as well as its primary name "Replay". RM has it under the alternate name "RC6-M-24n" as well as its primary name "Replay".

DecodeIr's Subdevice field in is called "unit" in KM

In ProntoEdit, DecodeIr's "Device" is called "Customer Code"; DecodeIr's "Subdevice" is called "System"; and DecodeIr's "OBC" is called "Command".

Samsung20

IRP notation: {38.4k,564}<1,-1|1,-3>(8,-8,D:6,S:6,F:8,1,^???)+
EFC translation: LSB

This is a moderately robust protocol, but spurious decodes are still possible.

Samsung36

UEI protocol: 01B5
IRP notation: {38k,500}<1,-1|1,-3>(9,-9,D:8,S:8,1,-9,E:4,F:8,-68u,~F:8,1,-118)+
EFC translation: LSB

Sampo

IRP notation: {38.4k, 833}<1,-1|1,-3>(4,-4,D:6,F:6,S:6,~F:6,1,-39)+
EFC translation: Not available in this version of DecodeIr

This is a moderately robust protocol, but spurious decodes are still possible.

ScAtl-6

UEI protocol: 0078
IRP notation: {57.6k,846}<1,-1|1,-3>(4,-4,D:6,F:6,~D:6,~F:6,1,-40)+
EFC translation: 6-bit LSB comp

ScAtl-6 is distinguished from Emerson only by frequency. So if you are using a learning system that doesn't record the frequency accurately, then DecodeIr can't accurately select between Emerson and ScAtl-6.

In KM, this protocol is named "Scientific Atlanta". Most Scientific Atlanta cable tuners use Panasonic_Old protocol, not this protocol.

Sejin-M-38 and Sejin-M-56

UEI protocol: 0161
IRP notation for Sejin-M-38: {38.8k,310,msb}<-1|1>(<8:4|4:4|2:4|1:4>(3,3:2,Dx:8,Fx:8,Fy:8,E:4,C:4,-L))+
IRP notation for Sejin-M-56: {56.3k,310,msb}<-1|1>(<8:4|4:4|2:4|1:4>(3,3:2,Dx:8,Fx:8,Fy:8,E:4,C:4,-L))+
In both cases E is a checksum seed (0 in all known examples) and C is a checksum given by
C = Dx:4 + Dx:4:4 + Fx:4 + Fx:4:4 + Fy:4 + Fy:4:4 + E.
EFC translation: For Sejin-1, MSB. For Sejin-2, EFC translation not available.

The parameter M is either 1 or 2. It distinguishes two styles of this protocol that have different purposes and very different lead-out times L. The 8-bit parameter Dx is a signed integer. If Dx > 0 then the style is Sejin-1, used for normal buttons of a remote control. If Dx < 0 then the style is Sejin-2, used for signals of an associated 2- or 3-button pointing device. E is a checksum seed, E=0 in the only known examples. The checksum formula reflects that in the UEI executor, so is presumed correct.

The protocol parameters Dx, Fx, Fy translate into device parameters in different ways corresponding to the different uses of the protocol. In Sejin-1 the device parameters are a Device Code, a SubDevice code and an OBC as is common for many protocols. Sejin-2 has two sub-styles. One corresponds to the displacement of a cursor or other pointer with device parameters (X, Y) that give the horizontal and vertical components of the displacement (and which can be positive or negative). The other signals Button Up or Button Down for any of the three buttons of the pointing device. The Misc field of the DecodeIR output displays these device parameters for the Sejin-2 signals. The relationship between these and the protocol parameters is beyond the scope of this document. The Misc field also displays an RMOBC value for Sejin-2 signals, which is an artificial OBC value that can be used as input to RemoteMaster to create the signal concerned.

The protocol parameters for Sejin-1 include a bit that marks the end frame of a repeat sequence. DecodeIR v2.37 and later check this and will report in the Misc field if the end frame is missing. This will normally be due to the key still being held when the learning process ends, so that the end frame gets omitted from the learned signal. For Sejin-2 signals that represent button operations the signal does not repeat. A single frame is sent on button down, a different frame is sent once on button up. Both frames can be detected and distinguished by DecodeIR v2.37 and later but the button up frame will not normally be present in a learned signal.

Sharp, Sharp{1} and Sharp{2}

IRP notation: {38k,264}<1,-3|1,-7>(D:5,F:8,1:2,1,-165,D:5,~F:8,2:2,1,-165)+
EFC translation: LSB

A Sharp signal has two halves, either one of which is enough to fully decode the information. A significant fraction of Sharp learned signals contain just one half or have the halves separated so that DecodeIr can't process them together. When one half is seen separate from the other, DecodeIr will name the protocol Sharp{1} or Sharp{2} depending on which half is decoded. Sharp, Sharp{1} and Sharp{2} all represent the same protocol when they are correct. But only Sharp is robust. A Sharp{1} or Sharp{2} decode might be spurious.

SharpDVD

UEI protocol: 00F8
IRP notation: {38k,400}<1,-1|1,-3>(8,-4,170:8,90:8,15:4,D:4,S:8,F:8,E:4,C:4,1,-48)+ {E=1,C=D^S:4:0^S:4:4^F:4:0^F:4:4^E:4}
EFC translation: LSB comp

SharpDVD is the member of the Kaseikyo family with OEM_code1=170 and OEM_code2=90.

SIM2

IRP notation: {38.8k,400}<3,-3|3,-7>(6,-7,D:8,F:8,3,-60m)

Solidtek16

IRP notation: {38k}<-624,468|468-624>(1820,-590,0:1,D:4,F:7,S:1,C:4,1:1,-???)

This is a KeyBoard protocol. The make/break bit is decoded into the subdevice field.

Solidtek20

IRP notation: {38k}<-624,468|468-624>(1820,-590,0:1,D:4,S:6,F:6,C:4,1:1,-???)

This is a mouse protocol. The button press info is included in the Device field. The horizontal motion is in the Subdevice field, and the vertical motion is in the OBC field.

The decode interface does not support returning negative Subdevice or OBC. So negative motions are represented by adding 64 to them. The numbers 1 to 31 represent positive motion. The numbers 32 to 63 are each 64 larger than the true negative motion, so 63 represents -1 and 32 represents -32.

Somfy

IRP notation: {35.7k}<308,-881|669,-520>(2072,-484,F:2,D:3,C:4,-2300)+
C is reported as SubDevice. It is probably a check nibble {C = F*4 + D + 3}.
F = 1 for UP or 2 for DOWN.
D = 1, 2 or 3 for the three observed devices, or D = 0 to control all devices together.

Sony8

IRP notation: {40k,600}<1,-1|2,-1>(4,-1,F:8,^22200)
EFC translation: LSB.

Sony12

UEI protocol: 00CA
IRP notation: {40k,600}<1,-1|2,-1>(4,-1,F:7,D:5,^45m)+
EFC translation: LSB.

Sony15

UEI protocol: 00CA
IRP notation: {40k,600}<1,-1|2,-1>(4,-1,F:7,D:8,^45m)+
EFC translation: LSB.

Sony20

UEI protocol: 00DE
IRP notation: {40k,600}<1,-1|2,-1>(4,-1,F:7,D:5,S:8,^45m)+
EFC translation: LSB.

StreamZap

IRP notation: {36k,msb,889}<1,-1|-1,1>(1:1,~F:1:6,T:1,D:6,F:6,^114m)+
DecodeIR V2.43 decodes this as RC5-7F
EFC translation: 6-bit MSB comp

StreamZap-57

IRP notation: {57k,msb,889}<1,-1|-1,1>(1:1,~F:1:6,T:1,D:6,F:6,^114m)+
DecodeIR V2.43 decodes this as RC5-7F-57
EFC translation: 6-bit MSB comp

Sunfire

IRP notation: (38k,560,msb)<1,-1|3,-1>(16,-8, D:4,F:8,~D:4,~F:8 -32)+
EFC translation: Not available in this version of DecodeIr

TDC-38 and TDC-56

IRP notation for TDC-38: {38k,315,msb}<-1,1|1,-1>(1:1,D:5,S:5,F:7,-89m)+
IRP notation for TDC-56: {56.3k,213,msb}<-1,1|1,-1>(1:1,D:5,S:5,F:7,-89m)+
EFC translation: 7-bit MSB.

There are two variants of this protocol, with different frequencies but with the same number of carrier cycles in each burst, which makes the duration of a burst also differ. TDC-38 has a 38kHz carrier and is used by Danish TDC IPTV. TDC-56 has a 56.3kHz carrier and is used by Italian ALICE Home TV box. These implementations effectively use a 6-bit OBC as bit 0 of F is always the complement of bit 1, but there are other implementations which do not follow that pattern.

Teac-K

UEI protocol: 00BB
IRP notation: {37k,432}<1,-1|1,-3>(8,-4,67:8,83:8,X:4,D:4,S:8,F:8,T:8,1,-100,(8,-8,1,-100)+ {T=D+S:4:0+S:4:4+F:4:0+F:4:4}
EFC translation: LSB comp, two parts

Teac-K is the member of the Kaseikyo family with OEM_code1=67 and OEM_code2=83.

Teac-K uses different repeat rules and a different check byte than other Kaseikyo protocols.

00BB requires 2-byte hex commands. DecodeIr returns both hex cmd bytes through the interface that usually means one or the other (for mini combos) but in this case it means both.

This protocol signals repeats by the use of dittos.

Thomson

UEI protocol: 004B
IRP notation: {33k,500}<1,-4|1,-9>(D:4,T:1,D:1:5,F:6,1,^80m)+
EFC translation: 6-bit LSB comp, or that prepended with extra device bit.

This is not a robust protocol, so spurious decodes are likely.

DecodeIR2.42 deprecates Thompson (5 bits of device, and 6 bits of function) and reports these signals as Thompson7 (4 bits of device and 7 bits of function).

Thomson includes a toggle bit so using learned signals will have operational problems. You should use KeyMoves or Upgrades based on the decoded values, rather than continue to use the learned signals.

There are two different variants of UEI protocol 004B which have different EFC numbering. The decode lists both possible EFCs so you could experiment to discover which is right for your model. But, if you are creating an upgrade (rather than just KeyMoves) it is better to use RM and use the OBC numbers from the decode (which are stable across models of JP1 remote). As of version 8.31, KM does not have support for Thomson protocol, so if you must make an upgrade in KM you need to use pid:004B. For the URC-8040 and 8060 the second decoded EFC should be right and the OBC values in KM should be wrong. For most (maybe all) other models, the first decoded EFC should be right and KM's default EFC to OBC translation should also be right.

Thomson7

UEI protocol: 004B
IRP notation: {33k,500}<1,-4|1,-9>(D:4,T:1,F:7,1,^80m)+
EFC translation: 7-bit LSB comp

DecodeIR2.42 deprecates Thompson (5 bits of device, and 6 bits of function) and reports these signals as Thompson7 (4 bits of device and 7 bits of function).

Tivo

IRP notation: {38.4k,564}<1,-1|1,-3>(16,-8,133:8,48:8,F:8,U:4,~F:4:4,1,-78,(16,-4,1,-173)*)
EFC translation: LSB comp

Velleman

IRP notation: {38k,msb}<700,-5060|700,-7590>(1:1,T:1,D:3,F:6,1,-55m)+
EFC translation: 6-bit MSB comp

Very similar to RECS80-0045, except on duration is longer

Velodyne

IRP notation: {38k,136,msb}<210,-760>(<0:1|0:1,-1|0:1,-2|0:1,-3|0:1,-4|0:1,-5|0:1,-6|0:1,-7|0:1,-8|0:1,-9|0:1,-10|0:1,-11|0:1,-12|0:1,-13|0:1,-14|0:1,-15>(S:4:4,C1:4,S:4,15:4,D:4,0:4,F:8,210u,-79m,S:4:4,C2:4,S:4,15:4,D:4,8:4,F:8,210u,-79m)+){C1=-(8+S+S::4+15+D+0+F+F::4),C2=-(8+S+S::4+15+D+8+F+F::4))
Velodyne is a close relative of XMP.

Viewstar

UEI protocol: 0021
IRP notation: {50.5k,337}<1,-8|1,-5>(F:5,1,-17)+
EFC translation: 5-bit LSB comp

This is not a robust protocol, so spurious decodes are likely.

X10 and X10.n

UEI protocol: 003F (X10.n), 01DF (X10)
IRP notation for X10: {40.8k,565}<2,-12|7,-7>(7,-7,F:5,~F:5,21,-7)+
IRP notation for X10.n: {40.8k,565}<2,-12|7,-7>(F:5,N:-4,21,-7,(7,-7,F:5,~F:5,21,-7)+)
EFC translation: LSB of 2*OBC+1

These are two variants of the same Home Automation protocol. They differ in that X10.n has a distinctive start frame that carries a sequence number, the n of the protocol name, in addition to the OBC. The repeat frames, and all frames of the X10 version, only carry the OBC. The value of n runs from 0 to 15 (or some lower value) and then restarts again at 0. It is incremented on each successive keypress. A valid X10.n signal must have at least one repeat frame. If this is missing then the Misc column shows "invalid signal".

RemoteMaster has a single protocol, named X10 with PID 003F, that sends X10.n signals. This is the same as the UEI protocol with that PID. There is no control over the value of n, this is handled automatically by the remote. The newer UEI protocol, with PID 01DF, sends X10 signals.

XMP, XMP-1 and XMP-2

UEI protocol: 016C
IRP notation (without final frame): {38k,136,msb}<210,-760>(<0:1|0:1,-1|0:1,-2|0:1,-3|0:1,-4|0:1,-5|0:1,-6|0:1,-7|0:1,-8|0:1,-9|0:1,-10|0:1,-11|0:1,-12|0:1,-13|0:1,-14|0:1,-15>(T=0,(S:4:4,C1:4,S:4,15:4,OEM:8,D:8,210u,-13.8m,S:4:4,C2:4,T:4,S:4,F:16,210u,-80.4m,T=8)+)){C1=-(15+S+S::4+15+OEM+OEM::4+D+D::4),C2=-(15+S+S:4+T+F+F::4+F::8+F::12)}
IRP notation (with final frame):{38k,136,msb}<210,-760>(<0:1|0:1,-1|0:1,-2|0:1,-3|0:1,-4|0:1,-5|0:1,-6|0:1,-7|0:1,-8|0:1,-9|0:1,-10|0:1,-11|0:1,-12|0:1,-13|0:1,-14|0:1,-15>(T=0,((S:4:4,C1:4,S:4,15:4,OEM:8,D:8,210u,-13.8m,S:4:4,C2:4,T:4,S:4,F:16,210u,[-80.4m][-80.4m][-13.8m],T=8)+,T=9)2)){C1=-(S+S::4+15+OEM+OEM::4+D+D::4),C2=-(S+S:4+T+F+F::4+F::8+F::12)}
XMP uses one burst pair to encode numbers 0 to 15, with an on duration of 210uS, and off duration of 760uS + n*136uS where n takes on values of 0 to 15. The checksum nibble is the complement of 15 plus the sum of the other 7 nibbles, mod 16

The Device code is D, the SubDevice code is S and there are two OBC values. OBC1 is the high byte of F, OBC2 is the low byte of F. The OEM code is normally 0x44 and is reported in the Misc field only if it has a different value. The XMP-1 protocol is XMP with OBC2 = 0. The OBC field in DecodeIR then shows OBC1. The XMP-2 protocol is XMP with OBC1 = 0. The OBC field in DecodeIR then shows OBC2.

This protocol has a 4-bit toggle T that is 0 for the first frame and normally 8 for all repeat frames. There is, however, a variant in which a further frame with T=9 is sent after the button is released, separated from the preceding frame by the short leadout of 13.8m that is used between two half-frames rather than the long lead-out of 80.4m used at the end of all other frames. When this frame is detected then the Misc field displays "With Final Frame". For this to be shown in a learned signal, the button must be released before the learning process times out, so a short button press is needed.

These are problem decodes because JP1 remotes don't typically learn these signals accurately enough for a correct decode. NG Prontos also do a rotten job of learning these signals. Older Prontos seem to do fairly well. DecodeIR v2.40 includes algorithms that attempt to reconstruct a valid XMP signal from a corrupt learn, but it is impossible to correct all learning errors and there can be no certainty that a reconstruction is actually correct.

In a correctly learned or fully reconstructed signal there will be an "XMP", "XMP-1" or "XMP-2" decode with device, subdevice and OBC values that can be used with RemoteMaster or any similar program to regenerate a clean signal. The Misc field shows which algorithms, if any, have been applied, as a list in brackets after any decode data in this field. There are notes below on the reliability of the various algorithms. When the protocol shows as (unqualified) XMP, both OBC values are non-zero. The OBC and Hex fields show OBC1. The corresponding values for OBC2 are shown in the Misc field.

The learned signal itself will certainly not be valid if any reconstruction algorithms have been applied and it may not be so even if it has been decoded without reconstruction. The possible algorithm indicators in the Misc field are as follows:

If a learned signal is good enough to be recognised as XMP but not good enough to be fully reconstructed, the protocol will display with a name of the form

XMP:136.218-0F0F441A0A800F00

In IR.exe you'll need to widen the Protocol column to see the whole thing. This represents intermediate data from an unsuccessful attempt to decode a XMP signal. The number in the position where the 136 is in this example represents the time scale. A number (like this example) that is near 137 is reasonable. A number much further from 137 indicates a more serious learning or decoding problem. The number in the position where the .218 is in this example (it is not part of the 136) represents the level of inconsistency in the individual hex digit decodes. A value greater than .100 means the hex digits aren't very reliable.

The hex string, where the 0F0F441A0A800F00 is, is the decoded data. At least one digit is almost certainly wrong or the whole decode wouldn't be displayed in this form. With a JP1 learning remote, the most common errors are that a digit is actually missing, in which case the string will have fewer than 16 hex digits, or that two or more digits which are decoded the same are actually different, so some of them are correct and some are one value higher or lower. Although the reconstruction algorithms attempt to correct these types of errors, it is not always possible. In this example I happen to know the correct signal. One of the three F's is really an E and one of the two A's is really a 9. The correct string is 0E0F441A09800F00.

Almost all examples we've seen start with "0E0F441A0" or "060F44120". But we've also seen upgrades from UEI for "0D1F441A0" and "0C2F441A0" and "0B3F441A0". The last 4 digits of the whole 16 digit string (if they are correct) represent the Hex command needed to reproduce the signal in a JP1 upgrade or KeyMove. DecodeIR shows them as two 8-bit OBC values, as described with the IRP notation above.

XX

Documentation not written yet.

Zaptor

UEI protocol: unknown
IRP notation: {36k,330,msb}<-1,1|1,-1>[T=0] [T=0] [T=1] (8,-6,2,D:8,T:1,S:7,F:8,E:4,C:4,-74m)+ {C = (D:4+D:4:4+S:4+S:3:4+8*T+F:4+F:4:4+E)&15}
where T=0 for all frames except the last, T=1 for last frame, E is a checksum seed. There is a 56KHz variant.
EFC translation: MSB

A protocol so far seen only in the Motorola Zaptor. See also Amino

Zenith

UEI protocol: 0022 IRP notation: {40k,520,msb}<1,-10|1,-1,1,-8>(S:1,<1:2|2:2>(F:D),-90m)+
Before Version 2.43, this document has shown the IRP notation as {40k,520,msb}<1,-1,1,-8|1,-10>(S:1,<1:2|2:2>(F:D),-90m)+
EFC translation: MSB

An unusual protocol, in that the number of bits in the function code is variable. It is represented in DecodeIR as the device code. There are also two lead-in styles, decoded as subdevice values 0 and 1. Style 1 aka "double-start" is usually used in TV's, other appliances use 0 aka "single start". If the device code is >8 then the bytes given in the Misc field as E = ... follow the OBC in the function code value.

?1-??-??-??

An experimental decode I added based on the thread at JP1-forum"Unknown Protocol"

 

================================================ FILE: examples/Convert_Old_Nec/Convert_Old_Nec.ino ================================================ /* Copyright (c) 2014 NicoHood See the readme for credit to other people. IRL Convert Old Nec Converts Nec Signals from the old format that Ken used with his library to the new bit order. Add your codes to the array, upload and open the Serial monitor. */ void setup() { // Serial setup while (!Serial); Serial.begin(115200); Serial.println(F("Startup")); // add your old code here uint32_t oldcode[] = { 0x20DF0FF0, 0x20DF9E61, 0x20DFD02F, 0x20DFA956, // ... }; // go thorugh all entries for (int i = 0; i < (sizeof(oldcode) / sizeof(uint32_t)); i++) { uint32_t newcode = 0; uint16_t command = 0; uint16_t address = 0; // print old code Serial.print(oldcode[i], HEX); Serial.print(F(" --> 0x")); // LSB to MSB for (uint8_t j = 0; j < 32; j++) { newcode <<= 1; newcode |= (oldcode[i] & 0x00000001); oldcode[i] >>= 1; } // new code (address + command) address = newcode & 0xFFFF; command = (newcode >> 16); // print new code //Serial.print(newcode, HEX); Serial.print(address, HEX); Serial.print(F(", 0x")); Serial.println(command, HEX); } } void loop() { // empty } ================================================ FILE: examples/NecAPI/NecAPI.ino ================================================ /* Copyright (c) 2014-2017 NicoHood See the readme for credit to other people. IRL NecAPI Receives IR NEC signals and decodes them with the API for better processing. The following pins are usable for PinInterrupt or PinChangeInterrupt*: Arduino Uno/Nano/Mini: All pins are usable Arduino Mega: 10, 11, 12, 13, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69) Arduino Leonardo/Micro: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI) HoodLoader2: All (broken out 1-7) pins are usable Attiny 24/44/84: All pins are usable Attiny 25/45/85: All pins are usable Attiny 13: All pins are usable Attiny 441/841: All pins are usable ATmega644P/ATmega1284P: All pins are usable PinChangeInterrupts* requires a special library which can be downloaded here: https://github.com/NicoHood/PinChangeInterrupt */ // Use HID Project for more keys and options #include "HID-Project.h" #define USBKEYBOARD BootKeyboard #define USBMOUSE BootMouse // include PinChangeInterrupt library* BEFORE IRLremote to acces more pins if needed //#include "PinChangeInterrupt.h" #include "IRLremote.h" // Choose a valid PinInterrupt or PinChangeInterrupt* pin of your Arduino board #define pinIR 2 using namespace IRL_Protek_Remote; // Choose the IR protocol of your remote. See the other example for this. void NecEvent(void); CNecAPI IRLremote; #define pinLed LED_BUILTIN void setup() { // Start serial debug output while (!Serial); Serial.begin(115200); Serial.println(F("Startup")); // Set LED to output pinMode(pinLed, OUTPUT); // Start reading the remote. PinInterrupt or PinChangeInterrupt* will automatically be selected if (!IRLremote.begin(pinIR)) Serial.println(F("You did not choose a valid pin.")); // Start HID devices USBKEYBOARD.begin(); USBMOUSE.begin(); } void loop() { // Get the new data from the remote // Always call this to check for timeouts IRLremote.read(); } void NecEvent(void) { // Get the current button (re)press count auto pressCount = IRLremote.pressCount(); // Tells how many times the button was pressed including the first time. // Add a debounce if the button is held down, only accept every xth key. // 1, 2, 4, 8, 16, 32, 64, 128 works best auto holdDebounce = IRLremote.holdCount(4); auto holdCount = IRLremote.holdCount(0); // Button holding/pressing multiple times timed out. // Use this to differentiate between 1,2,3,...,n button presses. // or release holding keys. auto pressTimeout = IRLremote.pressTimeout(); auto releaseButton = IRLremote.releaseButton(); // Get the actual command we are processing auto command = IRLremote.command(); // Print data to the serial for debugging // Serial.println(F("----------")); // Serial.print(F("Key: ")); // Serial.println(command); // Serial.print(F("Keypresses: ")); // Serial.println(pressCount); // Serial.print(F("holdDebounce: ")); // Serial.println(holdDebounce); // Serial.print(F("pressTimeout: ")); // Serial.println(pressTimeout); // Serial.println(); // Differenciate between 4 modes enum IRModes : uint8_t { PC_Mode, Mouse_Mode, Led_Mode, Kodi_Mode, }; static IRModes IRMode = PC_Mode; // Press HID keys with a protek remote switch (command) { // Red mode case IRL_KEYCODE_RED: if (holdCount == 1) { IRMode = PC_Mode; } break; // Green mode case IRL_KEYCODE_GREEN: if (holdCount == 1) { IRMode = Mouse_Mode; } break; // Yellow mode case IRL_KEYCODE_YELLOW: if (holdCount == 1) { // Not implemented IRMode = Led_Mode; } break; // Blue mode case IRL_KEYCODE_BLUE: if (holdCount == 1) { // Kodi remote // http://kodi.wiki/view/Keyboard_controls // https://github.com/xbmc/xbmc/blob/master/system/keymaps/keyboard.xml IRMode = Kodi_Mode; } break; // Shutdown menu case IRL_KEYCODE_POWER: if (IRMode == Kodi_Mode) { // Hold the button some time (around 3 sec) to trigger shutdown button if (holdDebounce == 4) { USBKEYBOARD.press('s'); USBKEYBOARD.releaseAll(); } } else { // Hold the button some time (around 3 sec) to trigger shutdown button if (pressCount == 1 && holdDebounce == 4) { if (IRMode == PC_Mode) { USBKEYBOARD.press(KEY_POWER); USBKEYBOARD.releaseAll(); } IRLremote.reset(); } // For two short keypress just exit the current program else if (pressCount == 2 && holdDebounce == 4) { IRLremote.reset(); } } break; // Global system mute case IRL_KEYCODE_MUTE: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press(KEY_F8); USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode) { USBKEYBOARD.press(KEY_VOLUME_MUTE); USBKEYBOARD.releaseAll(); } } break; // Fullscreen/Window mode case IRL_KEYCODE_SCREEN: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press('\\'); USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode || IRMode == Led_Mode) { // Turn off screens // xset dpms force off USBKEYBOARD.write(CONSUMER_SLEEP); USBKEYBOARD.releaseAll(); } } break; // Live TV channels window case IRL_KEYCODE_SATELLITE: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press('h'); USBKEYBOARD.releaseAll(); } } break; // Open videos case IRL_KEYCODE_TV_RADIO: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press(KEY_LEFT_CTRL); USBKEYBOARD.press('e'); USBKEYBOARD.releaseAll(); } } break; // Open music case IRL_KEYCODE_TV_MUSIC: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press(KEY_LEFT_CTRL); USBKEYBOARD.press('m'); USBKEYBOARD.releaseAll(); } } break; // 1 case IRL_KEYCODE_1: if (holdDebounce == 1) { USBKEYBOARD.press('1'); USBKEYBOARD.releaseAll(); } break; // Letters are used to qickly jump between movies in the library // A, B, C, 2 case IRL_KEYCODE_2: if (pressTimeout == 1) { USBKEYBOARD.press('A'); } else if (pressTimeout == 2) { USBKEYBOARD.press('B'); } else if (pressTimeout == 3) { USBKEYBOARD.press('C'); } else if (pressTimeout == 4) { USBKEYBOARD.press('2'); } USBKEYBOARD.releaseAll(); break; // D, E, F, 3 case IRL_KEYCODE_3: if (pressTimeout == 1) { USBKEYBOARD.press('D'); } else if (pressTimeout == 2) { USBKEYBOARD.press('E'); } else if (pressTimeout == 3) { USBKEYBOARD.press('F'); } else if (pressTimeout == 4) { USBKEYBOARD.press('3'); } USBKEYBOARD.releaseAll(); break; // G, H, I, 4 case IRL_KEYCODE_4: if (pressTimeout == 1) { USBKEYBOARD.press('G'); } else if (pressTimeout == 2) { USBKEYBOARD.press('H'); } else if (pressTimeout == 3) { USBKEYBOARD.press('I'); } else if (pressTimeout == 4) { USBKEYBOARD.press('4'); } USBKEYBOARD.releaseAll(); break; // J, K, L, 5 case IRL_KEYCODE_5: if (pressTimeout == 1) { USBKEYBOARD.press('J'); } else if (pressTimeout == 2) { USBKEYBOARD.press('K'); } else if (pressTimeout == 3) { USBKEYBOARD.press('L'); } else if (pressTimeout == 4) { USBKEYBOARD.press('5'); } USBKEYBOARD.releaseAll(); break; // M, N, O, 6 case IRL_KEYCODE_6: if (pressTimeout == 1) { USBKEYBOARD.press('M'); } else if (pressTimeout == 2) { USBKEYBOARD.press('N'); } else if (pressTimeout == 3) { USBKEYBOARD.press('O'); } else if (pressTimeout == 4) { USBKEYBOARD.press('6'); } USBKEYBOARD.releaseAll(); break; // P, Q, R, S, 7 case IRL_KEYCODE_7: if (pressTimeout == 1) { USBKEYBOARD.press('P'); } else if (pressTimeout == 2) { USBKEYBOARD.press('Q'); } else if (pressTimeout == 3) { USBKEYBOARD.press('R'); } else if (pressTimeout == 4) { USBKEYBOARD.press('S'); } else if (pressTimeout == 5) { USBKEYBOARD.press('7'); } USBKEYBOARD.releaseAll(); break; // T, U, V, 8 case IRL_KEYCODE_8: if (pressTimeout == 1) { USBKEYBOARD.press('T'); } else if (pressTimeout == 2) { USBKEYBOARD.press('U'); } else if (pressTimeout == 3) { USBKEYBOARD.press('V'); } else if (pressTimeout == 4) { USBKEYBOARD.press('8'); } USBKEYBOARD.releaseAll(); break; // W, X, Y, Z, 9 case IRL_KEYCODE_9: if (pressTimeout == 1) { USBKEYBOARD.press('W'); } else if (pressTimeout == 2) { USBKEYBOARD.press('X'); } else if (pressTimeout == 3) { USBKEYBOARD.press('Y'); } else if (pressTimeout == 4) { USBKEYBOARD.press('Z'); } else if (pressTimeout == 5) { USBKEYBOARD.press('9'); } USBKEYBOARD.releaseAll(); break; // Space, 0 case IRL_KEYCODE_0: if (pressTimeout == 1) { USBKEYBOARD.press(' '); } else if (pressTimeout == 2) { USBKEYBOARD.press('0'); } USBKEYBOARD.releaseAll(); break; case IRL_KEYCODE_BACK: if (holdDebounce == 1) { // Back if (IRMode == Kodi_Mode) { USBKEYBOARD.press(KEY_BACKSPACE); USBKEYBOARD.releaseAll(); } // Backspace else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(KEY_BACKSPACE); USBKEYBOARD.releaseAll(); } } break; case IRL_KEYCODE_FAVORITE: if (holdDebounce == 1) { // Mark as watched/unwatched if (IRMode == Kodi_Mode) { USBKEYBOARD.press('w'); USBKEYBOARD.releaseAll(); } // Delete else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(KEY_DELETE); USBKEYBOARD.releaseAll(); } } break; // Volume up case IRL_KEYCODE_VOL_UP: if (holdDebounce) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press('+'); // F10, = USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(KEY_VOLUME_UP); USBKEYBOARD.releaseAll(); } } break; // Volume down case IRL_KEYCODE_VOL_DOWN: if (holdDebounce) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press('-'); // F9 USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(KEY_VOLUME_DOWN); USBKEYBOARD.releaseAll(); } } break; // Live TV EPG/TV guide case IRL_KEYCODE_EPG: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press('e'); USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(KEY_TAB); USBKEYBOARD.releaseAll(); } } break; // Info case IRL_KEYCODE_INFO: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press('i'); USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(KEY_F1); USBKEYBOARD.releaseAll(); } } break; // Increase rating case IRL_KEYCODE_CHANNEL_UP: if (IRMode == Kodi_Mode || IRMode == PC_Mode) { // Decrease rating if (holdDebounce) { USBKEYBOARD.press(KEY_PAGE_UP); USBKEYBOARD.releaseAll(); } } else if (IRMode == Mouse_Mode) { // Scroll if (holdCount) { USBMOUSE.move(0, 0, min(holdCount, 10)); } } break; // Decrease rating case IRL_KEYCODE_CHANNEL_DOWN: if (IRMode == Kodi_Mode || IRMode == PC_Mode) { if (holdDebounce) { USBKEYBOARD.press(KEY_PAGE_DOWN); USBKEYBOARD.releaseAll(); } } else if (IRMode == Mouse_Mode) { // Scroll if (holdCount) { USBMOUSE.move(0, 0, -1 * min(holdCount, 10)); } } break; // Navigation case IRL_KEYCODE_RIGHT: if (IRMode == Kodi_Mode || IRMode == PC_Mode) { if (holdDebounce) { USBKEYBOARD.press(KEY_RIGHT_ARROW); USBKEYBOARD.releaseAll(); } } else if (IRMode == Mouse_Mode) { if (holdCount) { USBMOUSE.move(min(holdCount * holdCount, 127), 0); } } break; case IRL_KEYCODE_LEFT: if (IRMode == Kodi_Mode || IRMode == PC_Mode) { if (holdDebounce) { USBKEYBOARD.press(KEY_LEFT_ARROW); USBKEYBOARD.releaseAll(); } } else if (IRMode == Mouse_Mode) { if (holdCount) { USBMOUSE.move(-1 * min(holdCount * holdCount, 127), 0); } } break; case IRL_KEYCODE_UP: if (IRMode == Kodi_Mode || IRMode == PC_Mode) { if (holdDebounce) { USBKEYBOARD.press(KEY_UP_ARROW); USBKEYBOARD.releaseAll(); } } else if (IRMode == Mouse_Mode) { if (holdCount) { USBMOUSE.move(0, -1 * min(holdCount * holdCount, 127)); } } break; case IRL_KEYCODE_DOWN: if (IRMode == Kodi_Mode || IRMode == PC_Mode) { if (holdDebounce) { USBKEYBOARD.press(KEY_DOWN_ARROW); USBKEYBOARD.releaseAll(); } } else if (IRMode == Mouse_Mode) { if (holdCount) { USBMOUSE.move(0, min(holdCount * holdCount, 127)); } } break; // Enter menu, play/pause, general okay button case IRL_KEYCODE_OK: if (IRMode == Mouse_Mode) { if (holdDebounce == 1) { USBMOUSE.press(); } else if (releaseButton) { USBMOUSE.releaseAll(); } } else if (IRMode == Kodi_Mode || IRMode == PC_Mode) { if (holdDebounce == 1) { USBKEYBOARD.press(KEY_RETURN); USBKEYBOARD.releaseAll(); } } break; // Exit full screeen case IRL_KEYCODE_EXIT: if (holdDebounce == 1) { if (IRMode == Kodi_Mode || IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(KEY_ESC); USBKEYBOARD.releaseAll(); } } break; // Context menu/Playlist case IRL_KEYCODE_MENU: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press('c'); USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode) { USBKEYBOARD.press(KEY_MENU); USBKEYBOARD.releaseAll(); } else if (IRMode == Mouse_Mode) { USBMOUSE.press(MOUSE_RIGHT); } } else if (releaseButton) { USBMOUSE.releaseAll(); } break; // Show debug information case IRL_KEYCODE_I_II: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press(KEY_LEFT_CTRL); USBKEYBOARD.press('D'); USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode) { USBKEYBOARD.press(KEY_LEFT_GUI); USBKEYBOARD.press('p'); USBKEYBOARD.releaseAll(); } } break; // Teletext/Visualization settings case IRL_KEYCODE_TELETEXT: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press('v'); USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode) { // Linux is very picky here, 'e' needs to be released first. USBKEYBOARD.press(KEY_LEFT_GUI); USBKEYBOARD.write('e'); USBKEYBOARD.releaseAll(); } } break; // Next subtitle case IRL_KEYCODE_SUBTITLE: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press('l'); USBKEYBOARD.releaseAll(); } // Open Switchboard else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(KEY_LEFT_GUI); USBKEYBOARD.press(KEY_SPACE); USBKEYBOARD.releaseAll(); } } break; // Fullscreen play case IRL_KEYCODE_ADD: if (IRMode == Kodi_Mode) { if (holdDebounce == 1) { USBKEYBOARD.press(KEY_TAB); USBKEYBOARD.releaseAll(); } } // Switch application else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { // Hold down to keep the overview, press again to switch application if (holdDebounce == 1) { USBKEYBOARD.press(KEY_LEFT_ALT); USBKEYBOARD.write(KEY_TAB); } if (pressTimeout) { USBKEYBOARD.releaseAll(); } } break; // Play/Pause case IRL_KEYCODE_PLAY: case IRL_KEYCODE_PAUSE: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press(KEY_SPACE); USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(MEDIA_PLAY_PAUSE); USBKEYBOARD.releaseAll(); } } break; // Skip forward case IRL_KEYCODE_NEXT: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press('.'); USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(MEDIA_NEXT); USBKEYBOARD.releaseAll(); } } break; // Skip backward case IRL_KEYCODE_PREV: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press(','); USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(MEDIA_PREVIOUS); USBKEYBOARD.releaseAll(); } } break; // Stop case IRL_KEYCODE_STOP: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press('x'); USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(MEDIA_STOP); USBKEYBOARD.releaseAll(); } } break; // Change keyboard layout case IRL_KEYCODE_USB: if (IRMode == PC_Mode || IRMode == Mouse_Mode || IRMode == Kodi_Mode) { if (holdDebounce == 1) { USBKEYBOARD.press(KEY_LEFT_SHIFT); USBKEYBOARD.press(KEY_LEFT_ALT); USBKEYBOARD.press(KEY_SPACE); USBKEYBOARD.releaseAll(); } } break; // Screenshot case IRL_KEYCODE_REC: if (holdDebounce == 1) { if (IRMode == Kodi_Mode) { USBKEYBOARD.press(KEY_LEFT_CTRL); USBKEYBOARD.press('s'); USBKEYBOARD.releaseAll(); } else if (IRMode == PC_Mode || IRMode == Mouse_Mode) { USBKEYBOARD.press(KEY_PRINT); USBKEYBOARD.releaseAll(); } } break; // TODO case IRL_KEYCODE_LIVE: break; } } ================================================ FILE: examples/Receive/Receive.ino ================================================ /* Copyright (c) 2014-2015 NicoHood See the readme for credit to other people. IRL Receive Receives IR signals from different protocols and prints them to the Serial monitor. Choose your protocols that should be decoded. Remove the not used ones to save flash/ram/speed. You can choose a custom debounce time to not trigger a button two times in a row too fast. The following pins are usable for PinInterrupt or PinChangeInterrupt*: Arduino Uno/Nano/Mini: All pins are usable Arduino Mega: 10, 11, 12, 13, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69) Arduino Leonardo/Micro: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI) HoodLoader2: All (broken out 1-7) pins are usable Attiny 24/44/84: All pins are usable Attiny 25/45/85: All pins are usable Attiny 13: All pins are usable Attiny 441/841: All pins are usable ATmega644P/ATmega1284P: All pins are usable PinChangeInterrupts* requires a special library which can be downloaded here: https://github.com/NicoHood/PinChangeInterrupt */ // include PinChangeInterrupt library* BEFORE IRLremote to acces more pins if needed //#include "PinChangeInterrupt.h" #include "IRLremote.h" // Choose a valid PinInterrupt or PinChangeInterrupt* pin of your Arduino board #define pinIR 2 // Choose the IR protocol of your remote. See the other example for this. CNec IRLremote; //CPanasonic IRLremote; //CHashIR IRLremote; //#define IRLremote Sony12 #define pinLed LED_BUILTIN void setup() { // Start serial debug output while (!Serial); Serial.begin(115200); Serial.println(F("Startup")); // Set LED to output pinMode(pinLed, OUTPUT); // Start reading the remote. PinInterrupt or PinChangeInterrupt* will automatically be selected if (!IRLremote.begin(pinIR)) Serial.println(F("You did not choose a valid pin.")); } void loop() { // Check if we are currently receiving data //if (!IRLremote.receiving()) { // Run code that disables interrupts, such as some led strips //} // Check if new IR protocol data is available if (IRLremote.available()) { // Light Led digitalWrite(pinLed, HIGH); // Get the new data from the remote auto data = IRLremote.read(); // Print the protocol data Serial.print(F("Address: 0x")); Serial.println(data.address, HEX); Serial.print(F("Command: 0x")); Serial.println(data.command, HEX); Serial.println(); // Turn Led off after printing the data digitalWrite(pinLed, LOW); } } ================================================ FILE: examples/Receive_Raw/Receive_Raw.ino ================================================ /* Copyright (c) 2014-2015 NicoHood See the readme for credit to other people. IRL Receive_Raw Receives IR signals and prints raw values to the Serial. Please read the notes below, this example is used for developing/debugging only. The following pins are usable for PinInterrupt or PinChangeInterrupt*: Arduino Uno/Nano/Mini: 2, 3, All pins* are usable Arduino Mega: 2, 3, 18, 19, 20, 21, 10*, 11*, 12*, 13*, 50*, 51*, 52*, 53*, A8 (62)*, A9 (63)*, A10 (64)*, A11 (65)*, A12 (66)*, A13 (67)*, A14 (68)*, A15 (69)* Arduino Leonardo/Micro: 0, 1, 2, 3, 7, 8*, 9*, 10*, 11*, 14 (MISO)*, 15 (SCK)*, 16 (MOSI)* HoodLoader2: All (broken out 1-7*) pins are usable Attiny 24/44/84: 8, All pins* are usable Attiny 25/45/85: 2, All pins* are usable Attiny 13: All pins* are usable ATmega644P/ATmega1284P: 10, 11, All pins* are usable PinChangeInterrupts* requires a special library which can be downloaded here: https://github.com/NicoHood/PinChangeInterrupt */ // include PinChangeInterrupt library* BEFORE IRLremote to acces more pins if needed //#include "PinChangeInterrupt.h" #include "IRLremote.h" // choose a valid PinInterrupt or PinChangeInterrupt* pin of your Arduino board #define pinIR 2 CIRLremote IRLremote; #define pinLed LED_BUILTIN void setup() { // Start serial debug output while (!Serial); Serial.begin(115200); Serial.println(F("Startup")); // Set LED to output pinMode(pinLed, OUTPUT); // Start reading the remote. PinInterrupt or PinChangeInterrupt* will automatically be selected if (!IRLremote.begin(pinIR)) Serial.println(F("You did not choose a valid pin.")); } void loop() { if (IRLremote.available()) { // Light Led digitalWrite(pinLed, HIGH); // Important note: // Printing the values might cause you to miss // the first byte of the next sequence. // You might want to increase the buffer size // and the timeout as well in the settings. // You could also copy the buffer, call read() // and print afterwards if enough ram is available. // Do not use RawIR as "all day" protocol. // But you can use the HashIR protocol instead. const bool printRaw = true; if (printRaw) { // Print a mark Serial.println(F("==========")); // Go through the whole buffer and print values for (typeof(RawIR::countRawIR) i = 0; i < RawIR::countRawIR; i++) { Serial.print(i); Serial.print(F(": ")); Serial.println(RawIR::dataRawIR[i], DEC); } // Each buffer should end with the timeout value if (RawIR::countRawIR == RAWIR_BLOCKS) { Serial.println(F("Buffer was full!")); } Serial.println(); } // Get the new data from the remote IR_data_t data = IRLremote.read(); // Print the protocol data // For RawIR this is just an approximate calculation. // You should ignore addresses/length < 6 to avoid noise. Serial.print(F("Buffer length: ")); Serial.println(data.address, DEC); Serial.print(F("Command: 0x")); Serial.println(data.command, HEX); Serial.println(); // Turn Led off after printing the data digitalWrite(pinLed, LOW); } } ================================================ FILE: examples/Send_Button/Send_Button.ino ================================================ /* Copyright (c) 2014 NicoHood See the readme for credit to other people. IRL Send Button Sends IR signals on any pin. This uses Bitbanging. Press the button to send data. Turn interrupts off to get a better result if needed */ #include "IRLremote.h" // choose any pin to send IR signals const int pinSendIR = 3; // choose any pin to trigger IR sending const int pinButton = 8; void setup() { // setup for the button pinMode(pinButton, INPUT_PULLUP); } void loop() { if (!digitalRead(pinButton)) { // send the data, no pin setting to OUTPUT needed uint16_t address = 0x6361; uint32_t command = 0xFE01; IRLwrite(pinSendIR, address, command); // simple debounce delay(300); } } ================================================ FILE: examples/Send_Serial/Send_Serial.ino ================================================ /* Copyright (c) 2014 NicoHood See the readme for credit to other people. IRL Send Serial Sends IR signals on any pin. This uses Bitbanging. Write anything to the Serial port and hit enter to send Data. Turn interrupts off to get a better result if needed */ #include "IRLremote.h" // choose any pin to send IR signals const int pinSendIR = 3; void setup() { // start serial debug in/output Serial.begin(115200); Serial.println("Startup"); } void loop() { if (Serial.available()) { // discard all Serial bytes to avoid multiple sendings delay(10); while (Serial.available()) Serial.read(); // send the data, no pin setting to OUTPUT needed Serial.println("Sending..."); uint16_t address = 0x6361; uint32_t command = 0xFE01; IRLwrite(pinSendIR, address, command); } } ================================================ FILE: examples/Transceive/Transceive.ino ================================================ /* Copyright (c) 2014-2015 NicoHood See the readme for credit to other people. IRL Transceive Receives IR signals from different protocols and prints them to the Serial monitor. On receiving a specific IR input it will send another IR signal out. Choose your protocols that should be decoded. Remove the not used ones to save flash/ram/speed. You can choose a custom debounce time to not trigger a button two times in a row too fast. The following pins are usable for PinInterrupt or PinChangeInterrupt*: Arduino Uno/Nano/Mini: 2, 3, All pins* are usable Arduino Mega: 2, 3, 18, 19, 20, 21, 10*, 11*, 12*, 13*, 50*, 51*, 52*, 53*, A8 (62)*, A9 (63)*, A10 (64)*, A11 (65)*, A12 (66)*, A13 (67)*, A14 (68)*, A15 (69)* Arduino Leonardo/Micro: 0, 1, 2, 3, 7, 8*, 9*, 10*, 11*, 14 (MISO)*, 15 (SCK)*, 16 (MOSI)* HoodLoader2: All (broken out 1-7*) pins are usable Attiny 24/44/84: 8, All pins* are usable Attiny 25/45/85: 2, All pins* are usable ATmega644P/ATmega1284P: 10, 11, All pins* are usable *: PinChangeInterrupts requires a special library which can be downloaded here: https://github.com/NicoHood/PinChangeInterrupt */ // include PinChangeInterrupt library* BEFORE IRLremote to acces more pins if needed //#include "PinChangeInterrupt.h" #include "IRLremote.h" // choose a valid PinInterrupt or PinChangeInterrupt* pin of your Arduino board #define pinIR 2 #define pinSendIR 3 #define IRL_DEBOUCE 300 CIRLremote IRLremote; #define pinLed LED_BUILTIN void setup() { // start serial debug output Serial.begin(115200); Serial.println(F("Startup")); // set LED to output pinMode(pinLed, OUTPUT); // start reading the remote. PinInterrupt or PinChangeInterrupt* will automatically be selected if (!IRLremote.begin(pinIR)) Serial.println(F("You did not choose a valid pin.")); } void loop() { if (IRLremote.available()) { // light Led digitalWrite(pinLed, HIGH); // get the new data from the remote IR_data_t data = IRLremote.read(); // print protocol number Serial.println(); Serial.print(F("Protocol: ")); Serial.print(data.protocol); // see readme to terminate what number is for each protocol switch (data.protocol) { case IR_NEC: Serial.println(F(" NEC")); break; case IR_PANASONIC: Serial.println(F(" Panasonic")); break; case IR_SONY12: Serial.println(F(" Sony12")); break; default: Serial.println(F(" Unknown")); break; } // print the protocol data Serial.print(F("Address: 0x")); Serial.println(data.address, HEX); Serial.print(F("Command: 0x")); Serial.println(data.command, HEX); // check if the input was a specific signal and send another signal out if (data.protocol == IR_PANASONIC && data.address == 0x2002 && data.command == 0x813D1CA0) { // send the data, no pin setting to OUTPUT needed Serial.println(); Serial.println(F("Sending...")); uint16_t address = 0x6361; uint32_t command = 0xFE01; IRLwrite(pinSendIR, address, command); } // turn Led off after printing the data digitalWrite(pinLed, LOW); } } ================================================ FILE: extra/old/IRL_Hash.hpp ================================================ /* Copyright (c) 2014-2015 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once //================================================================================ // Protocol Definitions //================================================================================ //HashIR #define HASHIR_BLOCKS 255 // 0-65535 (maximum input length) #define HASHIR_TIMEOUT (0xFFFF/4) // 65535, max timeout #define HASHIR_TIME_THRESHOLD 10000UL // 0-32bit //================================================================================ // Decoding Class //================================================================================ class HashIR : public CIRLData{ public: HashIR(void){ // Empty } // Hide anything that is inside this class so the user dont accidently uses this class template friend class CIRLremote; private: static inline uint8_t getSingleFlag(void) __attribute__((always_inline)); static inline bool requiresCheckTimeout(void) __attribute__((always_inline)); static inline void checkTimeout(void) __attribute__((always_inline)); static inline bool available(void) __attribute__((always_inline)); static inline void read(IR_data_t* data) __attribute__((always_inline)); static inline bool requiresReset(void) __attribute__((always_inline)); static inline void reset(void) __attribute__((always_inline)); // Decode functions for a single protocol/multiprotocol for less/more accuration static inline void decodeSingle(const uint16_t &duration) __attribute__((always_inline)); static inline void decode(const uint16_t &duration) __attribute__((always_inline)); protected: // Temporary buffer to hold bytes for decoding the protocols // not all of them are compiled, only the used ones static uint16_t durationHashIR; static uint16_t countHashIR; static uint32_t commandHashIR; }; uint8_t HashIR::getSingleFlag(void){ return CHANGE; } bool HashIR::requiresCheckTimeout(void){ // Used in this protocol return true; } void HashIR::checkTimeout(void){ // This function is executed with interrupts turned off if (countHashIR) { // Check if reading timed out and save value. if ((micros() - IRLLastTime) >= HASHIR_TIMEOUT) { // Flag a new input if reading timed out countHashIR--; IRLProtocol = IR_HASH; IRLLastEvent = IRLLastTime; } } } bool HashIR::available(void) { // Only return a value if this protocol has new data if(IRLProtocol == IR_HASH) return true; else return false; } void HashIR::read(IR_data_t* data){ // Only (over)write new data if this protocol received any data if(IRLProtocol == IR_HASH){ // Save address as length. // You can check the address/length to prevent triggering on noise data->address = countHashIR; // Save calculated hash data->command = commandHashIR; } } bool HashIR::requiresReset(void){ // Used in this protocol return true; } void HashIR::reset(void){ // Reset protocol for new reading countHashIR = 0; commandHashIR = FNV_BASIS_32; } void HashIR::decodeSingle(const uint16_t &duration){ // Reading timed out if(duration >= HASHIR_TIMEOUT) { // Start a new reading sequence. if(countHashIR == 0){ countHashIR++; } // Ignore the very first timeout of each reading. // Otherwise flag a new input and stop reading. else if(countHashIR != 1){ countHashIR--; IRLProtocol = IR_HASH; } return; } // Only save data if a sequence is running. // This is required to avoid corrupted data // when starting capturing at the middle of a sequence. if(countHashIR) { // Converts the raw code values into a 32-bit hash code. // Hopefully this code is unique for each button. // This isn't a "real" decoding, just an arbitrary value. // Code taken from https://github.com/z3t0/Arduino-IRremote // Use FNV hash algorithm: http://isthe.com/chongo/tech/comp/fnv/#FNV-param #define FNV_PRIME_32 16777619UL #define FNV_BASIS_32 2166136261UL // Only compare after the first value got received if(countHashIR > 1){ // Get both values auto oldval = durationHashIR; auto newval = duration; // Compare two tick values, returning 0 if newval is shorter, // 1 if newval is equal, and 2 if newval is longer // Use a tolerance of 75% uint8_t value = 1; if (newval < (oldval * 3 / 4)) { value = 0; } else if (oldval < (newval * 3 / 4)) { value = 2; } // Add value into the hash commandHashIR = (commandHashIR * FNV_PRIME_32) ^ value; } // Save last time and count up countHashIR++; durationHashIR = duration; // Flag a new input if buffer is full if((countHashIR > HASHIR_BLOCKS)){ countHashIR--; IRLProtocol = IR_HASH; } } } void HashIR::decode(const uint16_t &duration) { // Wait some time after the last protocol. // This way it can finish its (possibly ignored) stop bit. uint8_t lastProtocol = IRLProtocol | IR_NEW_PROTOCOL; if(lastProtocol != IR_HASH && lastProtocol != IR_NEW_PROTOCOL && (IRLLastTime - IRLLastEvent < HASHIR_TIME_THRESHOLD)) return; decodeSingle(duration); } ================================================ FILE: extra/old/IRL_RawIR.hpp ================================================ /* Copyright (c) 2014-2015 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once //================================================================================ // Protocol Definitions //================================================================================ //RawIR #define RAWIR_BLOCKS 100 // 0-65535 #define RAWIR_TIMEOUT (0xFFFF/4) // 65535, max timeout #define RAWIR_TIME_THRESHOLD 10000UL // 0-32bit // Determine buffer length datatype #if (RAWIR_BLOCKS >= 255) #define RAWIR_DATA_T uint16_t #else #define RAWIR_DATA_T uint8_t #endif //================================================================================ // Decoding Class //================================================================================ class RawIR : public CIRLData{ public: RawIR(void){ // Empty } // Hide anything that is inside this class so the user dont accidently uses this class template friend class CIRLremote; private: static inline uint8_t getSingleFlag(void) __attribute__((always_inline)); static inline bool requiresCheckTimeout(void) __attribute__((always_inline)); static inline void checkTimeout(void) __attribute__((always_inline)); static inline bool available(void) __attribute__((always_inline)); static inline void read(IR_data_t* data) __attribute__((always_inline)); static inline bool requiresReset(void) __attribute__((always_inline)); static inline void reset(void) __attribute__((always_inline)); // Decode functions for a single protocol/multiprotocol for less/more accuration static inline void decodeSingle(const uint16_t &duration) __attribute__((always_inline)); static inline void decode(const uint16_t &duration) __attribute__((always_inline)); public: // Temporary buffer to hold bytes for decoding the protocols // not all of them are compiled, only the used ones static volatile RAWIR_DATA_T countRawIR; static volatile uint16_t dataRawIR[RAWIR_BLOCKS]; }; uint8_t RawIR::getSingleFlag(void){ return CHANGE; } bool RawIR::requiresCheckTimeout(void){ // Used in this protocol return true; } void RawIR::checkTimeout(void){ // This function is executed with interrupts turned off if(countRawIR) { // Check if reading timed out and save value. if ((micros() - IRLLastTime) >= RAWIR_TIMEOUT) { // Flag a new input if reading timed out countRawIR--; // Ignore the very first timeout. // This should normally never happen, but in any case // try to avoid a timeout only flag with bufferlength 0. if(countRawIR){ IRLProtocol = IR_RAW; IRLLastEvent = IRLLastTime; } } } } bool RawIR::available(void) { // Only return a value if this protocol has new data if(IRLProtocol == IR_RAW) return true; else return false; } void RawIR::read(IR_data_t* data){ // Only (over)write new data if this protocol received any data if(IRLProtocol == IR_RAW){ // Converts the raw code values into a 32-bit hash code. // Hopefully this code is unique for each button. // This isn't a "real" decoding, just an arbitrary value. // Code taken from https://github.com/z3t0/Arduino-IRremote // Use FNV hash algorithm: http://isthe.com/chongo/tech/comp/fnv/#FNV-param #define FNV_PRIME_32 16777619UL #define FNV_BASIS_32 2166136261UL // Save address as length. // You can check the address/length to prevent triggering on noise data->address = countRawIR; // Iterate through all raw values and calculate a hash uint32_t hash = FNV_BASIS_32; for (typeof(countRawIR) i = 1; i < countRawIR; i++) { // Get both values auto oldval = dataRawIR[i - 1]; auto newval = dataRawIR[i]; // Compare two tick values, returning 0 if newval is shorter, // 1 if newval is equal, and 2 if newval is longer // Use a tolerance of 75% uint8_t value = 1; if (newval < (oldval * 3 / 4)) { value = 0; } else if (oldval < (newval * 3 / 4)) { value = 2; } // Add value into the hash hash = (hash * FNV_PRIME_32) ^ value; } // Save calculated hash data->command = hash; } } bool RawIR::requiresReset(void){ // Used in this protocol return true; } void RawIR::reset(void){ // Reset protocol for new reading countRawIR = 0; } void RawIR::decodeSingle(const uint16_t &duration){ // Reading timed out if(duration >= RAWIR_TIMEOUT){ // Ignore the very first timeout of each reading. if(countRawIR == 1){ return; } // Otherwise flag a new input and stop reading. else if(countRawIR){ countRawIR--; IRLProtocol = IR_RAW; } // Start a new reading sequence. else{ countRawIR++; } return; } // Only save data if a sequence is running. // This is required to avoid corrupted data // when starting capturing at the middle of a sequence. if(countRawIR){ // Save value and increase count dataRawIR[countRawIR - 1] = duration; countRawIR++; // Flag a new input if buffer is full if((countRawIR > RAWIR_BLOCKS)){ countRawIR--; IRLProtocol = IR_RAW; } } } void RawIR::decode(const uint16_t &duration) { // Wait some time after the last protocol. // This way it can finish its (possibly ignored) stop bit. uint8_t lastProtocol = IRLProtocol | IR_NEW_PROTOCOL; if(lastProtocol != IR_RAW && lastProtocol != IR_NEW_PROTOCOL && (IRLLastTime - IRLLastEvent < RAWIR_TIME_THRESHOLD)){ return; } decodeSingle(duration); } ================================================ FILE: extra/old/IRL_Sony.hpp ================================================ /* Copyright (c) 2014-2015 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once //================================================================================ // Protocol Definitions //================================================================================ //SONY 8, 12, 15, 20 //IRP notation: {40k,600}<1,-1|2,-1>(4,-1,F:8,^22200) //IRP notation: {40k,600}<1,-1|2,-1>(4,-1,F:7,D:5,^45m)+ //IRP notation: {40k,600}<1,-1|2,-1>(4,-1,F:7,D:8,^45m)+ //IRP notation: {40k,600}<1,-1|2,-1>(4,-1,F:7,D:5,S:8,^45m) + // Lead + Mark logic #define SONY_HZ 40000 #define SONY_PULSE 600UL #define SONY_BLOCKS_8 1 #define SONY_BLOCKS_12 2 #define SONY_BLOCKS_15 2 #define SONY_BLOCKS_20 3 #define SONY_ADDRESS_LENGTH_8 0 #define SONY_ADDRESS_LENGTH_12 5 #define SONY_ADDRESS_LENGTH_15 8 #define SONY_ADDRESS_LENGTH_20 13 #define SONY_COMMAND_LENGTH_8 8 #define SONY_COMMAND_LENGTH_12 7 #define SONY_COMMAND_LENGTH_15 7 #define SONY_COMMAND_LENGTH_20 7 #define SONY_LENGTH_8 (2 + (8-1) * 2) // 2 for lead + space, -1 for mark end, 8 bit #define SONY_LENGTH_12 (2 + (7+5-1) * 2) // 2 for lead + space, -1 for mark end, 12 bit #define SONY_LENGTH_15 (2 + (7+8-1) * 2) // 2 for lead + space, -1 for mark end, 15 bit #define SONY_LENGTH_20 (2 + (7+5+8-1) * 2) // 2 for lead + space, -1 for mark end, 20 bit #define SONY_TIMEOUT_8 22200 #define SONY_TIMEOUT 45000 // 12, 15, 20 have the same timeout #define SONY_MARK_LEAD (SONY_PULSE * 4) #define SONY_SPACE_LEAD (SONY_PULSE * 1) #define SONY_SPACE_HOLDING 0 // no holding function in this protocol #define SONY_MARK_ZERO (SONY_PULSE * 1) #define SONY_MARK_ONE (SONY_PULSE * 2) #define SONY_SPACE_ZERO (SONY_PULSE * 1) #define SONY_SPACE_ONE (SONY_PULSE * 1) //================================================================================ // Decoding Class //================================================================================ class Sony : public CIRLData{ public: Sony(void){ // Empty } // Hide anything that is inside this class so the user dont accidently uses this class template friend class CIRLremote; private: static inline uint8_t getSingleFlag(void) __attribute__((always_inline)); static inline bool requiresCheckTimeout(void) __attribute__((always_inline)); static inline void checkTimeout(void) __attribute__((always_inline)); static inline bool available(void) __attribute__((always_inline)); static inline void read(IR_data_t* data) __attribute__((always_inline)); static inline bool requiresReset(void) __attribute__((always_inline)); static inline void reset(void) __attribute__((always_inline)); // Decode functions for a single protocol/multiprotocol for less/more accuration static inline void decodeSingle(const uint16_t &duration) __attribute__((always_inline)); static inline void decode(const uint16_t &duration) __attribute__((always_inline)); protected: // Temporary buffer to hold bytes for decoding the protocols // not all of them are compiled, only the used ones static uint8_t countSony; static uint8_t dataSony[SONY_BLOCKS_12]; }; uint8_t Sony::getSingleFlag(void){ return CHANGE; //TODO change to RISING and implement function } bool Sony::requiresCheckTimeout(void){ // Used in this protocol return true; } void Sony::checkTimeout(void){ // Only check for timeout if the last protocol was Sony uint8_t lastProtocol = IRLProtocol | IR_NEW_PROTOCOL; if(lastProtocol == IR_SONY12) { // Reset if a keypress ended to ensure // the next reading does not trigger // the first and 3rd signal (instead of the 2nd). if ((micros() - IRLLastTime) >= SONY_TIMEOUT) { reset(); } } } bool Sony::available(void) { // Only return a value if this protocol has new data if(IRLProtocol == IR_SONY12) //TODO return true; else return false; } void Sony::read(IR_data_t* data){ // Only (over)write new data if this protocol received any data if(IRLProtocol == IR_SONY12){ //TODO // protocol has no checksum uint8_t upper4Bits = ((dataSony[1] >> 3) & 0x1E); if (dataSony[0] & 0x80) upper4Bits |= 0x01; data->address = upper4Bits; data->command = dataSony[0] & 0x7F; } } bool Sony::requiresReset(void){ // Used in this protocol return true; } void Sony::reset(void){ countSony = 0; // Remove last protocol flag // This prevents the remote from triggering again // When the very first of three signals is recived // and the last keypress was already sony. // This also ensures that then 3rd signal is // also ignored. After this every 2nd signal // is recognized correct. if((IRLProtocol | IR_NEW_PROTOCOL) == IR_SONY12){ IRLProtocol = IR_NO_PROTOCOL; } } void Sony::decodeSingle(const uint16_t &duration){ // not implemented TODO decode(duration); } void Sony::decode(const uint16_t &duration) { // spaceTimeout gives some better accuracy, since we dont have a checksum here. // also set markTimeout if needed. const uint8_t irLength = SONY_LENGTH_12; const uint16_t timeoutThreshold = (SONY_TIMEOUT + SONY_MARK_LEAD) / 2; const uint16_t markLeadThreshold = (SONY_MARK_LEAD + SONY_MARK_ONE) / 2; const uint16_t markThreshold = (SONY_MARK_ONE + SONY_MARK_ZERO) / 2; const uint16_t markTimeout = 0; // (SONY_MARK_LEAD + SONY_MARK_ONE) / 2 const uint16_t spaceTimeout = SONY_MARK_ONE; // if timeout always start next possible reading and abort any pending readings //TODO maybe use the sending 3 times to determine sony 12 vs 20 // call the event from here after 2nd valid input if its still smaller than x if (duration >= timeoutThreshold) countSony = 1; // on a reset (error in decoding) we are waiting for a timeout to start a new reading again // this is to not conflict with other protocols while they are sending 0/1 which might be similar to a lead in another protocol else if (countSony == 0) return; // check pulses for mark/space and lead + logical 0/1 seperate else { // Mark pulses (odd numbers) if (countSony % 2 == 1) { // check Mark Lead (needs a timeout or a correct signal) if (countSony == 1) { // wrong lead if (duration < markLeadThreshold) { countSony = 0; return; } } else { // check for timeout if needed (might be a different protocol) if (markTimeout && duration > markTimeout) { countSony = 0; return; } // check different logical space pulses // get number of the Mark Bits (starting from zero) // only save every 2nd value, substract the first two lead pulses uint8_t length = (countSony / 2) - 1; // move bits and write 1 or 0 depending on the duration bool LSB = dataSony[length / 8] & 0x01; dataSony[length / 8] >>= 1; // set bit if it's a logical 1. Setting zero not needed due to bitshifting. bool logicBit = duration >= markThreshold; if (logicBit){ dataSony[length / 8] |= 0x80; } // Compare if new data is equal with last. // If not, remove the pressed flag and mark // the data as corrupted. // A new series is then required. // This is possible with Sony since it sends the // data always 3 times + X holding. if(LSB != logicBit){ if((IRLProtocol | IR_NEW_PROTOCOL) == IR_SONY12){ IRLProtocol = IR_NO_PROTOCOL; } } // check last input (always a mark) if (countSony > irLength) { // reset reading countSony = 0; uint8_t lastProtocol = IRLProtocol | IR_NEW_PROTOCOL; // Sony has no checksum IRLProtocol = IR_SONY12; // Trigger only on 2nd press and onwards // Sony normally should trigger 3 times anyways. // Normally it is recommended to check the last received data // and compare them with the 2nd (and 3rd) press. // TODO compare this while decoding (writing) // and remove lastProtocol if its unequal // This is also required to differenciate between Sony 12 and 20. // TODO the reset should then not happen if(lastProtocol != IR_SONY12){ IRLProtocol &= (~IR_NEW_PROTOCOL); } return; } } } // Space pulses (even numbers) else { // check for timeout if needed (might be a different protocol) // we could only check the lead or all data, // since the pulse should be always the same for lead and data // all data gives better errorcorrection and takes less flash if (spaceTimeout && duration > spaceTimeout) { countSony = 0; return; } } // next reading, no errors countSony++; } } /* template inline void CIRLremote:: decodeSony20(const uint16_t duration) { //// pass the duration to the decoding function //bool newInput; //// 1st extra accuracy solution //if (sizeof...(irProtocol) != 1) // newInput = IRLdecode // markTimeout, spaceTimeout // (duration, dataSony20, countSony20); //else // newInput = IRLdecode // markTimeout, spaceTimeout // (duration, dataSony20, countSony20); //if (newInput){ // // protocol has no checksum // uint8_t upper5Bits = ((dataSony20[2] >> 2) & 0x3E); // uint8_t lsb = (dataSony20[0] >> 7) & 0x01; // uint16_t address = (upper5Bits << 8) | (dataSony20[1] << 1) | lsb; // uint32_t command = dataSony20[0] & 0x7F; // // 2nd extra accuracy solution // //if ((sizeof...(irProtocol) != 1) && (address || command)) // IREvent(IR_SONY20, address, command); // // reset reading // countSony20 = 0; //} } // // //template //template // inline bool CIRLremote:: // IRLdecode(uint16_t duration, uint8_t data[], uint8_t &count){ // // // if timeout always start next possible reading and abort any pending readings // if (duration >= timeoutThreshold) // count = 1; // // // on a reset (error in decoding) we are waiting for a timeout to start a new reading again // // this is to not conflict with other protocols while they are sending 0/1 which might be similar to a lead in another protocol // else if (count == 0) // return false; // // // check pulses for mark/space and lead + logical 0/1 seperate // else{ // // Mark pulses (odd numbers) // if (count % 2 == 1){ // // check Mark Lead (needs a timeout or a correct signal) // if (markLeadThreshold && count == 1){ // // wrong lead // if (duration <= markLeadThreshold){ // count = 0; // return false; // } // } // // else{ // // check for timeout if needed (might be a different protocol) // if (markTimeout && duration > markTimeout){ // count = 0; // return false; // } // // // only check values if the protocol has different logical space pulses // else if (markThreshold){ // // // get number of the Mark Bits (starting from zero) // uint8_t length; // // only save every 2nd value, substract the first two lead pulses // if (!spaceThreshold) // length = (count / 2) - 1; // // special case: spaces and marks both have data in the pulse // else length = count - 2; // // // move bits and write 1 or 0 depending on the duration // // 1.7: changed from MSB to LSB. somehow takes a bit more flash but is correct and easier to handle. // data[length / 8] >>= 1; // if (duration > markThreshold) // data[length / 8] |= 0x80; // //else // normally not needed through the bitshift // // data[length / 8] &= ~0x80; // } // // // check last input (always a mark) // if (count > irLength){ // // reset by decoding function // //count = 0; // return true; // } // } // } // // // Space pulses (even numbers) // else{ // //check Space Lead/Space Holding // if (spaceLeadThreshold && count == 2){ // // normal Space, next reading // if (duration > spaceLeadThreshold); // // // Button holding (if supported by protocol) // else if (spaceLeadHoldingThreshold && duration > spaceLeadHoldingThreshold){ // // call the holding function after // // count not resetted to read it afterwards // // next mark ignored due to detecting techniques // //count = 0; // return true; // } // // wrong space // else { // count = 0; // return false; // } // } // else{ // // check for timeout if needed (might be a different protocol) // if (spaceTimeout && duration > spaceTimeout){ // count = 0; // return false; // } // // // only check values if the protocol has different logical space pulses // else if (spaceThreshold){ // // // get number of the Space Bits (starting from zero) // uint8_t length; // // only save every 2nd value, substract the first two lead pulses // if (!markThreshold) // length = (count / 2) - 2; // // special case: spaces and marks both have data in the pulse // else length = count - 2; // // // move bits and write 1 or 0 depending on the duration // // 1.7: changed from MSB to LSB. somehow takes a bit more flash but is correct and easier to handle. // data[length / 8] >>= 1; // if (duration > spaceThreshold) // data[length / 8] |= 0x80; // //else // normally not needed through the bitshift // // data[length / 8] &= ~0x80; // } // } // } // // // next reading, no errors // count++; // } // // // no valid input (yet) // return false; //} */ ================================================ FILE: extra/old/IRLremote.cpp ================================================ /* Copyright (c) 2014-2015 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "IRLremote.h" //================================================================================ // Static Data //================================================================================ // Protocol temporary data uint8_t Nec::countNec = 0; uint8_t Nec::dataNec[NEC_BLOCKS] = { 0 }; volatile uint8_t Nec::protocol = IR_NO_PROTOCOL; uint32_t Nec::lastTime = 0; volatile uint32_t Nec::lastEvent = 0; uint8_t Panasonic::countPanasonic = 0; uint8_t Panasonic::dataPanasonic[PANASONIC_BLOCKS] = { 0 }; uint8_t Sony::countSony = 0; uint8_t Sony::dataSony[SONY_BLOCKS_12] = { 0 }; volatile RAWIR_DATA_T RawIR::countRawIR = 0; volatile uint16_t RawIR::dataRawIR[RAWIR_BLOCKS] = { 0 }; uint16_t HashIR::durationHashIR = 0; uint16_t HashIR::countHashIR = 0; uint32_t HashIR::commandHashIR = FNV_BASIS_32; // Main/shared remote data volatile uint8_t CIRLData::IRLProtocol = IR_NO_PROTOCOL; uint32_t CIRLData::IRLLastTime = 0; volatile uint32_t CIRLData::IRLLastEvent = 0; ================================================ FILE: extra/old/IRLremoteReceive.hpp ================================================ /* Copyright (c) 2014-2015 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // include guard #pragma once //================================================================================ // User Functions //================================================================================ template CIRLremote:: CIRLremote(void) { // Empty } template bool CIRLremote:: begin(uint8_t pin) { // Get pin ready for reading. // This is normally not required with a static setup // But for dynamic plugging it is. pinMode(pin, INPUT_PULLUP); // For single protocols use a different flag uint8_t flag = CHANGE; if(sizeof...(protocols) == 0){ flag = protocol::getSingleFlag(); } // Try to attach PinInterrupt first if (digitalPinToInterrupt(pin) != NOT_AN_INTERRUPT){ attachInterrupt(digitalPinToInterrupt(pin), interrupt, flag); return true; } // If PinChangeInterrupt library is used, try to attach it #ifdef PCINT_VERSION else if (digitalPinToPCINT(pin) != NOT_AN_INTERRUPT){ attachPCINT(digitalPinToPCINT(pin), interrupt, flag); return true; } #endif // Return an error if none of them work (pin has no Pin(Change)Interrupt) return false; } template bool CIRLremote:: end(uint8_t pin) { // Disable pullup. pinMode(pin, INPUT); // Try to detach PinInterrupt first if (digitalPinToInterrupt(pin) != NOT_AN_INTERRUPT){ detachInterrupt(digitalPinToInterrupt(pin)); return true; } // If PinChangeInterrupt library is used, try to detach it #ifdef PCINT_VERSION else if (digitalPinToPCINT(pin) != NOT_AN_INTERRUPT){ detachPCINT(digitalPinToPCINT(pin)); return true; } #endif // Return an error if none of them work (pin has no Pin(Change)Interrupt) return false; } template bool CIRLremote:: available(void) { // Only add this overhead if we have multiple protocols // Or the protocol requires a timeout check. if(sizeof...(protocols) != 0 || protocol::requiresCheckTimeout()) { // Disable interrupts when checking for new input uint8_t oldSREG = SREG; cli(); // Let each protocol check if their timeout expired. Not all protocols use this. if(!(IRLProtocol & IR_NEW_PROTOCOL)){ protocol::checkTimeout(); nop((protocols::checkTimeout(), 0)...); } SREG = oldSREG; } // This if construct saves flash if(IRLProtocol & IR_NEW_PROTOCOL) return true; else return false; } template IR_data_t CIRLremote:: read(void) { // If nothing was received return an empty struct IR_data_t data = IR_data_t(); // Only the received protocol will write data into the struct uint8_t oldSREG = SREG; cli(); // Get new data, if any if(IRLProtocol & IR_NEW_PROTOCOL) { // Check if we actually have new data and save the protocol as well data.address = ((uint16_t)dataNec[1] << 8) | ((uint16_t)dataNec[0]); data.command = ((uint16_t)dataNec[3] << 8) | ((uint16_t)dataNec[2]); data.protocol = IRLProtocol; // Remove new protocol flag IRLProtocol &= ~IR_NEW_PROTOCOL; // Set last ISR to current time. // This is required to not trigger a timeout afterwards // and read corrupted data. This might happen // if the reading loop is too slow. IRLLastTime = micros(); } SREG = oldSREG; // Process API TODO // Return the new protocol information to the user return data; } template void CIRLremote:: reset(void) { // Call all protocol reset functions protocol::reset(); nop((protocols::reset(), 0)...); } //================================================================================ // Interrupt Function //================================================================================ template void CIRLremote:: interrupt(void) { // Block if the protocol is already recognized if(IRLProtocol & IR_NEW_PROTOCOL) return; // Save the duration between the last reading uint32_t time = micros(); uint32_t duration_32 = time - IRLLastTime; IRLLastTime = time; // Calculate 16 bit duration. On overflow sets duration to a clear timeout uint16_t duration = 0xFFFF; if (duration_32 <= 0xFFFF) duration = duration_32; // For a single protocol use a simpler decode function // to get maximum speed + recognition and minimum flash size protocol::decodeSingle(duration); // New valid signal, save new time if(IRLProtocol & IR_NEW_PROTOCOL) { IRLLastEvent = IRLLastTime; } } ================================================ FILE: extra/old/IRLremoteTransmit.hpp ================================================ /* Copyright (c) 2014-2015 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // include guard #pragma once //================================================================================ // Definitions //================================================================================ // definition for sending to determine what should be send first #define IR_ADDRESS_FIRST true #define IR_COMMAND_FIRST false // definition to convert an uint8_t array to an uint16_t/uint32_t at any position (thx timeage!) #define UINT16_AT_OFFSET(p_to_8, offset) ((uint16_t)*((const uint16_t *)((p_to_8)+(offset)))) #define UINT32_AT_OFFSET(p_to_8, offset) ((uint32_t)*((const uint32_t *)((p_to_8)+(offset)))) // definition to get the higher value #define MAX(a,b) \ ({ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a > _b ? _a : _b; }) // definition to get the lower value #define MIN(a,b) \ ({ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a < _b ? _a : _b; }) //================================================================================ // Inline Implementations (send) //================================================================================ template void IRLwrite(const uint8_t pin, uint16_t address, uint32_t command) { // get the port mask and the pointers to the out/mode registers for faster access uint8_t bitMask = digitalPinToBitMask(pin); uint8_t port = digitalPinToPort(pin); volatile uint8_t * outPort = portOutputRegister(port); volatile uint8_t * modePort = portModeRegister(port); // set pin to OUTPUT and LOW *modePort |= bitMask; *outPort &= ~bitMask; // disable interrupts uint8_t oldSREG = SREG; cli(); switch (irType) { case IR_NEC: // NEC only sends the data once if (command == 0xFFF) // send holding indicator IRLsend<0, 0, NEC_HZ, 0, NEC_MARK_LEAD, NEC_SPACE_HOLDING, 0, 0, 0, 0> (outPort, bitMask, address, command); else // send data IRLsend (outPort, bitMask, address, command); break; case IR_PANASONIC: //TODO test // send data IRLsend (outPort, bitMask, address, command); break; case IR_SONY12: //TODO test, address -1? // repeat 3 times for (uint8_t i = 0; i < 3; i++) // send data IRLsend (outPort, bitMask, address, command); break; } // enable interrupts SREG = oldSREG; // set pin to INPUT again to be save *modePort &= ~bitMask; } // multifunctional template for sending template void IRLsend(volatile uint8_t * outPort, uint8_t bitmask, uint16_t address, uint32_t command) { // send lead mark if (markLead) IRLmark(Hz, outPort, bitmask, markLead); // send lead space if (spaceLead) IRLspace(outPort, bitmask, spaceLead); // abort if input values are both the same (sending a holding signal for example) if (markOne != markZero || spaceOne != spaceZero) { // go through all bits for (uint8_t i = 0; i < (addressLength + commandLength); i++) { // determine if its a logical one or zero, starting with address or command bool bitToSend; if (addressFirst && i < addressLength || !addressFirst && i >= commandLength) { bitToSend = address & 0x01; address >>= 1; } else { bitToSend = command & 0x01; command >>= 1; } // send logic mark bits if needed if (markOne != markZero) { // modulate if spaces dont have logic, else only every even number if (spaceOne == spaceZero || spaceOne != spaceZero && i % 2 == 0) { if (bitToSend) IRLmark(Hz, outPort, bitmask, markOne); else IRLmark(Hz, outPort, bitmask, markZero); } } else IRLmark(Hz, outPort, bitmask, markOne); // send logic space bits if needed if (spaceOne != spaceZero) { // modulate if marks dont have logic, else only every odd number if (markOne == markZero || markOne != markZero && i % 2 == 1) { if (bitToSend) IRLspace(outPort, bitmask, spaceOne); else IRLspace(outPort, bitmask, spaceZero); } } else IRLspace(outPort, bitmask, spaceOne); } } // finish mark IRLmark(Hz, outPort, bitmask, markZero); //TODO zero or one for sony? IRLspace(outPort, bitmask, 0); } void IRLmark(const uint16_t Hz, volatile uint8_t * outPort, uint8_t bitMask, uint16_t time) { /* Bitbangs PWM in the given Hz number for the given time ________________________________________________________________________________ Delay calculation: F_CPU/1.000.000 to get number of cycles/uS /3 to get the number of loops needed for 1ms (1loop = 3 cycles) Multiply with the number of ms delay: 1/kHz to get the seconds * 1.000.000 to get it in uS /2 to get half of a full pulse Substract the while, portmanipulation, loop overhead /3 loop cycles F_CPU(16.000.000) 1 * 1.000.000(pulse in uS) 12(overhead) ========================== * ========================== - ============== 1.000.000 * 3(loop cycles) Hz * 2(half of a pulse) 3(loop cycles) <==> F_CPU(16.000.000) - (12(overhead) * Hz * 2(half of a pulse)) =========================================================== Hz * 2(half of a on/off pulse) * 3(loop cycles) ________________________________________________________________________________ Iterations calculation: Devide time with cycles in while loop Multiply this with the cycles per uS cycles per while loop: 3(loop cycles) * delay + overhead time * (F_CPU(16.000.000) / 1.000.000) ====================================== delay*3(loop cycles) + overhead */ const uint32_t loopCycles = 3; const uint32_t overHead = 12; // just a guess from try + error uint8_t delay = (F_CPU - (overHead * Hz * 2UL)) / (Hz * 2UL * loopCycles); uint16_t iterations = (time * (F_CPU / 1000000UL)) / (delay * loopCycles + overHead); // modulate IR signal while (iterations--) { // flip pin state and wait for the calculated time *outPort ^= bitMask; #ifdef ARDUINO_ARCH_AVR // loop _delay_loop_1(delay); #else // ARM TODO? #endif } // register uint8_t temp; // asm volatile ( // // flip pin state // ".L%=_iteration_loop:\n" // "ld %[temp], %a[outPort]\n" // (2) read the pin (happens before the 2 cycles) // "eor %[temp], %[bitMask]\n" // (1) XOR value // "st %a[outPort],%[temp]\n" // (2) flip pin state TODO happens before or after the 2 cycles // // wait some time to modulate the Hz // "mov %[temp],%[delay]\n" // (1) load delay value into temp // ".L%=_delay_loop:\n" // "dec %[temp]\n" // (1) decrement 1 from delay counter // "brne .L%=_delay_loop\n" // (1/2) wait until delay is over // // check if all pulses have been sent // //TODO set pin low // "eor %[bitMask], %[bitMask]\n" // (1) XOR value // "ld %[temp], %a[outPort]\n" // (2) read the pin (happens before the 2 cycles) // "and %[temp], %[bitMask]\n" // (1) AND value // "st %a[outPort],%[temp]\n" // (2) set pin low TODO happens before or after the 2 cycles // //MOVF NumL, F; Test lo byte // //BTFSC STATUS, Z; Skip if not zero // //DECF NumH, F; Decrement hi byte // //DECF NumL, F; Decrement lo byte // // decrement low byte // // check if low byte is 255 // // if yes decrement high byte // // check if high byte is zero, if yes and function // // if no decrement // // jump to loop above // // end of loop // // ---------- // // outputs: // : [outPort] "+e" (outPort), // (read and write) // [temp] "=&r" (temp), // (output only) // // inputs: // : [delay] "r" (delay), // [bitMask] "r" (bitMask) // // no clobbers // ); // end of asm volatile } //} // // // abort if input values are both the same (sending a holding signal for example) // if (markOne != markZero || spaceOne != spaceZero) // { // // go through all bits // for (uint8_t i = 0; i < (addressLength + commandLength); i++){ // 5f4: 8c e2 ldi r24, 0x2C ; 44 // 5f6: 90 e0 ldi r25, 0x00 ; 0 // 5f8: 01 97 sbiw r24, 0x01 ; 1 // const uint32_t overHead = 12; // just a guess from try + error // uint8_t delay = (F_CPU - (overHead * Hz * 2UL)) / (Hz * 2UL * loopCycles); // uint16_t iterations = (time*(F_CPU / 1000000UL)) / (delay * loopCycles + overHead); // // // modulate IR signal // while (iterations--){ // 5fa: 39 f0 breq .+14 ; 0x60a // // flip pin state and wait for the calculated time // *outPort ^= bitMask; // // //5fc: 28 81 ld r18, Y // //5fe: 27 25 eor r18, r7 // //600: 28 83 st Y, r18 // // 602: 25 2d mov r18, r5 // 604: 2a 95 dec r18 // 606: f1 f7 brne .-4 ; 0x604 // 608: f7 cf rjmp .-18 ; 0x5f8 // // const uint32_t loopCycles = 3; // const uint32_t overHead = 12; // just a guess from try + error // uint8_t delay = (F_CPU - (overHead * Hz * 2UL)) / (Hz * 2UL * loopCycles); // uint16_t iterations = (time*(F_CPU / 1000000UL)) / (delay * loopCycles + overHead); // // // modulate IR signal // while (iterations--){ // // flip pin state and wait for the calculated time // *outPort ^= bitMask; // //5fc: 28 81 ld r18, Y // //5fe: 27 25 eor r18, r7 // //600: 28 83 st Y, r18 // //#ifdef ARDUINO_ARCH_AVR // // loop // _delay_loop_1(delay); //#else // // ARM TODO? //#endif // } // } void IRLspace(volatile uint8_t * outPort, uint8_t bitMask, uint16_t time) { // Sends an IRLspace for the specified number of microseconds. // A IRLspace is no output, so the PWM output is disabled. *outPort &= ~bitMask; // write pin LOW delayMicroseconds(time); //_delay_loop_2(time*(F_CPU/1000000UL)/4UL); } // //template //void IRLsend(volatile uint8_t* outPort, volatile uint8_t* inPort uint8_t bitMask, uint16_t timeMark, uint16_ timeSpace){ // // uint16_t iterations = timeMark; // // while (iterations){ // *inPort |= bitMask; // } //} ================================================ FILE: keywords.txt ================================================ ####################################### # Syntax Coloring Map For IRLremote ####################################### ####################################### # Datatypes (KEYWORD1) ####################################### IRLremote KEYWORD1 ####################################### # Methods and Functions (KEYWORD2) ####################################### CNec KEYWORD2 CNecAPI KEYWORD2 CPanasonic KEYWORD2 CHashIR KEYWORD2 Nec_data_t KEYWORD2 Panasonic_data_t KEYWORD2 Hash_data_t KEYWORD2 begin KEYWORD2 end KEYWORD2 available KEYWORD2 receiving KEYWORD2 read KEYWORD2 timeout KEYWORD2 lastEvent KEYWORD2 nextEvent KEYWORD2 read KEYWORD2 command KEYWORD2 pressCount KEYWORD2 holdCount KEYWORD2 getTimeout KEYWORD2 pressTimeout KEYWORD2 nextTimeout KEYWORD2 releaseButton KEYWORD2 reset KEYWORD2 IRLwrite KEYWORD2 IRLmark KEYWORD2 IRLspace KEYWORD2 ####################################### # Constants (LITERAL1) ####################################### IRL_KEYCODE_POWER LITERAL1 IRL_KEYCODE_MUTE LITERAL1 IRL_KEYCODE_SCREEN LITERAL1 IRL_KEYCODE_SATELLITE LITERAL1 IRL_KEYCODE_TV_RADIO LITERAL1 IRL_KEYCODE_TV_MUSIC LITERAL1 IRL_KEYCODE_1 LITERAL1 IRL_KEYCODE_2 LITERAL1 IRL_KEYCODE_3 LITERAL1 IRL_KEYCODE_4 LITERAL1 IRL_KEYCODE_5 LITERAL1 IRL_KEYCODE_6 LITERAL1 IRL_KEYCODE_7 LITERAL1 IRL_KEYCODE_8 LITERAL1 IRL_KEYCODE_9 LITERAL1 IRL_KEYCODE_BACK LITERAL1 IRL_KEYCODE_0 LITERAL1 IRL_KEYCODE_FAVORITE LITERAL1 IRL_KEYCODE_VOL_UP LITERAL1 IRL_KEYCODE_VOL_DOWN LITERAL1 IRL_KEYCODE_EPG LITERAL1 IRL_KEYCODE_INFO LITERAL1 IRL_KEYCODE_CHANNEL_UP LITERAL1 IRL_KEYCODE_CHANNEL_DOWN LITERAL1 IRL_KEYCODE_UP LITERAL1 IRL_KEYCODE_DOWN LITERAL1 IRL_KEYCODE_LEFT LITERAL1 IRL_KEYCODE_RIGHT LITERAL1 IRL_KEYCODE_OK LITERAL1 IRL_KEYCODE_EXIT LITERAL1 IRL_KEYCODE_MENU LITERAL1 IRL_KEYCODE_I_II LITERAL1 IRL_KEYCODE_TELETEXT LITERAL1 IRL_KEYCODE_SUBTITLE LITERAL1 IRL_KEYCODE_ADD LITERAL1 IRL_KEYCODE_RED LITERAL1 IRL_KEYCODE_GREEN LITERAL1 IRL_KEYCODE_YELLOW LITERAL1 IRL_KEYCODE_BLUE LITERAL1 IRL_KEYCODE_PREV LITERAL1 IRL_KEYCODE_PLAY LITERAL1 IRL_KEYCODE_STOP LITERAL1 IRL_KEYCODE_NEXT LITERAL1 IRL_KEYCODE_USB LITERAL1 IRL_KEYCODE_PAUSE LITERAL1 IRL_KEYCODE_REC LITERAL1 IRL_KEYCODE_LIVE LITERAL1 ================================================ FILE: library.properties ================================================ name=IRLremote version=2.0.2 author=NicoHood maintainer=NicoHood sentence=Lightweight Infrared library for Arduino paragraph=IRLremote implements a fast and compact way to analyze IR signals with PinInterrupts and PinChangeInterrupts. category=Signal Input/Output url=https://github.com/NicoHood/IRLremote architectures=avr,esp8266 ================================================ FILE: src/IRL_Decode.h ================================================ /* Copyright (c) 2014-2018 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once #include "IRL_Platform.h" //============================================================================== // CIRL_DecodeSpaces Class //============================================================================== template class CIRL_DecodeSpaces { public: // User API to access library data inline bool available(void); inline bool receiving(void); protected: // Temporary buffer to hold bytes for decoding the protocol static volatile uint8_t count; static uint8_t data[blocks]; // Interrupt function that is attached inline void resetReading(void); static void interrupt(void); static constexpr uint8_t interruptMode = FALLING; // Interface that is required to be implemented //static inline bool checksum(void); //static inline void holding(void); //static constexpr uint32_t limitTimeout = VALUE; //static constexpr uint32_t limitLead = VALUE; //static constexpr uint32_t limitHolding = VALUE; //static constexpr uint32_t limitLogic = VALUE; //static constexpr uint32_t limitRepeat = VALUE; //static constexpr uint8_t irLength = VALUE; }; //============================================================================== // Static Data //============================================================================== // Protocol temporary data template volatile uint8_t CIRL_DecodeSpaces::count = 0; template uint8_t CIRL_DecodeSpaces::data[blocks] = { 0 }; //============================================================================== // CIRL_DecodeSpaces Implementation //============================================================================== template bool CIRL_DecodeSpaces::available(void){ return count > (T::irLength / 2); } template void CIRL_DecodeSpaces::resetReading(void){ // Reset reading count = 0; } template void CIRL_DecodeSpaces::interrupt(void) { // Block if the protocol is already recognized if (count > (T::irLength / 2)) { return; } // Get time between previous call and decode auto duration = T::nextTime(); // On a timeout abort pending readings and start next possible reading if (duration >= T::limitTimeout) { count = 0; } // On a reset (error in decoding) wait for a timeout to start a new reading // This is to not conflict with other protocols while they are sending 0/1 // which might be similar to a lead in this protocol else if (count == 0) { return; } // Check Mark Lead (requires a timeout) else if (count == 1) { // Wrong lead if (duration < T::limitHolding) { count = 0; return; } // Check for a "button holding" lead else if (duration < T::limitLead) { // Abort if last valid button press is too long ago if ((T::mlastTime - \ T::mlastEvent) >= \ T::limitRepeat) { count = 0; return; } // Received a Nec Repeat signal // Next mark (stop bit) ignored due to detecting techniques T::holding(); count = (T::irLength / 2); T::mlastEvent = T::mlastTime; } // Else normal lead, continue processing } // Check different logical space pulses (mark + space) else { // Get number of the Bits (starting from zero) // Substract the first lead pulse uint8_t length = count - 2; // Move bits (MSB is zero) data[length / 8] >>= 1; // Set MSB if it's a logical one if (duration >= T::limitLogic) { data[length / 8] |= 0x80; } // Last bit (stop bit following) if (count >= (T::irLength / 2)) { // Check if the protcol's command checksum is correct if (T::checksum()) { T::mlastEvent = T::mlastTime; } else { count = 0; return; } } } // Next reading, no errors count++; } /* * Return true if we are currently receiving new data */ template bool CIRL_DecodeSpaces::receiving(void) { bool ret = false; // Provess with interrupts disabled to avoid any conflicts ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { // Check if we already recognized a timed out if (count == 0) { ret = false; } else { // Calculate difference between last interrupt and now uint32_t timeout = T::mlastTime; uint32_t time = micros(); timeout = time - timeout; // Check for a new timeout if (timeout >= T::limitTimeout) { count = 0; ret = false; } // We are currently receiving else { ret = true; } } } return ret; } ================================================ FILE: src/IRL_Hash.h ================================================ /* Copyright (c) 2014-2018 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once #ifdef ARDUINO #include // micros() #endif #include "IRL_Receive.h" #include "IRL_Time.h" #include "IRL_Protocol.h" #include "IRL_Decode.h" //============================================================================== // Protocol Definitions //============================================================================== //HashIR #define HASHIR_BLOCKS 255 // 0-65535 (maximum input length) #define HASHIR_TIMEOUT (0xFFFF/4) // 65535, max timeout #define HashIR_TIMESPAN (HASHIR_TIMEOUT * 3) #define HASHIR_TIME_THRESHOLD 10000UL // 0-32bit // Use FNV hash algorithm: http://isthe.com/chongo/tech/comp/fnv/#FNV-param #define FNV_PRIME_32 16777619UL #define FNV_BASIS_32 2166136261UL typedef uint8_t HashIR_address_t; typedef uint32_t HashIR_command_t; // Struct that is returned by the read() function struct HashIR_data_t { HashIR_address_t address; HashIR_command_t command; }; //============================================================================== // Hash Decoding Class //============================================================================== class CHashIR : public CIRL_Receive, public CIRL_Time, public CIRL_Protocol { public: // User API to access library data inline bool available(void); inline bool receiving(void); protected: static constexpr uint32_t timespanEvent = HashIR_TIMESPAN; friend CIRL_Receive; friend CIRL_Protocol; // Interrupt function that is attached inline void resetReading(void); static inline void interrupt(void); static constexpr uint8_t interruptMode = CHANGE; // Protocol interface functions inline HashIR_data_t getData(void); static inline bool checksum(void); static inline void holding(void); // Protocol variables static volatile uint8_t count; static uint32_t hash; static volatile uint16_t lastDuration; }; //============================================================================== // Hash Decoding Implementation //============================================================================== HashIR_data_t CHashIR::getData(void){ // Save address as length. // You can check the address/length to prevent triggering on noise HashIR_data_t retdata; retdata.address = count; retdata.command = hash; return retdata; } bool CHashIR::available(void){ // First look for a timeout receiving(); bool ret; ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { ret = lastDuration == 0; } return ret; } void CHashIR::resetReading(void){ // Reset reading hash = FNV_BASIS_32; lastDuration = 0xFFFF; count = 0; } bool CHashIR::receiving(void) { bool ret = false; // Provess with interrupts disabled to avoid any conflicts ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { // Check if we already recognized a timed out if (count == 0) { ret = false; } else { // Calculate difference between last interrupt and now uint32_t timeout = mlastTime; uint32_t time = micros(); timeout = time - timeout; // Check for a new timeout if (timeout >= HASHIR_TIMEOUT) { // Flag new data if we previously received data if(count > 1) { count--; lastDuration = 0; mlastEvent = mlastTime; } else { count = 0; } ret = false; } // We are currently receiving else { ret = true; } } } return ret; } void CHashIR::interrupt(void) { // Block if the protocol is already recognized if (lastDuration == 0) { return; } // Get time between previous call and decode auto duration = nextTime(); // Reading timed out if(duration >= HASHIR_TIMEOUT) { // Start a new reading sequence. if(count == 0) { count++; } // Ignore the very first timeout of each reading. // Otherwise flag a new input and stop reading. else if(count != 1) { count--; lastDuration = 0; mlastEvent = mlastTime; } return; } // Only save data if a sequence is running. // This is required to avoid corrupted data // when starting capturing at the middle of a sequence. if(count) { // Converts the raw code values into a 32-bit hash code. // Hopefully this code is unique for each button. // This isn't a "real" decoding, just an arbitrary value. // Code taken from https://github.com/z3t0/Arduino-IRremote // Only compare after the first value got received if(count > 1) { // Get both values auto oldval = lastDuration; auto newval = duration; // Compare two tick values, returning 0 if newval is shorter, // 1 if newval is equal, and 2 if newval is longer // Use a tolerance of 75% uint8_t value = 1; if (newval < (oldval * 3 / 4)) { value = 0; } else if (oldval < (newval * 3 / 4)) { value = 2; } // Add value into the hash hash = (hash * FNV_PRIME_32) ^ value; } // Save last time and count up count++; // Flag a new input if buffer is full if(count >= HASHIR_BLOCKS){ lastDuration = 0; mlastEvent = mlastTime; } else { lastDuration = duration; } } } ================================================ FILE: src/IRL_Keycodes.h ================================================ /* Copyright (c) 2014-2018 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once #include "IRLremote.h" //============================================================================== // Protek 9700 Series //============================================================================== namespace IRL_Protek_Remote{ // Protocol: (Extended) NEC typedef Nec_address_t IRL_address_t; typedef Nec_command_t IRL_command_t; typedef Nec_data_t IRL_data_t; static const uint16_t IRL_ADDRESS = 0x2222; enum IRL_Keycode : uint8_t { IRL_KEYCODE_POWER = 0x02, IRL_KEYCODE_MUTE = 0x16, IRL_KEYCODE_SCREEN = 0x2B, IRL_KEYCODE_SATELLITE = 0x2C, IRL_KEYCODE_TV_RADIO = 0x2D, IRL_KEYCODE_TV_MUSIC = 0x2E, IRL_KEYCODE_1 = 0x13, IRL_KEYCODE_2 = 0x14, IRL_KEYCODE_3 = 0x15, IRL_KEYCODE_4 = 0x17, IRL_KEYCODE_5 = 0x18, IRL_KEYCODE_6 = 0x19, IRL_KEYCODE_7 = 0x1B, IRL_KEYCODE_8 = 0x1C, IRL_KEYCODE_9 = 0x1D, IRL_KEYCODE_BACK = 0x0E, IRL_KEYCODE_0 = 0x0C, IRL_KEYCODE_FAVORITE = 0x04, IRL_KEYCODE_VOL_UP = 0x20, IRL_KEYCODE_VOL_DOWN = 0x21, IRL_KEYCODE_EPG = 0x08, IRL_KEYCODE_INFO = 0x12, IRL_KEYCODE_CHANNEL_UP = 0x22, IRL_KEYCODE_CHANNEL_DOWN = 0x23, IRL_KEYCODE_UP = 0x09, IRL_KEYCODE_DOWN = 0x07, IRL_KEYCODE_LEFT = 0x0A, IRL_KEYCODE_RIGHT = 0x06, IRL_KEYCODE_OK = 0x11, IRL_KEYCODE_EXIT = 0x10, IRL_KEYCODE_MENU = 0x0F, IRL_KEYCODE_I_II = 0x0D, IRL_KEYCODE_TELETEXT = 0x1F, IRL_KEYCODE_SUBTITLE = 0x01, IRL_KEYCODE_ADD = 0x2F, IRL_KEYCODE_RED = 0x27, IRL_KEYCODE_GREEN = 0x28, IRL_KEYCODE_YELLOW = 0x29, IRL_KEYCODE_BLUE = 0x2A, IRL_KEYCODE_PREV = 0x30, IRL_KEYCODE_PLAY = 0x31, IRL_KEYCODE_STOP = 0x32, IRL_KEYCODE_NEXT = 0x33, IRL_KEYCODE_USB = 0x34, IRL_KEYCODE_PAUSE = 0x35, IRL_KEYCODE_REC = 0x36, IRL_KEYCODE_LIVE = 0x37, }; } ================================================ FILE: src/IRL_Nec.h ================================================ /* Copyright (c) 2014-2018 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once #include "IRL_Receive.h" #include "IRL_Time.h" #include "IRL_Protocol.h" #include "IRL_Decode.h" //============================================================================== // Protocol Definitions //============================================================================== // NEC // IRP notation: // {38.4k,564}<1,-1|1,-3>(16,-8,D:8,S:8,F:8,~F:8,1,-78,(16,-4,1,-173)*) // Lead + Space logic #define NEC_HZ 38000UL #define NEC_PULSE 564UL #define NEC_ADDRESS_LENGTH 16 #define NEC_COMMAND_LENGTH 16 #define NEC_DATA_LENGTH (NEC_ADDRESS_LENGTH + NEC_COMMAND_LENGTH) #define NEC_BLOCKS (NEC_DATA_LENGTH / 8) // 2 for lead + space, each block has mark and space #define NEC_LENGTH (2 + NEC_DATA_LENGTH * 2) #define NEC_TIMEOUT (NEC_PULSE * 78UL) #define NEC_TIMEOUT_HOLDING (NEC_PULSE * 173UL) #define NEC_TIMESPAN_HOLDING (NEC_TIMEOUT_HOLDING + NEC_LOGICAL_HOLDING) #define NEC_MARK_LEAD (NEC_PULSE * 16UL) #define NEC_MARK_HOLDING (NEC_PULSE * 16UL) #define NEC_SPACE_LEAD (NEC_PULSE * 8UL) #define NEC_SPACE_HOLDING (NEC_PULSE * 4UL) #define NEC_LOGICAL_LEAD (NEC_MARK_LEAD + NEC_SPACE_LEAD) #define NEC_LOGICAL_HOLDING (NEC_MARK_LEAD + NEC_SPACE_HOLDING) #define NEC_MARK_ZERO (NEC_PULSE * 1UL) #define NEC_MARK_ONE (NEC_PULSE * 1UL) #define NEC_SPACE_ZERO (NEC_PULSE * 1UL) #define NEC_SPACE_ONE (NEC_PULSE * 3UL) #define NEC_LOGICAL_ZERO (NEC_MARK_ZERO + NEC_SPACE_ZERO) #define NEC_LOGICAL_ONE (NEC_MARK_ONE + NEC_SPACE_ONE) // Decoding limits #define NEC_LIMIT_LOGIC ((NEC_LOGICAL_ONE + NEC_LOGICAL_ZERO) / 2) #define NEC_LIMIT_HOLDING ((NEC_LOGICAL_HOLDING + NEC_LOGICAL_ONE) / 2) #define NEC_LIMIT_LEAD ((NEC_LOGICAL_LEAD + NEC_LOGICAL_HOLDING) / 2) #define NEC_LIMIT_TIMEOUT ((NEC_TIMEOUT + NEC_LOGICAL_LEAD) / 2) #define NEC_LIMIT_REPEAT (NEC_TIMESPAN_HOLDING * 3 / 2) /* * Nec pulse demonstration: * *---| |--------| |---| |-| ... -| |----------/ ~ /----------| * | | | | | | | ... | | | * | | | | | | | ... | | | * |----------------| |-| |-| |- ... |-| | * | Lead |Log 1|Lg0| Data |E| Timeout |- *---| |----| |---------------------/ ~ /----------------------| * | | | | | * | | | | | * |----------------| |-| | * | Holding |E| Timeout Holding |- * | Timespan Holding | * * 2 Pulses: |-+-| Logical 0 * 3 Pulses: |----| limitLogic * 4 Pulses: |-+---| Logical 1 * 12 Pulses: |-------------| limitHolding * 20 Pulses: |----------------+----| Holding * 22 Pulses: |-----------------------| limitLead * 24 Pulses: |----------------+--------| Lead * 51 Pulses: |-----------------/ ~ /-----------------| limitTimeout * 78 Pulses: |-------------------------/ ~ /-------------------------| Timeout */ typedef uint16_t Nec_address_t; typedef uint8_t Nec_command_t; // Struct that is returned by the read() function struct Nec_data_t { Nec_address_t address; Nec_command_t command; }; //============================================================================== // Nec Decoding Class //============================================================================== class CNec : public CIRL_Receive, public CIRL_Time, public CIRL_Protocol, public CIRL_DecodeSpaces { protected: static constexpr uint32_t timespanEvent = NEC_TIMESPAN_HOLDING; static constexpr uint32_t limitTimeout = NEC_LIMIT_TIMEOUT; static constexpr uint32_t limitLead = NEC_LIMIT_LEAD; static constexpr uint32_t limitHolding = NEC_LIMIT_HOLDING; static constexpr uint32_t limitLogic = NEC_LIMIT_LOGIC; static constexpr uint32_t limitRepeat = NEC_LIMIT_REPEAT; static constexpr uint8_t irLength = NEC_LENGTH; friend CIRL_Receive; friend CIRL_Protocol; friend CIRL_DecodeSpaces; // Protocol interface functions inline Nec_data_t getData(void); static inline bool checksum(void); static inline void holding(void); }; //============================================================================== // Nec Decoding Implementation //============================================================================== Nec_data_t CNec::getData(void){ Nec_data_t retdata; retdata.address = ((uint16_t)data[1] << 8) | ((uint16_t)data[0]); retdata.command = data[2]; return retdata; } bool CNec::checksum(void) { return uint8_t((data[2] ^ (~data[3]))) == 0x00; } void CNec::holding(void) { // Flag repeat signal via "invalid" address and empty command data[0] = 0xFF; data[1] = 0xFF; data[2] = 0x00; } ================================================ FILE: src/IRL_NecAPI.h ================================================ /* Copyright (c) 2014-2018 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once #include "IRL_Nec.h" //============================================================================== // API Class //============================================================================== typedef void(*NecEventCallback)(void); #define NEC_API_PRESS_TIMEOUT (500UL * 1000UL) // 0.5 seconds template class CNecAPI : public CNec { public: // User API to access library data inline void read(void); inline uint8_t command(void); inline uint8_t count(void); inline uint8_t duration(bool raw = false); inline uint8_t released(bool samebutton = false); inline constexpr uint32_t getTimeout(void); inline uint32_t nextTimeout(void); protected: // Differenciate between timeout types enum TimeoutType : uint8_t { NO_TIMEOUT, // Keydown TIMEOUT, // Key release with timeout NEXT_BUTTON, // Key release, pressed again NEW_BUTTON, // Key release, another key is pressed } NecTimeoutType; // Keep track which key was pressed/held down how often uint8_t lastCommand = 0; uint8_t lastPressCount = 0; uint8_t lastHoldCount = 0; }; //============================================================================== // API Class Implementation //============================================================================== // Reads data from the nec protocol (if available) and processes it. template void CNecAPI::read(void) { auto data = CNec::read(); // Check if the correct protocol and address (optional) is used bool firstCommand = data.address != 0xFFFF; if ((data.address == 0) || (address && firstCommand && (data.address != address))) { // Call the remote function again once the keypress timed out if (lastPressCount && (timeout() > getTimeout())) { // Flag timeout event, key was released and the current chain is over NecTimeoutType = TIMEOUT; callback(); // Reset the button press and hold count after a timeout lastPressCount = 0; lastHoldCount = 0; } return; } // Count the first button press if (firstCommand) { // The same button was pressed twice in a short timespawn (500ms) if (data.command == lastCommand) { // Flag that the last button hold is over, the same key is held down again if (lastPressCount) { NecTimeoutType = NEXT_BUTTON; callback(); } // Increase pressing streak if (lastPressCount < 255) { lastPressCount++; } } // Different button than before else { // Flag that the last button hold is over, a differnt key is now held down if (lastPressCount) { NecTimeoutType = NEW_BUTTON; callback(); } lastPressCount = 1; } // Start a new series of button holding lastHoldCount = 0; // Save the new command. On a repeat (below) don't safe it. lastCommand = data.command; } // Count the button holding else { // Abort if no first press was recognized (after reset) if(!lastPressCount){ return; } // Increment holding count if (lastHoldCount < 255) { lastHoldCount++; } } // Call the remote function and flag that the event was just received NecTimeoutType = NO_TIMEOUT; callback(); } template uint8_t CNecAPI::command(void) { return lastCommand; } // Number of repeating button presses in a row template uint8_t CNecAPI::count(void) { return lastPressCount; } // Duration (count) how long the current button press was held down. // Pass true to also recognize keyup events template uint8_t CNecAPI::duration(bool raw) { // Only recognize the actual keydown event if (NecTimeoutType == NO_TIMEOUT || raw) // TODO reorder? { return 1 + lastHoldCount; } return 0; } // True when the button is released: // 1. Timeout of press series // 2. Next press, new button // 3. Next press, same button // `--> pass true as parameter, // useful when measuring idential or single button press durations // False when the button is held down: // 1. Initial button press // 2. Holding button down // 3. Renewed button press // Usually you want to use timeout() to check if the series ends template uint8_t CNecAPI::released(bool samebutton) { if (NecTimeoutType == TIMEOUT || NecTimeoutType == NEW_BUTTON) { return 1 + lastHoldCount; } if (samebutton && NecTimeoutType == NEXT_BUTTON) { return 1 + lastHoldCount; } return 0; } template constexpr uint32_t CNecAPI::getTimeout(void) { return NEC_API_PRESS_TIMEOUT; } // Return when the next timeout triggers. // Zero means it already timed out. template uint32_t CNecAPI::nextTimeout(void) { auto time = timeout(); auto timeout = getTimeout(); if(time >= timeout) { return 0; } return timeout - time; } ================================================ FILE: src/IRL_Panasonic.h ================================================ /* Copyright (c) 2014-2018 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once #include "IRL_Receive.h" #include "IRL_Time.h" #include "IRL_Protocol.h" #include "IRL_Decode.h" //============================================================================== // Protocol Definitions //============================================================================== // PANASONIC // IRP notation: // {37k,432}<1,-1|1,-3>(8,-4,3:8,1:8,D:8,S:8,F:8,(D^S^F):8,1,-173)+ // Lead + Space logic #define PANASONIC_HZ 37000 #define PANASONIC_PULSE 432UL #define PANASONIC_ADDRESS_LENGTH 16 #define PANASONIC_COMMAND_LENGTH 32 #define PANASONIC_DATA_LENGTH (PANASONIC_ADDRESS_LENGTH + \ PANASONIC_COMMAND_LENGTH) #define PANASONIC_BLOCKS (PANASONIC_DATA_LENGTH / 8) // 2 for lead + space, each block has mark and space #define PANASONIC_LENGTH (2 + PANASONIC_DATA_LENGTH * 2) #define PANASONIC_TIMEOUT (PANASONIC_PULSE * 173UL) #define PANASONIC_TIMESPAN_HOLDING (PANASONIC_TIMEOUT + \ PANASONIC_LOGICAL_LEAD + \ (PANASONIC_DATA_LENGTH / 2) * \ PANASONIC_LOGICAL_ONE + \ (PANASONIC_DATA_LENGTH / 2) * \ PANASONIC_LOGICAL_ZERO) #define PANASONIC_MARK_LEAD (PANASONIC_PULSE * 8UL) #define PANASONIC_SPACE_LEAD (PANASONIC_PULSE * 4UL) #define PANASONIC_LOGICAL_LEAD (PANASONIC_MARK_LEAD + PANASONIC_SPACE_LEAD) // No holding function in this protocol #define PANASONIC_MARK_ZERO (PANASONIC_PULSE * 1UL) #define PANASONIC_MARK_ONE (PANASONIC_PULSE * 1UL) #define PANASONIC_SPACE_ZERO (PANASONIC_PULSE * 1UL) #define PANASONIC_SPACE_ONE (PANASONIC_PULSE * 3UL) #define PANASONIC_LOGICAL_ZERO (PANASONIC_MARK_ZERO + PANASONIC_SPACE_ZERO) #define PANASONIC_LOGICAL_ONE (PANASONIC_MARK_ONE + PANASONIC_SPACE_ONE) // Decoding limits #define PANASONIC_LIMIT_LOGIC ((PANASONIC_LOGICAL_ONE + PANASONIC_LOGICAL_ZERO) / 2) #define PANASONIC_LIMIT_HOLDING ((PANASONIC_LOGICAL_LEAD + PANASONIC_LOGICAL_ONE) / 2) #define PANASONIC_LIMIT_LEAD 0 #define PANASONIC_LIMIT_TIMEOUT ((PANASONIC_TIMEOUT + PANASONIC_LOGICAL_LEAD) / 2) #define PANASONIC_LIMIT_REPEAT (PANASONIC_TIMESPAN_HOLDING * 3 / 2) /* Panasonic pulse demonstration: *---| |------------| |---------| |---| ... -| |-- * | | | | | | | ... | | * | | | | | | | ... | | * |------------------------| |---| |---| |- ... |---| * | Lead Mark | Lead Space | Logical 1 | Log 0 | Data |End| */ typedef uint16_t Panasonic_address_t; typedef uint32_t Panasonic_command_t; // Struct that is returned by the read() function union Panasonic_data_t { struct{ union { Panasonic_address_t address; uint16_t manufacturer; }; Panasonic_command_t command; }; struct { union { uint16_t address; uint16_t manufacturer; }; uint32_t parity : 4; uint32_t system : 4; uint32_t product : 8; uint32_t function : 8; uint32_t checksum : 8; } japan; struct { union { uint16_t address; uint16_t manufacturer; }; uint32_t parity : 4; uint32_t genre1 : 4; uint32_t genre2 : 4; uint32_t data : 10; uint32_t id : 2; uint32_t checksum : 8; } denon; }; //============================================================================== // Panasonic Decoding Class //============================================================================== class CPanasonic : public CIRL_Receive, public CIRL_Time, public CIRL_Protocol, public CIRL_DecodeSpaces { protected: static constexpr uint32_t timespanEvent = PANASONIC_TIMESPAN_HOLDING; static constexpr uint32_t limitTimeout = PANASONIC_LIMIT_TIMEOUT; static constexpr uint32_t limitLead = PANASONIC_LIMIT_LEAD; static constexpr uint32_t limitHolding = PANASONIC_LIMIT_HOLDING; static constexpr uint32_t limitLogic = PANASONIC_LIMIT_LOGIC; static constexpr uint32_t limitRepeat = PANASONIC_LIMIT_REPEAT; static constexpr uint8_t irLength = PANASONIC_LENGTH; friend CIRL_Receive; friend CIRL_Protocol; friend CIRL_DecodeSpaces; // Protocol interface functions inline Panasonic_data_t getData(void); static inline bool checksum(void); static inline void holding(void); }; //============================================================================== // Panasonic Decoding Implementation //============================================================================== Panasonic_data_t CPanasonic::getData(void) { Panasonic_data_t retdata; retdata.address = ((uint16_t)data[1] << 8) | ((uint16_t)data[0]); retdata.command = ((uint32_t)data[5] << 24) | ((uint32_t)data[4] << 16) | ((uint32_t)data[3] << 8) | ((uint32_t)data[2]); return retdata; } bool CPanasonic::checksum(void) { // Check if the protcol's checksum is correct uint8_t XOR1 = data[2] ^ data[3] ^ data[4]; if (XOR1 == data[5]) { // Check vendor nibble checksum (optional) //uint8_t XOR2 = data[0] ^ data[1]; //if(((XOR2 & 0x0F) ^ (XOR2 >> 4)) == (data[2] & 0x0F)) //{ return true; //} } return false; } void CPanasonic::holding(void) { // Holding not available for Panasonic protocol return; } ================================================ FILE: src/IRL_Platform.h ================================================ /* Copyright (c) 2014-2018 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once #ifdef ARDUINO #include // micros() #endif #if defined(ARDUINO_ARCH_AVR) || defined(DMBS_ARCH_AVR8) #include #elif defined(ARDUINO_ARCH_ESP8266) || defined(ESP8266) // copied from https://github.com/wizard97/SimplyAtomic/blob/master/esp8266.h #ifndef __STRINGIFY #define __STRINGIFY(a) #a #endif #ifndef xt_rsil #define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state)); state;})) #endif #ifndef xt_wsr_ps #define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory") #endif static __inline__ void SA_iRestore(const uint32_t *__s) { xt_wsr_ps(*__s); } // Note value can be 0-15, 0 = Enable all interrupts, 15 = no interrupts #define SA_ATOMIC_RESTORESTATE uint32_t _sa_saved \ __attribute__((__cleanup__(SA_iRestore))) = xt_rsil(15) #define ATOMIC_RESTORESTATE #define ATOMIC_BLOCK(A) \ for ( SA_ATOMIC_RESTORESTATE, _sa_done = 1; \ _sa_done; _sa_done = 0 ) #else #error "This library supports only AVR and ESP8266 Boards." #endif ================================================ FILE: src/IRL_Protocol.h ================================================ /* Copyright (c) 2014-2018 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once #include "IRL_Platform.h" //============================================================================== // IRL_Protocol Class //============================================================================== template class CIRL_Protocol { public: // User API to access library data Protocol_data_t read(void); protected: // Interface that is required to be implemented //inline Nec_data_t getData(void); //inline void resetReading(void); }; //============================================================================== // CIRL_Protocol Implementation //============================================================================== template Protocol_data_t CIRL_Protocol::read(void) { // If nothing was received return an empty struct Protocol_data_t retdata = Protocol_data_t(); // Disable interrupts while accessing volatile data ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { // Check and get data if we have new. if (static_cast(this)->available()) { // Set last ISR to current time. // This is required to not trigger a timeout afterwards // and read corrupted data. This might happen // if the reading loop is too slow. static_cast(this)->mlastTime = micros(); // Save the protocol data retdata = static_cast(this)->getData(); // Reset reading static_cast(this)->resetReading(); } } // Return the new protocol information to the user return retdata; } ================================================ FILE: src/IRL_Receive.h ================================================ /* Copyright (c) 2014-2018 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once #ifdef ARDUINO #include // pinMode() #endif #ifdef DMBS_MODULE_BOARD #include "board_pins.h" #endif #ifdef DMBS_MODULE_FASTPIN #include "fastpin.h" #endif #ifdef DMBS_MODULE_PCINT #include "pcint.h" #endif //============================================================================== // IRL_Receive Class //============================================================================== template class CIRL_Receive { public: #ifdef ARDUINO // Attach the interrupt so IR signals are detected inline bool begin(uint8_t pin); inline bool end(uint8_t pin); #endif // Alternative template option template inline bool begin(void); template inline bool end(void); protected: // Interface that is required to be implemented //static inline void interrupt(void); //static constexpr uint8_t interruptMode = FALLING|RISING|CHANGE; }; //============================================================================== // CIRL_Receive Implementation //============================================================================== template template bool CIRL_Receive::begin(void) { #ifdef ARDUINO return begin(pin); #else // Set pin to INPUT_PULLUP FastPin p; p.setInput(); p.hi(); // If PinChangeInterrupt library is used, try to attach it if (digitalPinToPCINT(pin) != NOT_AN_INTERRUPT){ attachPCINT(digitalPinToPCINT(pin), T::interrupt, T::interruptMode); return true; } // Return an error if none of them work (pin has no Pin(Change)Interrupt) return false; #endif } #ifdef ARDUINO template bool CIRL_Receive::begin(uint8_t pin) { // Get pin ready for reading. pinMode(pin, INPUT_PULLUP); // Try to attach PinInterrupt first if (digitalPinToInterrupt(pin) != NOT_AN_INTERRUPT){ attachInterrupt(digitalPinToInterrupt(pin), T::interrupt, T::interruptMode); return true; } // If PinChangeInterrupt library is used, try to attach it #ifdef PCINT_VERSION else if (digitalPinToPCINT(pin) != NOT_AN_INTERRUPT){ attachPCINT(digitalPinToPCINT(pin), T::interrupt, T::interruptMode); return true; } #endif // Return an error if none of them work (pin has no Pin(Change)Interrupt) return false; } #endif template template bool CIRL_Receive::end(void) { #ifdef ARDUINO return end(pin); #else // Disable pullup. FastPin p; p.lo(); // If PinChangeInterrupt library is used, try to detach it if (digitalPinToPCINT(pin) != NOT_AN_INTERRUPT){ detachPCINT(digitalPinToPCINT(pin)); return true; } // Return an error if none of them work (pin has no Pin(Change)Interrupt) return false; #endif } #ifdef ARDUINO template bool CIRL_Receive::end(uint8_t pin) { // Disable pullup. pinMode(pin, INPUT); // Try to detach PinInterrupt first if (digitalPinToInterrupt(pin) != NOT_AN_INTERRUPT){ detachInterrupt(digitalPinToInterrupt(pin)); return true; } // If PinChangeInterrupt library is used, try to detach it #ifdef PCINT_VERSION else if (digitalPinToPCINT(pin) != NOT_AN_INTERRUPT){ detachPCINT(digitalPinToPCINT(pin)); return true; } #endif // Return an error if none of them work (pin has no Pin(Change)Interrupt) return false; } #endif ================================================ FILE: src/IRL_Time.h ================================================ /* Copyright (c) 2014-2018 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once #include "IRL_Platform.h" //============================================================================== // IRL_Time Class //============================================================================== template class CIRL_Time { public: // User API to access library data inline uint32_t timeout(void); inline uint32_t lastEvent(void); inline uint32_t nextEvent(void); // Interface that is required to be implemented //static constexpr uint32_t timespanEvent = VALUE; //static constexpr uint32_t limitTimeout = VALUE; protected: // Time mangement functions static inline uint16_t nextTime(void); // Time values for the last interrupt and the last valid protocol static uint32_t mlastTime; static volatile uint32_t mlastEvent; }; //============================================================================== // Static Data //============================================================================== // Protocol temporary data template uint32_t CIRL_Time::mlastTime = 0; template volatile uint32_t CIRL_Time::mlastEvent = 0; //============================================================================== // CIRL_Time Implementation //============================================================================== /* * Returns duration between last interrupt and current time. * This will safe the last interrupt time to the current time. */ template uint16_t CIRL_Time::nextTime(void){ // Save the duration between the last reading uint32_t time = micros(); uint32_t duration_32 = time - mlastTime; mlastTime = time; // Calculate 16 bit duration. On overflow sets duration to a clear timeout uint16_t duration = duration_32; if (duration_32 > 0xFFFF) { duration = 0xFFFF; } return duration; } /* * Return relativ time between last event time (in micros) */ template uint32_t CIRL_Time::timeout(void) { uint32_t timeout; ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { timeout = mlastEvent; } uint32_t time = micros(); timeout = time - timeout; return timeout; } /* * Return absolute last event time (in micros) */ template uint32_t CIRL_Time::lastEvent(void) { uint32_t time; ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { time = mlastEvent; } return time; } /* * Return when the next event can be expected. * Zero means at any time. * Attention! This value is a little bit too high in general. * Also for the first press it is even higher than it should. */ template uint32_t CIRL_Time::nextEvent(void) { auto time = timeout(); auto timespan = static_cast(this)->timespanEvent; if(time >= timespan) { return 0; } return timespan - time; } ================================================ FILE: src/IRLremote.cpp ================================================ /* Copyright (c) 2014-2018 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "IRLremote.h" //============================================================================== // Static Data //============================================================================== // Protocol temporary data volatile uint8_t CHashIR::count = 0; uint32_t CHashIR::hash = FNV_BASIS_32; volatile uint16_t CHashIR::lastDuration = 0xFFFF; ================================================ FILE: src/IRLremote.h ================================================ /* Copyright (c) 2014-2018 NicoHood See the readme for credit to other people. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Include guard #pragma once // IDE version check #if defined(ARDUINO) && ARDUINO < 10606 #error IRLremote requires Arduino IDE 1.6.6 or greater. Please update your IDE. #endif // Software version #define IRL_VERSION 202 // Delay_basic is only for avrs. With ARM sending is currently not possible // TODO implement sending #ifdef ARDUINO_ARCH_AVR #include #endif #include "IRL_Platform.h" // Include all protocol implementations #include "IRL_Nec.h" #include "IRL_NecAPI.h" #include "IRL_Panasonic.h" #include "IRL_Hash.h" // Include pre recorded IR codes from IR remotes #include "IRL_Keycodes.h"