Project: RC-5Remote
Author: Malte Marwedel
Version: 2012-09-17   1.0
Homepage: www.marwedels.de/malte
Target MCU: ATtiny84

== About the source ==
This project connects an RC-5 remote control as keyboard to the computer.
The sourcecode for the USB part was derived from the HIDKeys example:
http://www.obdev.at/products/vusb/hidkeys.html
The sourcecode for the RC-5 decoding was derived from Peter Dannegger
http://www.mikrocontroller.net/topic/12216

== About the LED ==
1. The LED light short at the start.
2. The LED is off during normal operation.
3. The LED does a long flicker if a remote-key is received and a USB-key is send to the computer.
4. The LED does a short flicker if a remote-key code is received, which is not connected to any USB-key.
5. The LED lights continuously in the configuration mode.
If the EEPROM checksum is invalid, the state of the LED in point 2, 3, 4 is inverted.

== Checksums ==
The configuration data in the EEPROM is verified by checksum.
If the checksum does not fit, all data is deleted and no key will be send. This will be the
case on the first start or if configuration was not completed.

== How to configure ==
OPEN A TEXT EDITOR AND PLACE THE FOCUS INSIDE. This is important because for configuring
the circuit will press a lot of buttons. To minimise the risk of accidents,
the configuration menu will only print the USB-keys 0-9, a-z, A-Z, '.', '-' and space.

Right after connecting the circuit to the USB port, press a pattern of
four different remote-keys twice. No previous remote-keys may be pressed.
Pattern: ABCDABCD. A B C D must each be unique!
You will then enter the configuration menu. Now your four remote-keys have the following functions:
A: Leave config menu
B: Assign IR codes to a predefined set of keyboard chars
C: Assign custom keyboard chars (only necessary for advanced users)
D: Print current assigned USB-key -> remote-key mapping.
Pressing any other button will print the RC-5 code of the remote.

Note that the checksum is only updated after the mode B or C have finished,
so removing the device after your first assignmend in one of the modes and before the last assignment,
will result in an invalid checksum and the device will delete all your settings on the next connect.

In mode B press the proper remote-key on the remote for the name of each USB-key.
If you do not want to assign some USB-keys, press a remote-key you have already assigned, in this
case 0000 is printed. Note, there is no way to *not* assign the first USB-key.
Use some remote-key you don't want to use.

In the case you want to press an USB-key, which is not predefined or a predefined by two
different remote-keys, you can assign five custom USB-keys.
This is done by entering two 3-digit numbers for each USB-key. The first number describes
the modifier keys, like SHIFT, ALT, CONTROL... and the second one the actual key.
Each number has the range 0...255. If you enter larger numbers, this will wrap (ex 256 will be 0).
For the modifier keys, you can enter the sum of the following:
CONTROL LEFT: 1
SHIFT LEFT: 2
ALT LEFT: 4
GUI LEFT: 8
CONTROL RIGHT: 16
SHIFT RIGHT: 32
ALT RIGHT: 64
GUI RIGHT: 128
(see http://www.usb.org/developers/devclass_docs/HID1_11.pdf page 56)
For the second number, look into the table from usb.org:
http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf
page 53-59.
Note, that in order to enter the digits, you should assign all 0...9 USB-keys to some remote-keys before.
If you don't want to use the USB-keys later, you may need to run configuration B a second time.

== Modify the source code ==
You can easily add your own predefined USB-keys and more custom keys until you reach the limit of the EEPROM and flash.
Each predefined USB-key, needs 2 byte, each custom USB-key 4 bytes EEPROM. Both need 12 bytes of flash each. 
Since the ATtine84 has 512 Bytes EEPROM and the checksum needs 4 byte,
you can calculate yourself how many keys of which type are possible.

== The schematics ==
The schematics and pcb layouts may be used non-commercial (meaning you may not earn money with them).
They are not tested in exactly the version you see here, because I have a PCB of version 1.0 assembled and did
some modification to it.
The difference between Version 1.0 and 1.1 is that R3 was a general pull-up and not connected to the I/O pin.
Use on your own risk.
