Magic IR, universal IR record & playback
I've been working on a home automation project for a while - Jon Williams' Spin Zone column on Sony's IR control format (pdf) got me started on IR control. It's an awesome & well documented object, problem was it only worked with SIRCS.
I looked at the other IR objects in the Propeller Object Exchange, & they supported NEC & RC5 IR formats, but I was having problems getting it to work with my TV. I needed something dumber, so I built my own object, Magic IR.
Magic IR stores any arbitrary IR code, as received from an IR receiver (I've been using this Vishay, but all others should work) with a max of 128 transitions. Store code is written in pasm, so the transition timing is as high resolution as possible. The stored IR code can then be played back.
Usage is pretty simple, there are just 2 methods;
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
magicir : "magicir_010"
LONG code1, code1len
magicir.storecode(0, @code1, @code1len)
'' store a code received at pin 0 at code1 with total
'' transition count at code1len
waitcnt(clkfreq + cnt)
'' playback a code with the IR LED connected to pin 1.
'' Code is stored at code1, length at code1len
The storecode method starts a new cog - it will pause until the input pin goes low & will timeout after 1/8 second or 128 transitions have been received.
The playcode method runs in the existing cog - if you've just called storecode, it will pause until storecode completes. Once storecode is done, it will playback the code at 38kHz on the LED connected to the output pin.
This is my first object meant for others to use - it's attached. I also did a video demo. Any suggestions are welcome!
You can download the object here.