|Top Previous Next|
The pir namespace allows you to control the PIR-1 and PIR-4 from Lua.
pir.transmit(serial, ccf, bitmask, repeats)
serial should be the serial of the PIR (you can find it on the back of the PIR or use listpir1/listpir4. If you pass an empty string it will send out all PIR's attached to the machine.
bitmask depends on the hardware
1 = Back
2 = Front
3 = Both
1 = Port 1
2 = Port 2
4 = Port 3
8 = Port 4
Note that the PIR-4 will only send out one port at time.
Repeats dictates how many times the repeat part of the CCF code will be sent. Note that if the CCF code only consists out of repeat codes and you pass 0 for repeat nothing will be sent. So it's generally a good idea to pass at least 1 here.
keyboard(serial, key1, key2, key3, key4)
PIR-1 units have a built-in keyboard emulator and can send one of 4 keys depending on which of the contacts was closed. To set what keypress, if any, should be generated use this function. Note that serial must match a connected PIR-1 otherwise this function will fail.
This is only an excerpt of the scan code table. The full version can be found here (http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/translate.pdf)
Setting the key values to 0 will suppress any key presses from being generated.