Full Code of NicoHood/IRLremote for AI

master 0c7c61e5773b cached
30 files
228.6 KB
67.0k tokens
39 symbols
1 requests
Download .txt
Showing preview only (240K chars total). Download the full file or copy to clipboard to get everything.
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.

<a href="https://www.buymeacoffee.com/nicohood" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>

# 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
================================================
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<title>Interpreting Decoded IR Signals (v2.43)</title>
</head>
<body alink="#996600" background="Interpreting%20Decoded%20IR%20Signals%20(v2.43)-Dateien/bg.jpg" bgcolor="#ffffff" link="#3366cc" text="#000000" vlink="#666666">

<table width="750"><tbody><tr><td><center>
<script type="text/javascript"><!--
google_ad_client = "pub-2040680936936450";
/* 468x60, created 4/17/09 */
google_ad_slot = "7283198346";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript" src="Interpreting%20Decoded%20IR%20Signals%20%28v2.43%29-Dateien/show_ads.js">
</script>
</center>
</td></tr></tbody></table>
<p>

</p><blockquote>
<a href="#Introduction">Introduction</a><br><br>

<table>
<tbody><tr><td valign="top" width="140">
<a href="#48-NEC">48-NEC</a><br>
<a href="#48-NEC1">48-NEC1</a><br>
<a href="#48-NEC2">48-NEC2</a><br>
<a href="#AdNotam">AdNotam</a><br>
<a href="#AirAsync">AirAsync</a><br>
<a href="#AirB?-????">AirB?-????</a><br>
<a href="#Aiwa">Aiwa</a><br>
<a href="#AK">AK</a><br>
<a href="#Akai">Akai</a><br>
<a href="#Amino">Amino</a><br>
<a href="#Anthem">Anthem</a><br>
<a href="#Apple">Apple</a><br>
<a href="#Archer">Archer</a><br>
<a href="#Async">Async</a><br>
<a href="#Blaupunkt">Blaupunkt</a><br>
<a href="#Bose">Bose</a><br>
<a href="#CanalSat">CanalSat</a><br>
<a href="#Denon">Denon</a><br>
<a href="#Denon">Denon{1}</a><br>
<a href="#Denon">Denon{2}</a><br>
<a href="#Denon-K">Denon-K</a><br>
<a href="#Dgtec">Dgtec</a><br>
<a href="#DirecTV">DirecTV</a><br>
<a href="#Dishplayer">Dishplayer</a><br>
<a href="#Dish_Network">Dish_Network</a><br>
<a href="#Emerson">Emerson</a><br>
<a href="#F12">F12</a><br>
</td>

<td valign="top" width="144">
<a href="#Fujitsu">Fujitsu</a><br>
<a href="#Fujitsu-56">Fujitsu-56</a><br>
<a href="#G.I.%20Cable">G.I. Cable</a><br>
<a href="#G.I.%20Cable">G.I. Cable{1}</a><br>
<a href="#G.I.4DTV">G.I.4DTV</a><br>
<a href="#Grundig16">Grundig16</a><br>
<a href="#Grundig16">Grundig16-30</a><br>
<a href="#GXB">GXB</a><br>
<a href="#IODATAn">IODATA<i>n</i></a><br>
<a href="#IODATAn">IODATA<i>n</i>-<i>x</i>-<i>y</i></a><br>
<a href="#Jerrold">Jerrold</a><br>
<a href="#JVC">JVC</a><br>
<a href="#JVC">JVC{2}</a><br>
<a href="#JVC-48">JVC-48</a><br>
<a href="#JVC-56">JVC-56</a><br>
<a href="#Kaseikyo">Kaseikyo</a><br>
<a href="#Kaseikyo-???-???">Kaseikyo-???-???</a><br>
<a href="#Kaseikyo56">Kaseikyo56</a><br>
<a href="#Kaseikyo56-???-???">Kaseikyo56-???-???</a><br>
<a href="#Kathrein">Kathrein</a><br>
<a href="#Konka">Konka</a><br>
<a href="#Lumagen">Lumagen</a><br>
<a href="#Lutron">Lutron</a><br>
<a href="#Matsui">Matsui</a><br>
<a href="#MCE">MCE</a><br>
<a href="#Metz19">Metz19</a><br>
</td>

<td valign="top" width="142">
<a href="#Mitsubishi">Mitsubishi</a><br>
<a href="#Mitsubishi-K">Mitsubishi-K</a><br>
<a href="#NEC">NEC</a><br>
<a href="#NEC1">NEC1</a><br>
<a href="#NEC2">NEC2</a><br>
<a href="#NECx">NECx</a><br>
<a href="#NECx1">NECx1</a><br>
<a href="#NECx2">NECx2</a><br>
<a href="#Nokia">Nokia</a><br>
<a href="#Nokia12">Nokia12</a><br>
<a href="#Nokia32">Nokia32</a><br>
<a href="#NRC16">NRC16</a><br>
<a href="#NRC17">NRC17</a><br>
<a href="#OrtekMCE">OrtekMCE</a><br>
<a href="#Pace%20MSS">Pace MSS</a><br>
<a href="#Panasonic">Panasonic</a><br>
<a href="#Panasonic2">Panasonic2</a><br>
<a href="#Panasonic_Old">Panasonic_Old</a><br>
<a href="#PCTV">PCTV</a><br>
<a href="#pid-0001">pid-0001</a><br>
<a href="#pid-0003">pid-0003</a><br>
<a href="#pid-0004">pid-0004</a><br>
<a href="#pid-002A">pid-002A</a><br>
<a href="#pid-0083">pid-0083</a><br>
<a href="#Pioneer">Pioneer</a><br>
<a href="#Proton">Proton</a><br>
</td>

<td valign="top" width="131">
<a href="#RC5">RC5</a><br>
<a href="#RC5-7F">RC5-7F</a><br>
<a href="#RC5-7F-57">RC5-7F-57</a><br>
<a href="#RC5x">RC5x</a><br>
<a href="#RC5-?-??">RC5-?-??</a><br>
<a href="#RC6">RC6</a><br>
<a href="#RC6-6-20">RC6-6-20</a><br>
<a href="#RC6-?-??">RC6-?-??</a><br>
<a href="#RCA">RCA</a><br>
<a href="#RCA">RCA(Old)</a><br>
<a href="#RCA-38">RCA-38</a><br>
<a href="#RCA-38">RCA-38(Old)</a><br>
<a href="#RECS80">RECS80</a><br>
<a href="#Replay">Replay</a><br>
<a href="#Samsung20">Samsung20</a><br>
<a href="#Samsung36">Samsung36</a><br>
<a href="#Sampo">Sampo</a><br>
<a href="#ScAtl-6">ScAtl-6</a><br>
<a href="#Sejin-M-38">Sejin-<i>M</i>-38</a><br>
<a href="#Sejin-M-38">Sejin-<i>M</i>-56</a><br>
<a href="#Sharp">Sharp</a><br>
<a href="#Sharp">Sharp{1}</a><br>
<a href="#Sharp">Sharp{2}</a><br>
<a href="#SharpDVD">SharpDVD</a><br>
<a href="#SIM2">SIM2</a><br>
<a href="#Solidtek16">Solidtek16</a><br>
</td>

<td valign="top" width="130">
<a href="#Solidtek20">Solidtek20</a><br>
<a href="#Somfy">Somfy</a><br>
<a href="#Sony8">Sony8</a><br>
<a href="#Sony12">Sony12</a><br>
<a href="#Sony15">Sony15</a><br>
<a href="#Sony20">Sony20</a><br>
<a href="#StreamZap">StreamZap</a><br>
<a href="#Sunfire">Sunfire</a><br>
<a href="#TDC-38">TDC-38</a><br>
<a href="#TDC-38">TDC-56</a><br>
<a href="#Teac-K">Teac-K</a><br>
<a href="#Thomson">Thomson</a><br>
<a href="#Thomson7">Thomson7</a><br>
<a href="#Tivo">Tivo</a><br>
<a href="#Velleman">Velleman</a><br>
<a href="#Velodyne">Velodyne</a><br>
<a href="#Viewstar">Viewstar</a><br>
<a href="#X10">X10</a><br>
<a href="#X10">X10.<i>n</i></a><br>
<a href="#XMP">XMP</a><br>
<a href="#XMP">XMP-1</a><br>
<a href="#XMP">XMP-2</a><br>
<a href="#XX">XX</a><br>
<a href="#Zaptor">Zaptor</a><br>
<a href="#Zenith">Zenith</a><br>
<a href="#?1-??-??-??">?1-??-??-??</a><br>
</td></tr></tbody></table>

<h2><a name="Introduction">Introduction</a></h2>
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.
<p>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.</p>
<h3>Decode problems</h3>
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.
<h3><a name="spurious">Spurious decodes and non-robust protocols</a></h3>
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.
  <p>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.</p>
<h3><a name="jp1">EFC, JP1, KeyMoves, Upgrades, etc.</a></h3>
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.
<p>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.</p>
<p>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.</p>
<h3><a name="toggle">Toggle bits</a></h3>
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.
<p>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.</p>
<p>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.</p>
<p>With OneForAll type remotes, using an upgrade or KeyMove will solve that problem.</p>
<p>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.</p>

<h3><a name="repeat">Repeat frames and dittos</a></h3>
<p>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.</p>
<p>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".</p>
<p>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".</p>

<h3><a name="MiniComboExecutors">Mini Combos</a></h3>
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.
<p>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).</p>

<h3><a name="ReadingIRP">Brief and incomplete guide to reading IRP</a></h3>

<b>General</b>: {carrier frequency, time unit, sequencing rule} 
Mitsubishi:<b>{32.6k,300}</b>&lt;1,-3|1,-7&gt;(D:8,F:8,1,-80)+ <br>
<i>Carrier Frequency</i>: Hz; e.g. 38.3k; default is 0k--no  modulation<br>
<i>Time Unit</i>: Integer that can represent durations.  Suffix u (default) is microseconds, p denotes number of pulses of the carrier.<br>
<i>Sequencing Rule</i>:  lsb|msb; lsb (default) means the least significant bit of a binary form is sent first. <br>
<b>BitSpec</b>: Rule for the translating bit sequences to duration 
sequences.  &lt;ZeroPulseSeq|OnePulseSeq|TwoPulseSeq....&gt;.  Most IR 
protocols use only &lt;ZeroPulseSeq|OnePulseSeq&gt;, and the sequence is
 simply OnDuration,OffDuration.    Example: NEC uses  &lt;1,-1|1,-3&gt;<br>

<b>Bitfield</b>:  D:NumberOfBits:StartingBit.  E.g. if D=71= 01000111, D:2:5 means x<b>10</b>xxxxx.
  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.<br>

<b>IRStream</b>: 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}&lt;1,-1|1,-3&gt;<b>(16,-8,D:8,S:8,F:8,~F:8,1,-78)+</b> <br>

<b>Durations</b>: 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.<br>

<b>Extent</b>: 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,<b>^114m</b>)+ <br>

<b>Expressions</b>:   names, numbers and bitfields connected by standard symbols for arithmetic and logical 
operations.  Enclosed in parentheses. Panasonic: {37k,432}&lt;1,-1|1,-3&gt;(8,-4,2:8,32:8,D:8,S:8,F:8,<b>(D^S^F)</b>:8,1,-173)+ 
 <br>  

<b>Permitted operators in decreasing order of precedence:</b><br>
<code>
      unary    (negation)<br>
      **  (exponentiation)<br>
      * /, %  (multiplication, integer division, modulo) (* is also used in IRStreams)<br>
      +,    (addition, subtraction  (+ is also used in IRStreams)<br>
      &amp;       (bitwise AND)<br>
      ^        (exclusive OR)  (also used in extents)<br>
      |        (OR)<br>
      ~     (complement) is permitted in Bitfields</code><br>

<b>Definitions</b>:  expressions separated by commas, enclosed in curly brackets. 
GI Cable: {38.7k,490}&lt;1,-4.5|1,-9&gt;(18,-9,F:8,D:4,C:4,1,-84,(18,-4.5,1,-178)*) 
<b>{C = -(D + F:4 + F:4:4)}</b> <br>
<b>Assignments</b>:  For example T=T+1, which can be used to describe the RC-5 toggle bit.<br>
<b>Variations</b>:  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]<br>
<a href="http://www.hifi-remote.com/wiki/index.php?title=IRP_Notation"> The IRP specification by Graham Dixon</a><br>
<a href="http://www.hifi-remote.com/forums/dload.php?action=file&amp;file_id=6996"> Practical explanation of IR signals and IRP by Vicky Getz</a>

    
<h2><a name="48-NEC">48-NEC</a></h2>
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.

<h2><a name="48-NEC1">48-NEC1</a></h2>
IRP notation: {564}&lt;1,-1|1,-3&gt;(16,-8,D:8,S:8,F:8,~F:8,E:8,~E:8,1,-??,(16,-4,1,-??)*) 
<br>
EFC translation: LSB
<p>This protocol signals repeats by the use of <a href="#repeat">dittos</a>.</p> 

<h2><a name="48-NEC2">48-NEC2</a></h2>
IRP notation: {564}&lt;1,-1|1,-3&gt;(16,-8,D:8,S:8,F:8,~F:8,E:8,~E:8,1,-??)+ 
<br>
EFC translation: LSB

<h2><a name="AdNotam">AdNotam</a></h2>
IRP notation: {35.7Khz,895,msb}&lt;1,-1|1,-3&gt;(0:1,1:1,D:6,F:6,^114m)+ 
<br>
<p>Very similar to RC5, except AdNotam uses two start bits, and no toggle bit.    


</p><h2><a name="AirAsync">AirAsync</a></h2>
IRP notation: {37.7Khz,840}&lt;1|-1&gt;( 1,B:8,-2 ... )
<p>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
AirAsync<i>n</i>-xx.yy. ...
where <i>n</i> is the number of bytes and xx, yy, ... are the byte values in hexadecimal notation.  
</p>

<h2><a name="AirB?-????">AirB?-????</a></h2>
<p>This is not a robust protocol, so <a href="#spurious">spurious decodes</a> are likely.
If you see this decode from something other than an IR keyboard, you should probably ignore it.</p>

<h2><a name="Aiwa">Aiwa</a></h2>
UEI protocol: 005E or 009E
<br>
IRP notation: {38k,550}&lt;1,-1|1,-3&gt;(16,-8,D:8,S:5,~D:8,~S:5,F:8,~F:8,1,-42,(16,-8,1,-165)*) 
<br>
EFC translation: LSB
<p>This protocol signals repeats by the use of <a href="#repeat">dittos</a>.</p>
<p>The EFC numbering varies among the KM and RM versions of Aiwa.  Using OBC numbers is less confusing.</p>
<p>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.</p>

<h2><a name="AK">AK</a></h2>
Documentation not written yet.

<h2><a name="Akai">Akai</a></h2>
UEI protocol: 000D
<br>
IRP notation: {38k,289}&lt;1,-2.6|1,-6.3&gt;(D:3,F:7,1,^25.3m)+ <br>
EFC translation: LSB comp prefixed with last device bit
<p>This is not a robust protocol, so <a href="#spurious">spurious decodes</a> are likely.</p>
<p>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:</p>
<ul>
<li>Decoded device 0 or 4 --&gt; KM device 3</li>
<li>Decoded device 1 or 5 --&gt; KM device 2</li>
<li>Decoded device 2 or 6 --&gt; KM device 1</li>
<li>Decoded device 3 or 7 --&gt; KM device 0</li>
</ul>
<p>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.</p>

<h2><a name="Amino">Amino</a></h2>
UEI protocol: 019C
<br>
IRP notation: {56.0k,268,msb}&lt;-1,1|1,-1&gt;[T=1] [T=0] (7,-6,3,D:4,1:1,T:1,1:2,0:8,F:8,15:4,C:4,-79m)+<br>
-----Variant: {36.0k,268,msb}&lt;-1,1|1,-1&gt;[T=1] [T=0] (7,-6,3,D:4,1:1,T:1,1:2,0:8,F:8,15:4,C:4,-79m)+
<br>{C =(D:4+4*T+9+F:4+F:4:4+15)&amp;15}  [the arithmetic sum of the first 7 nibbles mod 15]
<br>T=1 for the first frame and T=0 for all repeat frames.  
<br>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.
<br>
EFC translation: MSB

<h2><a name="Anthem">Anthem</a></h2>
UEI protocol: 0123 <br>
IRP notation: {38.0k,605}&lt;1,-1|1,-3&gt;((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}
<br>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.

<h2><a name="Apple">Apple</a></h2>
UEI protocol: 01E0
<br>

IRP notation: {38.4k,564}&lt;1,-1|1,-3&gt;(16,-8,D:8,S:8,C:1,F:7,I:8,1,-78,(16,-4,1,-173)*)<br>
C=1 if the number of 1 bits in the fields F and I is even.  I is the remote ID.
<p> Apple uses the same framing as NEC1, with D=238 in normal use, 224 while pairing.  S=135 </p>

<h2><a name="Archer">Archer</a></h2>
IRP notation: {0k,12}&lt;1,-3.3m|1,-4.7m&gt;(F:5,1,-9.7m)+ <br>
EFC translation: 5-bit LSB
<p>This is not a robust protocol, so <a href="#spurious">spurious decodes</a> are likely.</p>

<h2><a name="Async">Async</a></h2>
<p>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
Async<i>n</i>:min-max:aa.bb...yy.zz
where <i>n</i> 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.  
</p>

<h2><a name="Blaupunkt">Blaupunkt</a></h2>
IRP notation: {30.3k,528}&lt;-1,1|1,-1&gt;(1,-5,1023:10,-39,1,-5,1:1,F:7,D:2,-230) 

<h2><a name="Bose">Bose</a></h2>
IRP notation: {500,msb}&lt;1,-1|1,-3&gt;(2,-3,F:8,~F:8,1,-???)+ <br>
EFC translation: MSB
The decode is intended to be consistent with the posted KM file:
<a href="http://www.hifi-remote.com/forums/dload.php?action=file&amp;file_id=974">Bose-Wave-Radio-KM.txt</a>
and PB file:
<a href="http://www.hifi-remote.com/forums/dload.php?action=file&amp;file_id=1389">Bose_Wave_Radio-PB.txt</a>

<h2><a name="CanalSat">CanalSat</a></h2>
UEI protocol: 018C
<br>
IRP notation: {55.5k,250,msb}&lt;-1,1|1,-1&gt;(1:1,D:7,S:6,T:1,0:1,F:7,-89m)+ 
<br>
EFC translation: 7-bit MSB.
<p>The <a href="#repeat">repeat frames</a> 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.</p>

<h2><a name="Denon">Denon, Denon{1} and Denon{2}</a></h2>
IRP notation: {38k,264}&lt;1,-3|1,-7&gt;(D:5,F:8,0:2,1,-165,D:5,~F:8,3:2,1,-165)+ 
<br>
EFC translation: LSB
<p>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 <a href="#spurious">spurious</a>.</p>

<h2><a name="Denon-K">Denon-K</a></h2>
UEI protocol: 00CD
<br>
IRP notation: {37k,432}&lt;1,-1,1,-3&gt;(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)+ 
<br>
EFC translation: LSB comp
<p>Denon-K is the member of the Kaseikyo family with OEM_code1=84 and OEM_code2=50.</p>
<p>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.</p>

<h2><a name="Dgtec">Dgtec</a></h2>
UEI protocol: 016A
<br>
IRP notation: {38k,560}&lt;1,-1|1,-3&gt;(16,-8,D:8,F:8,~F:8,1,^108m,(16,-4,1,^108m)+) 
<br>
EFC translation: LSB comp
<p>This protocol signals repeats by the use of <a href="#repeat">dittos</a>.</p>

<h2><a name="DirecTV">DirecTV</a></h2>
IRP notation: {38k,600,msb}&lt;1,-1|1,-2|2,-1|2,-2&gt;(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)} <br>
EFC translation: MSB
<p>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:</p>
<ul>
<li>Parm=0 : 40k, -15
</li><li>Parm=1 : 40k, -50
</li><li>Parm=2 : 38k, -15
</li><li>Parm=3 : 38k, -50
</li><li>Parm=4 : 57k, -15
</li><li>Parm=5 : 57k, -50
</li></ul> 
<p>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.</p>
<p>This protocol was called Russound in versions of DecodeIR earlier than 2.40.</p>

<h2><a name="Dishplayer">Dishplayer</a></h2>
UEI protocol: 010F
<br>
IRP notation: {38.4k,535,msb}&lt;1,-5|1,-3&gt;(1,-11,(F:6,U:5,D:2,1,-11)+) <br>
EFC translation: Not available in this version of DecodeIr
<p>This is not a robust protocol, so <a href="#spurious">spurious decodes</a> are likely.</p>

<h2><a name="Dish_Network">Dish_Network</a></h2>
UEI protocol: 0002 <br>IRP notation: {57.6k,400}&lt;1,-7|1,-4&gt;(1,-15,(F:-6,U:5,D:5,1,-15)+)
<br>
EFC translation: MSB comp 6 function bits followed by LSB comp low 2 unit bits.
<p>This is not a robust protocol, so <a href="#spurious">spurious decodes</a> are likely.</p>
<p>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.</p>
<p>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.</p>

<h2><a name="EchoStar">EchoStar</a></h2>
UEI protocol: 0182
<br> As of 2.42 DecodeIR shows this as RC5-7F

<h2><a name="Emerson">Emerson</a></h2>
UEI protocol: 0065
<br>
IRP notation: {36.7k,872}&lt;1,-1|1,-3&gt;(4,-4,D:6,F:6,~D:6,~F:6,1,-39)+ <br>
EFC translation: 6-bit LSB comp with 2-bit mini-combo
<p>Lists three different EFCs because this protocol is a <a href="#mini%20combo">mini combo</a>.</p>

<h2><a name="F12">F12</a></h2>
UEI protocol: 001A
<br>
IRP notation: (Toshiba specification) K=(D:3,H:1,A:1,B:2,F:6)
{37.9k,422}&lt;1,-3|3,-1&gt;(K,-34,K) for A=1 or B=1 <br>
{37.9k,422}&lt;1,-3|3,-1&gt;(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. <p>
IRP notation: (JP1) K=(D:3,H:1,F:8)
{37.9k,422}&lt;1,-3|3,-1&gt;(K,-34,K) for H=0. <br>
{37.9k,422}&lt;1,-3|3,-1&gt;(K,-34,K,-88,K,-34,K)+ for H=1. <br>
A and B are subsumed into F, and the value of H is computed in the executor. H=A^B.
<br>EFC translation: lsb, but not computed in DecodeIR.
<br> 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.

</p><h2><a name="Fujitsu">Fujitsu</a></h2>
UEI protocol: 00F8
<br>
IRP notation: {37k,432}&lt;1,-1,1,-3&gt;(8,-4,20:8,99:8,X:4,E:4,D:8,S:8,F:8,1,-110)+ 
<br>
EFC translation: LSB comp
<p>Fujitsu is the member of the Kaseikyo family with OEM_code1=20 and OEM_code2=99.</p>
<p>There is no check byte, so the risk of an incorrectly decoded OBC is much higher than in
other Kaseikyo protocols.</p>
  <p>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.</p>

<h2><a name="Fujitsu-56">Fujitsu-56</a></h2>
IRP notation: {37k,432}&lt;1,-1,1,-3&gt;(8,-4,20:8,99:8,H:4,E:4,D:8,S:8,X:8,F:8,1,-110)+ 

<h2><a name="G.I. Cable">G.I. Cable and G.I. Cable{1}</a></h2>
UEI protocol: 00C4
<br>
IRP notation: {38.7k,490}&lt;1,-4.5|1,-9&gt;(18,-9,F:8,D:4,C:4,1,-84,(18,-4.5,1,-178)*) 
{C = -(D + F:4 + F:4:4)} <br>
EFC translation: LSB
<p>This protocol signals repeats by the use of <a href="#repeat">dittos</a>.
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 <a href="#jp1">KeyMove, Upgrade</a> or cleaned
up version.</p>

<h2><a name="G.I.4DTV">G.I.4DTV</a></h2>
UEI protocol: 00A4
<br>
IRP notation: {37.3k,992}&lt;1,-1|1,-3&gt;(5,-2,F:6,D:2,C:4,1,-60)+ <br>
EFC translation: NONE
<p>This is a moderately robust protocol, but <a href="#spurious">spurious decodes</a> are still possible.</p>
<p>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.</p>

<h2><a name="Grundig16">Grundig16 and Grundig16-30</a></h2>
UEI protocol:  Grundig16 0112, Grundig16-30 00AB
<br>IRP notation for Grundig16: {35.7k,578,msb}&lt;-4,2|-3,1,-1,1|-2,1,-2,1|-1,1,-3,1&gt;
(806u,-2960u,1346u,T:1,F:8,D:7,-100)+
<br>IRP notation for Grundig16-30: {30.3k,578,msb}&lt;-4,2|-3,1,-1,1|-2,1,-2,1|-1,1,-3,1&gt;
(806u,-2960u,1346u,T:1,F:8,D:7,-100)+ 
 <br>
EFC translation:  MSB but with bit pairs translated data-&gt;hex by 00-&gt;00, 01-&gt;11, 10-&gt;01, 11-&gt;
10 and off by one position.
<p>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.</p>

<h2><a name="GXB">GXB</a></h2>
IRP notation: {38.3k,520,msb}&lt;1,-3|3,-1&gt;(1,-1,D:4,F:8,P:1,1,^???)+ 
<p>Decoder for a nonstandard Xbox remote.</p>

<h2><a name="IODATAn">IODATA</a><i>n</i> and IODATA<i>n</i>-<i>x</i>-<i>y</i></h2>
UEI protocol: not known.
<br>
IRP notation: {38k,550}&lt;1,-1|1,-3&gt;(16,-8,x:7,D:7,S:7,y:7,F:8,C:4,1,^108m)+ 
{n = F:4 ^ F:4:4 ^ C:4} <br>
EFC translation: LSB
<p>This is potentially a class of protocols distinguished by values of <i>n</i>, <i>x</i> and <i>y</i> with 
    <i>n</i> = 0..15 and <i>x</i>, <i>y</i> = 0..127.  If <i>x</i> and <i>y</i> are both zero, they are omitted.  The only known example is IODATA1.</p>

<h2><a name="Jerrold">Jerrold</a></h2>
UEI protocol: 0006
<br>
IRP notation: {0k,44}&lt;1,-7.5m|1,-11.5m&gt;(F:5,1,-23.5m)+ 
<p>This is not a robust protocol, so <a href="#spurious">spurious decodes</a> are likely.</p>

<h2><a name="JVC">JVC and JVC{2}</a></h2>
UEI protocol: 0034
<br>
IRP notation: {38k,525}&lt;1,-1|1,-3&gt;(16,-8,(D:8,F:8,1,-45)+) <br>
EFC translation: LSB comp
<p>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 <a href="#spurious">spurious decodes</a> are likely.  It
is also very similar in structure and timing to <a href="#Mitsubishi">Mitsubishi</a> 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.</p>

<h2><a name="JVC-48">JVC-48</a></h2>
UEI protocol: 001F or 00C9 or 00CD
<br>
IRP notation: {37k,432}&lt;1,-1|1,-3&gt;(8,-4,3:8,1:8,D:8,S:8,F:8,(D^S^F):8,1,-173)+ 
<br>
EFC translation: LSB comp
<p>JVC-48 is the member of the Kaseikyo family with OEM_code1=3 and OEM_code2=31.</p>
<p>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.</p>

<h2><a name="JVC-56">JVC-56</a></h2>
IRP notation: {37k,432}&lt;1,-1|1,-3&gt;(8,-4,3:8,1:8,D:8,S:8,X:8,F:8,(D^S^X^F):8,1,-173)+
 
<h2><a name="Kaseikyo">Kaseikyo</a></h2>
<p>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.</p>
<p>
  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). </p>
<p>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.</p>

<h2><a name="Kaseikyo-???-???">Kaseikyo-???-???</a></h2>
IRP notation: 
{37k,432}&lt;1,-1|1,-3&gt;(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}
<br>
EFC translation: LSB comp
<p>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.</p>
<p>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.</p>

<h2><a name="Kaseikyo56">Kaseikyo56</a></h2>
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.

<h2><a name="Kaseikyo56-???-???">Kaseikyo56-???-???</a></h2>
IRP notation: {37k,432}&lt;1,-1|1,-3&gt;(8,-4,M:8,N:8,H:4,D:4,S:8,X:8,F:8,E:4,C:4,1,-173)+ 

<h2><a name="Kathrein">Kathrein</a></h2>
UEI protocol: 0066
<br>IRP notation: {38k,540}&lt;1,-1|1,-3&gt;(16,-8,D:4,~D:4,F:8,~F:8,1,^105m,(16,-8,F:8,1,^105m)+)
<br>EFC translation: LSB comp
<p>This protocol signals repeats by the use of <a href="#repeat">dittos</a>.  It is unusual in that the ditto 
    frame carries part of the signal data, specifically the function code (OBC) but not the device code.</p>

<h2><a name="Konka">Konka</a></h2>
UEI protocol: 019B
<br>
IRP notation: {38k,500,msb}&lt;1,-3|1,-5&gt;(6,-6,D:8,F:8,1,-8,1,-46)+ <br>
EFC translation: MSB

<h2><a name="Lumagen">Lumagen</a></h2>
IRP notation: {38.4k,416,msb}&lt;1,-6|1,-12&gt;(D:4,C:1,F:7,1,-26)+ {C = odd parity 
for F} <br>
EFC translation: MSB prepended with C bit.
<p>This is a moderately robust protocol, but <a href="#spurious">spurious decodes</a> are still possible.</p>

<h2><a name="Lutron">Lutron</a></h2>
IRP notation: {40k,2300,msb}&lt;-1|1&gt;(255:8,X:24,0:4)+ <br>
EFC translation: MSB of decoded signal.
<p>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.</p>

<h2><a name="Matsui">Matsui</a></h2>
IRP notation: {38K,525}&lt;1,-1|1,-3&gt;(D:3,F:7,1,^30.5m)+ <br>
EFC translation: Not available in this version of DecodeIr
<p>This is not a robust protocol, so <a href="#spurious">spurious decodes</a> are likely.</p>

<h2><a name="MCE">MCE (RC6-6-32)</a></h2>
IRP notation: {36k,444,msb}&lt;-1,1|1,-1&gt;(6,-2,1:1,6:3,-2,2,OEM1:8,OEM2:8,T:1,D:7,F:8,-???)+
<p>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.</p>
<p>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.</p>
<p>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</p>
<h2><a name="Metz19">Metz19</a></h2>
IRP notation: (37.9K,106,msb)&lt;4,-9|4,-16&gt;(8,-22,T:1,D:3,~D:3,F:6,~F:6,4,-125m)+ <br>
The toggle bit T is inverted each time a new button press occurs.

<h2><a name="Mitsubishi">Mitsubishi</a></h2>
UEI protocol: 0014
<br>
IRP notation: {32.6k,300}&lt;1,-3|1,-7&gt;(D:8,F:8,1,-80)+ <br>
EFC translation: LSB comp
<p>This is not a robust protocol, so <a href="#spurious">spurious decodes</a> are likely.  It
is also very similar in structure and timing to <a href="#JVC">JVC{2}</a> 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.</p>

<h2><a name="Mitsubishi-K">Mitsubishi-K</a></h2>
IRP notation: {37k,432}&lt;1,-1|1,-3&gt;(8,-4,35:8,203:8,X:4,D:8,S:8,F:8,T:4,1,-100)+ 
<br>
EFC translation: not available yet
<p>Mitsubishi-K is the member of the Kaseikyo family with OEM_code1=35 and OEM_code2=203.</p>

<h2><a name="NEC">NEC</a></h2>
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.
<h3><a name="NEC12difference">Difference between NEC1 and NEC2</a></h3>
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.

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

<h2><a name="NEC1">NEC1</a></h2>
IRP notation: {38.4k,564}&lt;1,-1|1,-3&gt;(16,-8,D:8,S:8,F:8,~F:8,1,-78,(16,-4,1,-173)*) 
<br>
EFC translation: LSB comp
<p>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.</p>

<h2><a name="NEC2">NEC2</a></h2>
IRP notation: {38.4k,564}&lt;1,-1|1,-3&gt;(16,-8,D:8,S:8,F:8,~F:8,1,-78)+ <br>
EFC translation: LSB comp
<p>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.</p>

<h2><a name="NECx">NECx</a></h2>
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.

<h2><a name="NECx1">NECx1</a></h2>
IRP notation: {38.4k,564}&lt;1,-1|1,-3&gt;(8,-8,D:8,S:8,F:8,~F8,1,^108m,(8,-8,D:1,1,^108m)*) <br>
EFC translation: LSB comp
<br>  Most, but not all NECx1 signals have S=D

<h2><a name="NECx2">NECx2</a></h2>
IRP notation: {38.4k,564}&lt;1,-1|1,-3&gt;(8,-8,D:8,S:8,F:8,~F8,1,^108m)+ <br>
EFC translation: LSB comp
<br>  Most, but not all  NECx2 signals have S=D

<h2><a name="Nokia">Nokia</a></h2>
IRP notation: {36k,msb}&lt;164,-276|164,-445|164,-614|164,-783&gt;(412,-276,D:8,S:8,F:8,164,-???)+ 
<br>
EFC translation: MSB

<h2><a name="Nokia12">Nokia12</a></h2>
IRP notation: {36k,msb}&lt;164,-276|164,-445|164,-614|164,-783&gt;(412,-276,D:4,F:8,164,-???)+ 
<br>
EFC translation: MSB

<h2><a name="Nokia32">Nokia32</a></h2>
UEI protocol: 0173
<br>
IRP notation: {36k,msb}&lt;164,-276|164,-445|164,-614|164,-783&gt;(412,-276,D:8,S:8,X:8,F:8,164,^100m)+ 
<br>
EFC translation: MSB

<h2><a name="NRC16">NRC16</a></h2>
Documentation not written yet.

<h2><a name="NRC17">NRC17</a></h2>
UEI protocol: 00BD

<h2><a name="OrtekMCE">OrtekMCE</a></h2>
UEI protocol: not known.
<br>
IRP notation: {38.6k,480}&lt;1,-1|-1,1&gt;(4,-1,D:5,P:2,F:6,C:4,-48m)+<br>
EFC translation: 6-bit LSB comp
<p>The <a href="#repeat">repeat frames</a> 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.</p>

<h2><a name="Pace MSS">Pace MSS</a></h2>
IRP notation: {38k,630,msb}&lt;1,-7|1,-11&gt;(1,-5,1,-5,T:1,D:1,F:8,1,^120m)+ 
<br>
EFC translation: Not available in this version of DecodeIr
<p>This is a moderately robust protocol, but <a href="#spurious">spurious decodes</a> are still possible.</p>

<h2><a name="Panasonic">Panasonic</a></h2>
UEI protocol: 001F or 00C9 or 00CD
<br>
IRP notation: {37k,432}&lt;1,-1|1,-3&gt;(8,-4,2:8,32:8,D:8,S:8,F:8,(D^S^F):8,1,-173)+ 
<br>
EFC translation: LSB comp
<p>Panasonic protocol is the most commonly seen member of the Kaseikyo family</p>
  <p>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.</p>

<h2><a name="Panasonic2">Panasonic2</a></h2>
IRP notation: {37k,432}&lt;1,-1|1,-3&gt;(8,-4,2:8,32:8,D:8,S:8,X:8,F:8,(D^S^X^F):8,1,-173)+ 

<h2><a name="Panasonic_Old">Panasonic_Old</a></h2>
UEI protocol: 0000
<br>
IRP notation: {57.6k,833}&lt;1,-1|1,-3&gt;(4,-4,D:5,F:6,~D:5,~F:6,1,-???)+ <br>
EFC translation: 6-bit LSB comp with 2-bit mini-combo
<p>Lists three different EFCs because this protocol is a <a href="#mini%20combo">mini combo</a>.</p>

<h2><a name="PCTV">PCTV</a></h2>
IRP notation: {38.4k,832}&lt;0,-1|1,-0&gt;(2,-8,1,D:8,F:8,2,-???) 

<h2><a name="pid-0001">pid-0001</a></h2>
UEI protocol: 0001
<br>IRP notation:  {0k,msb}&lt;24,-9314|24,-13486&gt;(24,-21148,(F:5,1,-28m)+)
<br>EFC translation: 5-bit MSB comp
<p>As of version 8.31 KM has seriously wrong OBC translation for pid-0001, so use only EFC's with KM.</p>

<h2><a name="pid-0003">pid-0003</a></h2>
UEI protocol: 0003
<br>IRP notation:  {40.2k,389}&lt;2,-2|3,-1&gt;(F:8,~F:8,^102k)+
<br>EFC translation: LSB

<h2><a name="pid-0004">pid-0004</a></h2>
UEI protocol: 0004
<br>IRP notation:  {0k,msb}&lt;12,-130|12,-372&gt;(F:6,12,-27k)+
<br>EFC translation: 6-bit MSB comp

<h2><a name="pid-002A">pid-002A</a></h2>
UEI protocol: 002A
<br>IRP notation: {0k,10}&lt;1,-5|1,-15&gt;(1,-25, D:5,F:6, 1,-25,1,120m)+
<br>EFC translation: 6-bit LSB comp
<br> Used primarily in Barco remotes.
<p>This is a moderately robust protocol, but <a href="#spurious">spurious decodes</a> are still possible.</p>

<h2><a name="pid-0083">pid-0083</a></h2>
UEI protocol: 0083
<br>EFC translation: 5-bit MSB comp
<br>IRP notation: {42.3K, 3000}&lt;1,-3,1,-7|1,-7,1,-3&gt;(F:5,1,-27)+
<p>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.</p>
<p>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.</p>

<h2><a name="Pioneer">Pioneer</a></h2>
IRP notation: {40k,564}&lt;1,-1|1,-3&gt;(16,-8,D:8,S:8,F:8,~F:8,1,-78)+ <br>
EFC translation: LSB comp
<p>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.</p>
  <p>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.</p>
<p>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.</p>

<h2><a name="Proton">Proton</a></h2>
UEI protocol: 005C
<br>
IRP notation: {38k,500}&lt;1,-1|1,-3&gt;(16,-8,D:8,1,-8,F:8,1,^63m)+ <br>
EFC translation: LSB comp
<p>This is not a robust protocol, so <a href="#spurious">spurious decodes</a> are likely.</p>

<h2><a name="RC5">RC5</a></h2>
UEI protocol: 00E8
<br>
IRP notation: {36k,msb,889}&lt;1,-1|-1,1&gt;(1:1,~F:1:6,T:1,D:5,F:6,^114m)+ <br>
EFC translation: 6-bit MSB comp with 2-bit mini-combo
<p>Lists three different EFCs because this protocol is a <a href="#mini%20combo">mini combo</a>.</p>
  <p>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.</p>


<h2><a name="RC5-7F">RC5-7F</a></h2>
UEI protocol: 0182
<br>
IRP notation: {36k,msb,889}&lt;1,-1|-1,1&gt;(1:1, D:1:5,T:1,D:5,F:7,^114m)+ <br>
EFC translation: 7-bit MSB comp

<h2><a name="RC5-7F-57">RC5-7F-57</a></h2>
UEI protocol: 0182
<br>
IRP notation: {57k,msb,889}&lt;1,-1|-1,1&gt;(1:1, D:1:5,T:1,D:5,F:7,^114m)+ <br>
EFC translation: 7-bit MSB comp

<h2><a name="RC5x">RC5x</a></h2>
UEI protocol: 00F2
<br>
IRP notation: {36k,msb,889}&lt;1,-1|-1,1&gt;(1:1,~S:1:6,T:1,D:5,-4,S:6,F:6,^114m)+ 
<br>
EFC translation: NONE
<p>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.</p>
<p>In the functions sheet in KM you must put the subdevice number in the byte2 column, which KM calls 
    "unit code".</p>
  <p>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.</p>

<h2><a name="RC5-?-??">RC5-?-??</a></h2>
Just ignore this decode.  It is almost certainly <a href="#spurious">spurious</a>.  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.

<h2><a name="RC6">RC6</a></h2>
UEI protocol: 0058
<br>IRP notation: {36k,444,msb}&lt;-1,1|1,-1&gt;(6,-2,1:1,0:3,&lt;-2,2|2,-2&gt;(T:1),D:8,F:8,^107m)+
<br>EFC translation: MSB
<p>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"</p>

<h2><a name="RC6-6-20">RC6-6-20</a></h2>
IRP notation: {36k,444,msb}&lt;-1,1|1,-1&gt;(6,-2,1:1,6:3,&lt;-2,2|2,-2&gt;(T:1),D:8,S:4,F:8,-???)+
<br>EFC translation: MSB
<p>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).</p>

<h2><a name="RC6-?-??">RC6-?-??</a></h2>
IRP notation: {36k,444,msb}&lt;-1,1|1,-1&gt;(6,-2,1:1,M:3,&lt;-2,2|2,-2&gt;(T:1),???:??)+
  <p>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.</p>
<p>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.</p>

<h2><a name="RCA">RCA and RCA(Old)</a></h2>
UEI protocols: 00AF (RCA), 002D(RCA(Old)) and 0114 (RCA Combo)
<br>IRP notation for RCA: {58k,460,msb}&lt;1,-2|1,-4&gt;(8,-8,D:4,F:8,~D:4,~F:8,1,-16)+
<br>IRP notation for RCA(Old): {58k,460,msb}&lt;1,-2|1,-4&gt;(32,(8,-8,D:4,F:8,~D:4,~F:8,2,-16)+)
<br>EFC translation: MSB
<p>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.</p>

<h2><a name="RCA-38">RCA-38 and RCA-38(Old)</a></h2>
UEI protocol: not known
<br>IRP notation for RCA-38: {38.7k,460,msb}&lt;1,-2|1,-4&gt;(8,-8,D:4,F:8,~D:4,~F:8,1,-16)+
<br>IRP notation for RCA-38(Old): {38.7k,460,msb}&lt;1,-2|1,-4&gt;(32,(8,-8,D:4,F:8,~D:4,~F:8,2,-16)+)
<br>EFC translation: MSB
<p>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.</p>

<h2><a name="RECS80">RECS80</a></h2>
UEI protocol: 0045, 0068, 0090 or ???
<br>IRP notation for 0045: {38k,158,msb}&lt;1,-31|1,-47&gt;(1:1,T:1,D:3,F:6,1,-45m)+
<br>IRP notation for 0068: {33.3k,180,msb}&lt;1,-31|1,-47&gt;(1:1,T:1,D:3,F:6,1,^138m)+
<br>EFC translation: 6-bit MSB comp
<p>RECS80 is a family of related protocols with the same structure, but different timing.  See also
Velleman </p>
<p>These are moderately non robust protocols, so <a href="#spurious">spurious decodes</a> are possible.</p>
<p>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).</p>
<p>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.</p>
<p>For 0045,</p>
<ul>
<li>frequency should be between 37000 and 39000</li>
<li>first timing number between 100 and 200</li>
<li>second timing number between 4500 and 5500</li>
<li>third timing number between 6800 and 8300</li>
</ul>
<p>For 0068,</p>
<ul>
<li>frequency should be between 32300 and 34300</li>
<li>first timing number between 130 and 250</li>
<li>second timing number between 5100 and 6300</li>
<li>third timing number between 7700 and 9500</li>
</ul>
<p>For 0090,</p>
<ul>
<li>frequency should be 0</li>
<li>first timing number between 0 and 40</li>
<li>second timing number between 4500 and 5500</li>
<li>third timing number between 6800 and 8300</li>
</ul>
<p>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.</p>
<p>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.</p>

<h2><a name="Replay">Replay</a></h2>
UEI protocol: 0092
<br>IRP notation: {36k,444,msb}&lt;-1,1|1,-1&gt;(6,-2,1:1,6:3,&lt;-2,2|2,-2&gt;(T:1),D:8,S:8,F:8,-???)+
<br>EFC translation: MSB
<p>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".</p>
<p>DecodeIr's Subdevice field in  is called "unit" in KM</p>
<p>In ProntoEdit, DecodeIr's "Device" is called "Customer Code"; DecodeIr's "Subdevice" is called "System";
and DecodeIr's "OBC" is called "Command".</p>

<h2><a name="Samsung20">Samsung20</a></h2>
IRP notation: {38.4k,564}&lt;1,-1|1,-3&gt;(8,-8,D:6,S:6,F:8,1,^???)+
<br>EFC translation: LSB
<p>This is a moderately robust protocol, but <a href="#spurious">spurious decodes</a> are still possible.</p>


<h2><a name="Samsung36">Samsung36</a></h2>
UEI protocol: 01B5
<br>IRP notation: {38k,500}&lt;1,-1|1,-3&gt;(9,-9,D:8,S:8,1,-9,E:4,F:8,-68u,~F:8,1,-118)+
<br>EFC translation: LSB

<h2><a name="Sampo">Sampo</a></h2>
IRP notation: {38.4k, 833}&lt;1,-1|1,-3&gt;(4,-4,D:6,F:6,S:6,~F:6,1,-39)+
<br>EFC translation: Not available in this version of DecodeIr
<p>This is a moderately robust protocol, but <a href="#spurious">spurious decodes</a> are still possible.</p>

<h2><a name="ScAtl-6">ScAtl-6</a></h2>
UEI protocol: 0078
<br>IRP notation: {57.6k,846}&lt;1,-1|1,-3&gt;(4,-4,D:6,F:6,~D:6,~F:6,1,-40)+
<br>EFC translation: 6-bit LSB comp
  <p>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.</p>
<p>In KM, this protocol is named "Scientific Atlanta".  Most Scientific Atlanta cable tuners use Panasonic_Old
protocol, not this protocol.</p>

<h2><a name="Sejin-M-38">Sejin-<i>M</i>-38 and Sejin-<i>M</i>-56</a></h2>
UEI protocol: 0161
<br>
IRP notation for Sejin-<i>M</i>-38: {38.8k,310,msb}&lt;-1|1&gt;(&lt;8:4|4:4|2:4|1:4&gt;(3,3:2,Dx:8,Fx:8,Fy:8,E:4,C:4,-L))+ 
<br>
IRP notation for Sejin-<i>M</i>-56: {56.3k,310,msb}&lt;-1|1&gt;(&lt;8:4|4:4|2:4|1:4&gt;(3,3:2,Dx:8,Fx:8,Fy:8,E:4,C:4,-L))+ 
<br>
In both cases E is a checksum seed (0 in all known examples) and C is a checksum given by
<br>C = Dx:4 + Dx:4:4 + Fx:4 + Fx:4:4 + Fy:4 + Fy:4:4 + E.
<br>EFC translation: For Sejin-1, MSB.  For Sejin-2, EFC translation not available.
<p>The parameter <i>M</i> 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 
&gt; 0 then the style is Sejin-1, used for normal buttons of a remote 
control.  If Dx &lt; 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.</p>

<p>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.</p>

<p>The protocol parameters for Sejin-1 include a bit that marks the end frame of a <a href="#repeat">repeat 
   sequence</a>.  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.</p>

<h2><a name="Sharp">Sharp, Sharp{1} and Sharp{2}</a></h2>
IRP notation: {38k,264}&lt;1,-3|1,-7&gt;(D:5,F:8,1:2,1,-165,D:5,~F:8,2:2,1,-165)+
<br>EFC translation: LSB
  <p>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 <a href="#spurious">spurious</a>.</p>


<h2><a name="SharpDVD">SharpDVD</a></h2>
UEI protocol: 00F8
<br>
IRP notation: {38k,400}&lt;1,-1|1,-3&gt;(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}
<br> EFC translation: LSB comp
<p>SharpDVD is the member of the Kaseikyo family with OEM_code1=170 and OEM_code2=90.</p>

<h2><a name="SIM2">SIM2</a></h2>
IRP notation: {38.8k,400}&lt;3,-3|3,-7&gt;(6,-7,D:8,F:8,3,-60m)

<h2><a name="Solidtek16">Solidtek16</a></h2>
IRP notation: {38k}&lt;-624,468|468-624&gt;(1820,-590,0:1,D:4,F:7,S:1,C:4,1:1,-???) 
<p>
This is a KeyBoard protocol.  The make/break bit is decoded into the subdevice field.</p>

<h2><a name="Solidtek20">Solidtek20</a></h2>
IRP notation: {38k}&lt;-624,468|468-624&gt;(1820,-590,0:1,D:4,S:6,F:6,C:4,1:1,-???) 
<p>
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.</p>
<p>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.</p>

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

<h2><a name="Sony8">Sony8</a></h2>
IRP notation: {40k,600}&lt;1,-1|2,-1&gt;(4,-1,F:8,^22200)
<br>EFC translation: LSB.

<h2><a name="Sony12">Sony12</a></h2>
UEI protocol: 00CA
<br>IRP notation: {40k,600}&lt;1,-1|2,-1&gt;(4,-1,F:7,D:5,^45m)+
<br>EFC translation: LSB.

<h2><a name="Sony15">Sony15</a></h2>
UEI protocol: 00CA
<br>IRP notation: {40k,600}&lt;1,-1|2,-1&gt;(4,-1,F:7,D:8,^45m)+
<br>EFC translation: LSB.

<h2><a name="Sony20">Sony20</a></h2>
UEI protocol: 00DE
<br>IRP notation: {40k,600}&lt;1,-1|2,-1&gt;(4,-1,F:7,D:5,S:8,^45m)+
<br>EFC translation: LSB.

<h2><a name="StreamZap">StreamZap</a></h2>
IRP notation: {36k,msb,889}&lt;1,-1|-1,1&gt;(1:1,~F:1:6,T:1,D:6,F:6,^114m)+
<br>DecodeIR V2.43 decodes this as RC5-7F
<br>EFC translation: 6-bit MSB comp

<h2><a name="StreamZap-57">StreamZap-57</a></h2>
IRP notation: {57k,msb,889}&lt;1,-1|-1,1&gt;(1:1,~F:1:6,T:1,D:6,F:6,^114m)+
<br>DecodeIR V2.43 decodes this as RC5-7F-57
<br>EFC translation: 6-bit MSB comp


<h2><a name="Sunfire">Sunfire</a></h2>
IRP notation: (38k,560,msb)&lt;1,-1|3,-1&gt;(16,-8, D:4,F:8,~D:4,~F:8 -32)+
<br>EFC translation: Not available in this version of DecodeIr

<h2><a name="TDC-38">TDC-38 and TDC-56</a></h2>
IRP notation for TDC-38: {38k,315,msb}&lt;-1,1|1,-1&gt;(1:1,D:5,S:5,F:7,-89m)+
<br>IRP notation for TDC-56:  {56.3k,213,msb}&lt;-1,1|1,-1&gt;(1:1,D:5,S:5,F:7,-89m)+
<br>EFC translation: 7-bit MSB.
<p>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.</p>

<h2><a name="Teac-K">Teac-K</a></h2>
UEI protocol: 00BB
<br>
IRP notation: {37k,432}&lt;1,-1|1,-3&gt;(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} <br>
EFC translation: LSB comp, two parts
<p>Teac-K is the member of the Kaseikyo family with OEM_code1=67 and OEM_code2=83.</p>
<p>Teac-K uses different repeat rules and a different check byte than other Kaseikyo protocols.</p>
<p>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.</p>
<p>This protocol signals repeats by the use of <a href="#repeat">dittos</a>.</p>

<h2><a name="Thomson">Thomson</a></h2>
UEI protocol: 004B
<br>IRP notation: {33k,500}&lt;1,-4|1,-9&gt;(D:4,T:1,D:1:5,F:6,1,^80m)+
<br>EFC translation: 6-bit LSB comp, or that prepended with extra device bit.
<p>This is not a robust protocol, so <a href="#spurious">spurious decodes</a> are likely.</p>
<p>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).</p>
<p>Thomson includes a <a href="#toggle">toggle bit</a> so using learned signals will have
operational problems.  You should use <a href="#jp1">KeyMoves or Upgrades</a> based on the decoded values,
rather than continue to use the learned signals.</p>
  <p>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.</p>

<h2><a name="Thomson7">Thomson7</a></h2>
UEI protocol: 004B
<br>IRP notation: {33k,500}&lt;1,-4|1,-9&gt;(D:4,T:1,F:7,1,^80m)+
<br>EFC translation: 7-bit LSB comp
<p>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).</p>

<h2><a name="Tivo">Tivo</a></h2>
IRP notation: {38.4k,564}&lt;1,-1|1,-3&gt;(16,-8,133:8,48:8,F:8,U:4,~F:4:4,1,-78,(16,-4,1,-173)*) 
<br>
EFC translation: LSB comp

<h2><a name="Velleman">Velleman</a></h2>
IRP notation: {38k,msb}&lt;700,-5060|700,-7590&gt;(1:1,T:1,D:3,F:6,1,-55m)+
<br>EFC translation: 6-bit MSB comp
<p>Very similar to RECS80-0045, except on duration is longer</p>

<h2><a name="Velodyne">Velodyne</a></h2>
IRP notation: 
{38k,136,msb}&lt;210,-760&gt;(&lt;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&gt;(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))
<br> Velodyne is a close relative of XMP.  

<h2><a name="Viewstar">Viewstar</a></h2>
UEI protocol: 0021
<br>IRP notation: {50.5k,337}&lt;1,-8|1,-5&gt;(F:5,1,-17)+
<br>EFC translation: 5-bit LSB comp
<p>This is not a robust protocol, so <a href="#spurious">spurious decodes</a> are likely.</p>

<h2><a name="X10">X10 and X10.<i>n</i></a></h2>
UEI protocol: 003F (X10.<i>n</i>), 01DF (X10)
<br>IRP notation for X10: {40.8k,565}&lt;2,-12|7,-7&gt;(7,-7,F:5,~F:5,21,-7)+
<br>IRP notation for X10.<i>n</i>: {40.8k,565}&lt;2,-12|7,-7&gt;(F:5,N:-4,21,-7,(7,-7,F:5,~F:5,21,-7)+)
<br>EFC translation: LSB of 2*OBC+1
<p>These are two variants of the same Home Automation protocol.  They differ in that X10.<i>n</i> has a 
    distinctive start frame that carries a sequence number, the <i>n</i> 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 <i>n</i> 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.<i>n</i> signal must have at least one repeat frame.  If this is 
    missing then the Misc column shows "invalid signal".</p>
<p>RemoteMaster has a single protocol, named X10 with PID 003F, that sends X10.<i>n</i> signals.  This is 
    the same as the UEI protocol with that PID.  There is no control over the value of <i>n</i>, this is 
    handled automatically by the remote.  The newer UEI protocol, with PID 01DF, sends X10 signals.</p>

<h2><a name="XMP">XMP, XMP-1 and XMP-2</a></h2>
UEI protocol: 016C
<br>IRP notation (without final frame): 
{38k,136,msb}&lt;210,-760&gt;(&lt;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&gt;(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)}
<br>IRP notation (with final 
frame):{38k,136,msb}&lt;210,-760&gt;(&lt;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&gt;(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)}
<br>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

<br><br>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.
<br><p>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.</p>

<p>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.</p>
<p>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.</p>
<p>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:</p>
<ul>
<li>End (= Endpoint):  The lead-out burst is missing and has been inserted.  This is almost certainly correct.
</li><li>Rec (= Recovery):  Look-ahead has been used to recover a 
missing burst from the following repeat frame.  This is very likely to 
be correct.
</li><li>Cor (= Correction): Two bursts have been coalesced in the 
learning process, e.g. those for hex digits C and D, causing a C to 
appear as D or vice versa.
The error has been identified and corrected.  This is probably correct.
</li><li>Cal (= Calculated): A missing digit has been calculated from a 
checksum.  The digit is probably correct but it may be in the wrong 
place.  The most likely error in the reconstruction is that the two 
digits of the OBC are the wrong way round.
</li><li>Cal2 (= Calculated 2)  Two consecutive missing zero digits have
 been identified, corresponding to a zero OBC.  When this happens, the 
signal will always be shown as XMP-1.  The most likely error in the 
reconstruction is that it should actually be XMP-2.
</li></ul>
<p>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
<br><br>XMP:136.218-0F0F441A0A800F00
<br><br>
  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.</p>
<p>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.</p>
<p>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.</p>

<h2><a name="XX">XX</a></h2>
Documentation not written yet.

<h2><a name="Zaptor">Zaptor</a></h2>
UEI protocol: unknown
<br>IRP notation: {36k,330,msb}&lt;-1,1|1,-1&gt;[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)&amp;15}
<br>where T=0 for all frames except the last, T=1 for last frame, E is a checksum seed.  There is a 56KHz variant.
<br>EFC translation: MSB
<p>A protocol so far seen only in the Motorola Zaptor.  See also Amino</p>

<h2><a name="Zenith">Zenith</a></h2>
UEI protocol: 0022
IRP notation: {40k,520,msb}&lt;1,-10|1,-1,1,-8&gt;(S:1,&lt;1:2|2:2&gt;(F:D),-90m)+
<br>Before Version 2.43, this document has shown the IRP notation as 
{40k,520,msb}&lt;1,-1,1,-8|1,-10&gt;(S:1,&lt;1:2|2:2&gt;(F:D),-90m)+
<br>EFC translation: MSB 
<p>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 &gt;8 then the bytes given in the Misc field as E = ... follow the OBC in the function 
    code value.</p>

<h2><a name="?1-??-??-??">?1-??-??-??</a></h2>
An experimental decode I added based on the thread at
<a href="http://www.hifi-remote.com/forums/viewtopic.php?p=19168#19168">JP1-forum"Unknown 
    Protocol"</a>

</blockquote>
<p>&nbsp;</p>
<table width="750"><tbody><tr><td><center>
<script type="text/javascript"><!--
google_ad_client = "pub-2040680936936450";
/* 468x60, created 4/17/09 */
google_ad_slot = "7283198346";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript" src="Interpreting%20Decoded%20IR%20Signals%20%28v2.43%29-Dateien/show_ads.js">
</script>
</center>
</td></tr></tbody></table>

</body></html>

================================================
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<NecEvent, IRL_ADDRESS> 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<RawIR> 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<IR_NEC>(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<IR_NEC>(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<IRL_DEBOUCE, IR_NEC, IR_PANASONIC, IR_SONY12> 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<IR_NEC>(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<typename protocol, typename ...protocols>
	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<typename protocol, typename ...protocols>
	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<typename protocol, typename ...protocols>
	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 <IRType ...irProtocol>
inline void CIRLremote<debounce, irProtocol...>::
decodeSony20(const uint16_t duration) {
	//// pass the duration to the decoding function
	//bool newInput;
	//// 1st extra accuracy solution
	//if (sizeof...(irProtocol) != 1)
	//	newInput = IRLdecode <SONY_LENGTH_20, (SONY_TIMEOUT + SONY_MARK_LEAD) / 2, // irLength, timeoutThreshold
	//	(SONY_MARK_LEAD + SONY_MARK_ONE) / 2, 0, // markLeadThreshold, spaceLeadThreshold
	//	0, (SONY_MARK_ONE + SONY_MARK_ZERO) / 2, // spaceLeadHoldingThreshold, markThreshold
	//	0, // spaceThreshold
	//	(SONY_MARK_LEAD + SONY_MARK_ONE) / 2, SONY_MARK_ONE>// markTimeout, spaceTimeout
	//	(duration, dataSony20, countSony20);
	//else
	//	newInput = IRLdecode <SONY_LENGTH_20, (SONY_TIMEOUT + SONY_MARK_LEAD) / 2, // irLength, timeoutThreshold
	//	(SONY_MARK_LEAD + SONY_MARK_ONE) / 2, 0, // markLeadThreshold, spaceLeadThreshold
	//	0, (SONY_MARK_ONE + SONY_MARK_ZERO) / 2, // spaceLeadHoldingThreshold, markThreshold
	//	0, // spaceThreshold
	//	0, 0>// 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 <IRType ...irProtocol>
//template <uint8_t irLength, uint16_t timeoutThreshold, uint16_t markLeadThreshold, uint16_t spaceLeadThreshold,
//	uint16_t spaceLeadHoldingThreshold, uint16_t markThreshold, uint16_t spaceThreshold,
//	uint16_t markTimeout, uint16_t spaceTimeout>
//	inline bool CIRLremote<debounce, irProtocol...>::
//	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<typename protocol, typename ...protocols>
CIRLremote<protocol, protocols...>::
CIRLremote(void) {
	// Empty
}


template<typename protocol, typename ...protocols>
bool CIRLremote<protocol, protocols...>::
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<typename protocol, typename ...protocols>
bool CIRLremote<protocol, protocols...>::
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<typename protocol, typename ...protocols>
bool CIRLremote<protocol, protocols...>::
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<typename protocol, typename ...protocols>
IR_data_t CIRLremote<protocol, protocols...>::
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<typename protocol, typename ...protocols>
void CIRLremote<protocol, protocols...>::
reset(void)
{
	// Call all protocol reset functions
	protocol::reset();
	nop((protocols::reset(), 0)...);
}


//================================================================================
// Interrupt Function
//================================================================================

template<typename protocol, typename ...protocols>
void CIRLremote<protocol, protocols...>::
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 <IRType irType>
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<NEC_ADDRESS_LENGTH, NEC_COMMAND_LENGTH, NEC_HZ, IR_ADDRESS_FIRST, NEC_MARK_LEAD, NEC_SPACE_LEAD,
			        NEC_MARK_ZERO, NEC_MARK_ONE, NEC_SPACE_ZERO, NEC_SPACE_ONE>
			        (outPort, bitMask, address, command);
		break;

	case IR_PANASONIC: //TODO test
		// send data
		IRLsend<PANASONIC_ADDRESS_LENGTH, PANASONIC_COMMAND_LENGTH, PANASONIC_HZ, IR_ADDRESS_FIRST, PANASONIC_MARK_LEAD, PANASONIC_SPACE_LEAD,
		        PANASONIC_MARK_ZERO, PANASONIC_MARK_ONE, PANASONIC_SPACE_ZERO, PANASONIC_SPACE_ONE>
		        (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<SONY_ADDRESS_LENGTH_12, SONY_COMMAND_LENGTH_12, SONY_HZ, IR_COMMAND_FIRST, SONY_MARK_LEAD, SONY_SPACE_LEAD,
			        SONY_MARK_ZERO, SONY_MARK_ONE, SONY_SPACE_ZERO, SONY_SPACE_ONE>
			        (outPort, bitMask, address, command);
		break;
	}

	// enable interrupts
	SREG = oldSREG;

	// set pin to INPUT again to be save
	*modePort &= ~bitMask;
}

// multifunctional template for sending
template <uint8_t addressLength, uint8_t commandLength,
          uint16_t Hz, bool addressFirst,
          uint16_t markLead, uint16_t spaceLead,
          uint16_t markZero, uint16_t markOne,
          uint16_t spaceZero, uint16_t spaceOne>
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 <loop+0x204>
//		// 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 <loop+0x1fe>
//     608:	f7 cf       	rjmp	.-18     	; 0x5f8 <loop+0x1f2>
//
//	 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<const uint16_t Hz>
//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 <blog@NicoHood.de>
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 T, int blocks>
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<class T, int blocks>
volatile uint8_t CIRL_DecodeSpaces<T, blocks>::count = 0;
template<class T, int blocks>
uint8_t CIRL_DecodeSpaces<T, blocks>::data[blocks] = { 0 };


//==============================================================================
// CIRL_DecodeSpaces Implementation
//==============================================================================

template<class T, int blocks>
bool CIRL_DecodeSpaces<T, blocks>::available(void){
    return count > (T::irLength / 2);
}


template<class T, int blocks>
void CIRL_DecodeSpaces<T, blocks>::resetReading(void){
    // Reset reading
    count = 0;
}


template<class T, int blocks>
void CIRL_DecodeSpaces<T, blocks>::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<class T, int blocks>
bool CIRL_DecodeSpaces<T, blocks>::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 <Arduino.h> // 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<CHashIR>,
             public CIRL_Time<CHashIR>,
             public CIRL_Protocol<CHashIR, HashIR_data_t>
{
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<CHashIR>;
    friend CIRL_Protocol<CHashIR, HashIR_data_t>;

    // 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
====================================
Download .txt
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
Download .txt
SYMBOL INDEX (39 symbols across 15 files)

FILE: extra/old/IRL_Hash.hpp
  class HashIR (line 40) | class HashIR : public CIRLData{
    method HashIR (line 42) | HashIR(void){

FILE: extra/old/IRL_RawIR.hpp
  class RawIR (line 47) | class RawIR : public CIRLData{
    method RawIR (line 49) | RawIR(void){

FILE: extra/old/IRL_Sony.hpp
  class Sony (line 69) | class Sony : public CIRLData{
    method Sony (line 71) | Sony(void){

FILE: extra/old/IRLremoteReceive.hpp
  function IR_data_t (line 127) | IR_data_t CIRLremote<protocol, protocols...>::

FILE: extra/old/IRLremoteTransmit.hpp
  function IRLwrite (line 57) | void IRLwrite(const uint8_t pin, uint16_t address, uint32_t command)
  function IRLsend (line 119) | void IRLsend(volatile uint8_t * outPort, uint8_t bitmask, uint16_t addre...
  function IRLmark (line 179) | void IRLmark(const uint16_t Hz, volatile uint8_t * outPort, uint8_t bitM...
  function IRLspace (line 330) | void IRLspace(volatile uint8_t * outPort, uint8_t bitMask, uint16_t time) {

FILE: src/IRL_Decode.h
  function ATOMIC_BLOCK (line 186) | ATOMIC_BLOCK(ATOMIC_RESTORESTATE)

FILE: src/IRL_Hash.h
  type HashIR_address_t (line 49) | typedef uint8_t HashIR_address_t;
  type HashIR_command_t (line 50) | typedef uint32_t HashIR_command_t;
  type HashIR_data_t (line 53) | struct HashIR_data_t
  function HashIR_data_t (line 99) | HashIR_data_t CHashIR::getData(void){
  function available (line 109) | bool CHashIR::available(void){
  function resetReading (line 121) | void CHashIR::resetReading(void){
  function receiving (line 129) | bool CHashIR::receiving(void)
  function interrupt (line 172) | void CHashIR::interrupt(void)

FILE: src/IRL_Keycodes.h
  function namespace (line 33) | namespace IRL_Protek_Remote{

FILE: src/IRL_Nec.h
  type Nec_address_t (line 98) | typedef uint16_t Nec_address_t;
  type Nec_command_t (line 99) | typedef uint8_t Nec_command_t;
  type Nec_data_t (line 102) | struct Nec_data_t
  function Nec_data_t (line 141) | Nec_data_t CNec::getData(void){
  function checksum (line 149) | bool CNec::checksum(void) {
  function holding (line 154) | void CNec::holding(void) {

FILE: src/IRL_NecAPI.h
  type TimeoutType (line 51) | enum TimeoutType : uint8_t

FILE: src/IRL_Panasonic.h
  type Panasonic_address_t (line 84) | typedef uint16_t Panasonic_address_t;
  type Panasonic_command_t (line 85) | typedef uint32_t Panasonic_command_t;
  function Panasonic_data_t (line 156) | Panasonic_data_t CPanasonic::getData(void) {
  function checksum (line 168) | bool CPanasonic::checksum(void) {
  function holding (line 186) | void CPanasonic::holding(void) {

FILE: src/IRL_Platform.h
  function SA_iRestore (line 48) | static __inline__ void SA_iRestore(const  uint32_t *__s)

FILE: src/IRL_Protocol.h
  function ATOMIC_BLOCK (line 58) | ATOMIC_BLOCK(ATOMIC_RESTORESTATE)

FILE: src/IRL_Receive.h
  function else (line 109) | else if (digitalPinToPCINT(pin) != NOT_AN_INTERRUPT){
  function else (line 157) | else if (digitalPinToPCINT(pin) != NOT_AN_INTERRUPT){

FILE: src/IRL_Time.h
  function ATOMIC_BLOCK (line 98) | ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
  function ATOMIC_BLOCK (line 117) | ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
Condensed preview — 30 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (247K chars).
[
  {
    "path": ".github/FUNDING.yml",
    "chars": 767,
    "preview": "# These are supported funding model platforms\n\ngithub: nicohood # Replace with up to 4 GitHub Sponsors-enabled usernames"
  },
  {
    "path": "Readme.md",
    "chars": 14306,
    "preview": "# IRLremote 2.0.2\r\n\r\n![Infrared Picture](header.jpg)\r\n\r\nNew lightweight IR library with different, smarter implementatio"
  },
  {
    "path": "dev/Interpreting Decoded IR Signals (v2.43).htm",
    "chars": 82747,
    "preview": "<html><head>\r\n<meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1252\">\r\n<title>Interpreting Decoded IR"
  },
  {
    "path": "examples/Convert_Old_Nec/Convert_Old_Nec.ino",
    "chars": 1208,
    "preview": "/*\n Copyright (c) 2014 NicoHood\n See the readme for credit to other people.\n\n IRL Convert Old Nec\n Converts Nec Signals "
  },
  {
    "path": "examples/NecAPI/NecAPI.ino",
    "chars": 20154,
    "preview": "/*\n  Copyright (c) 2014-2017 NicoHood\n  See the readme for credit to other people.\n\n  IRL NecAPI\n\n  Receives IR NEC sign"
  },
  {
    "path": "examples/Receive/Receive.ino",
    "chars": 2539,
    "preview": "/*\n  Copyright (c) 2014-2015 NicoHood\n  See the readme for credit to other people.\n\n  IRL Receive\n\n  Receives IR signals"
  },
  {
    "path": "examples/Receive_Raw/Receive_Raw.ino",
    "chars": 3231,
    "preview": "/*\n  Copyright (c) 2014-2015 NicoHood\n  See the readme for credit to other people.\n\n  IRL Receive_Raw\n\n  Receives IR sig"
  },
  {
    "path": "examples/Send_Button/Send_Button.ino",
    "chars": 767,
    "preview": "/*\r\n Copyright (c) 2014 NicoHood\r\n See the readme for credit to other people.\r\n\r\n IRL Send Button\r\n Sends IR signals on "
  },
  {
    "path": "examples/Send_Serial/Send_Serial.ino",
    "chars": 880,
    "preview": "/*\r\n Copyright (c) 2014 NicoHood\r\n See the readme for credit to other people.\r\n\r\n IRL Send Serial\r\n Sends IR signals on "
  },
  {
    "path": "examples/Transceive/Transceive.ino",
    "chars": 3274,
    "preview": "/*\n Copyright (c) 2014-2015 NicoHood\n See the readme for credit to other people.\n\n IRL Transceive\n\n Receives IR signals "
  },
  {
    "path": "extra/old/IRL_Hash.hpp",
    "chars": 6146,
    "preview": "/*\nCopyright (c) 2014-2015 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "extra/old/IRL_RawIR.hpp",
    "chars": 6436,
    "preview": "/*\nCopyright (c) 2014-2015 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "extra/old/IRL_Sony.hpp",
    "chars": 15213,
    "preview": "/*\nCopyright (c) 2014-2015 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "extra/old/IRLremote.cpp",
    "chars": 2090,
    "preview": "/*\nCopyright (c) 2014-2015 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "extra/old/IRLremoteReceive.hpp",
    "chars": 5791,
    "preview": "/*\nCopyright (c) 2014-2015 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "extra/old/IRLremoteTransmit.hpp",
    "chars": 11861,
    "preview": "/*\nCopyright (c) 2014-2015 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "keywords.txt",
    "chars": 2307,
    "preview": "#######################################\r\n# Syntax Coloring Map For IRLremote\r\n#######################################\r\n\r"
  },
  {
    "path": "library.properties",
    "chars": 360,
    "preview": "name=IRLremote\r\nversion=2.0.2\r\nauthor=NicoHood\r\nmaintainer=NicoHood <blog@NicoHood.de>\r\nsentence=Lightweight Infrared li"
  },
  {
    "path": "src/IRL_Decode.h",
    "chars": 6336,
    "preview": "/*\nCopyright (c) 2014-2018 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "src/IRL_Hash.h",
    "chars": 6994,
    "preview": "/*\nCopyright (c) 2014-2018 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "src/IRL_Keycodes.h",
    "chars": 3697,
    "preview": "/*\nCopyright (c) 2014-2018 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "src/IRL_Nec.h",
    "chars": 6355,
    "preview": "/*\nCopyright (c) 2014-2018 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "src/IRL_NecAPI.h",
    "chars": 6610,
    "preview": "/*\nCopyright (c) 2014-2018 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "src/IRL_Panasonic.h",
    "chars": 7149,
    "preview": "/*\nCopyright (c) 2014-2018 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "src/IRL_Platform.h",
    "chars": 2326,
    "preview": "/*\nCopyright (c) 2014-2018 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "src/IRL_Protocol.h",
    "chars": 2792,
    "preview": "/*\nCopyright (c) 2014-2018 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "src/IRL_Receive.h",
    "chars": 4585,
    "preview": "/*\nCopyright (c) 2014-2018 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "src/IRL_Time.h",
    "chars": 3973,
    "preview": "/*\nCopyright (c) 2014-2018 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "src/IRLremote.cpp",
    "chars": 1462,
    "preview": "/*\nCopyright (c) 2014-2018 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  },
  {
    "path": "src/IRLremote.h",
    "chars": 1733,
    "preview": "/*\nCopyright (c) 2014-2018 NicoHood\nSee the readme for credit to other people.\n\nPermission is hereby granted, free of ch"
  }
]

About this extraction

This page contains the full source code of the NicoHood/IRLremote GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 30 files (228.6 KB), approximately 67.0k tokens, and a symbol index with 39 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!