IR Question

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
Mr Billy
Posts: 10
Joined: Wed Oct 26, 2005 10:13 am

IR Question

Post by Mr Billy »

i love the new ir function, i was playing around with it and its pretty neat. i was wondering tho, can i read the command that a button on my tv remote is sending, and send that command to do stuff with my tv. i know its just a pulse rate on the LED and not really a command, but is there a way to do it this way? thanx
"There is no spoone"
-The Matricks
youresam
Posts: 87
Joined: Sun Nov 06, 2005 1:43 am

Post by youresam »

nope, Ive tried this with simple C programs, too many variables. You can recieve the IR and display them, acording to what I see in the source.

EDIT
Alright, I used my modified .11 and I can make it do what my C program did!
print("")
System.irdaInit()
while true do
input = Controls.read()
if input:start() then break end
irtext = System.irdaRead()
if irtext ~= "" then
print(irtext)
end
end
put that in an index.lua and run it, it will recieve the IR signal and print it on the screen.

NOTE: the print() function uses teh debug library, which uses a different text encoding, so dont try the screen:print(), all it does it print letters that look like static.
Mr Billy
Posts: 10
Joined: Wed Oct 26, 2005 10:13 am

Post by Mr Billy »

what if i made a program to count the number of milliseconds between inputs, and output every x milliseconds. it really wouldnt matter what character is outputted, just so it lights up the LED. that could work theoretically, right?

EDIT: I made a program to do this and i counted 17 milliseconds between pulses on my TV power button on my remote. im going to try to output any character once every 17 milliseconds to see if it will turn it on.

EDIT2: Doesnt work... how do all these other programs made in C do it? like the one that controlls a phillips TV...
"There is no spoone"
-The Matricks
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Re: IR Question

Post by Shine »

Mr Billy wrote:i was wondering tho, can i read the command that a button on my tv remote is sending, and send that command to do stuff with my tv.
There are 3 infrared modes for PSP: IrDA (see http://forums.ps2dev.org/viewtopic.php?t=2555 for an example program in C, which I've used as the base for the Lua Player implementation), SIRCS for Sony remote controls (see http://forums.ps2dev.org/viewtopic.php?p=17336#17336 for some oscilloscope pictures of the signal) and custom mode for other remote controls (see http://forums.ps2dev.org/viewtopic.php?t=3140 for the nice hack from PspPet). IrDA is implemented in Lua Player, SIRCS and general IR is on the TODO list at http://wiki.ps2dev.org/psp:lua_player:todos

As it is already implemented I have to provide some nice Lua API for it, only and copy and paste the implementations. Do you have some ideas how the Lua functions for SIRCS and general IR should look like?
Mr Billy
Posts: 10
Joined: Wed Oct 26, 2005 10:13 am

Re: IR Question

Post by Mr Billy »

As it is already implemented I have to provide some nice Lua API for it, only and copy and paste the implementations. Do you have some ideas how the Lua functions for SIRCS and general IR should look like?[/quote]

i honestly have no idea how they should look, im new to the whole IR thing. since i dont have wifi in my house (i live in a cave :P) this is the closest thing i have to wireless communications. i cant wait til i can interface my psp with my laptop or control my tv, vcr, dvd player, and surround with my psp.

and a little tip to anyone that likes to see what their IR LED is doing... use your webcam. most digital cameras and webcams pick up ir, so you can see it if u need.
"There is no spoone"
-The Matricks
youresam
Posts: 87
Joined: Sun Nov 06, 2005 1:43 am

Re: IR Question

Post by youresam »

Shine wrote:As it is already implemented I have to provide some nice Lua API for it, only and copy and paste the implementations. Do you have some ideas how the Lua functions for SIRCS and general IR should look like?
Well, for SIRCS don't you have to convert the signal to HEX, then switch numbers, then do more confusing stuff?

I think if your going to put it in, make it like the 3D stuff where its the same command, and maybe include some instructions on how to get the numbers for it.
aldebaran
Posts: 12
Joined: Thu Nov 17, 2005 11:21 pm

Re: IR Question

Post by aldebaran »

youresam wrote:Well, for SIRCS don't you have to convert the signal to HEX, then switch numbers, then do more confusing stuff?
I think it is a general sistem to obtain IR codes from any remote controller.
Sony, for an example, encodes each command as an AGC burst (2400picoseconds) followed by a 7-bit command field and a 5-bit device field transmitted lsb (last significant bit) to msb (most sb). A "0" bit is encodes as 600 picosec idle followed by a 600 picosec pulse; while a "1" bit is encodes as 600 picosec idle followed by a 1200 picosec pulse.
Starting from the HEX code you read, you can generate (with a script) almost every other code for your device (without saving each signal).

Another point is: I don't know if there is a filter in front of the IR diod (like the Newton MP2100 has) which can prevent the PSP to read ir signals with a frequency different from ~ 40 KHz (Sony frq).
Post Reply