in lua is there IR so I can send signals?
edit: whoops, im stupid, i just found out there is >_<
Printable View
in lua is there IR so I can send signals?
edit: whoops, im stupid, i just found out there is >_<
IrDA functions in Lua:
Quote:
nil System.irdaInit()
Opens the IrDA device. Call this to start the IrDA module.
Quote:
System.irdaWrite(string)
Writes the string to the IrDA port.
Quote:
string System.irdaRead()
Reads all available data from the IrDA port. Returns an empty string, if no data was received.
I used irdacapture on my remote control for my helicopter, but it came back with like loads of symbols and it doesnt work in Lua, Hoe would I be abnle to figure out what the symbols mean?
that is what I have, but it doesn't say "Going UP!".Quote:
if pad:up() then
if System.irdaWrite("Ô„ÄÀ*|ô„„|ü8Nˆ´¤| ð€è´Ä|‡ü|t.¤|þð|>§8NˆÀ„|äð—| |ä|‡|‡øä„„|äø€ðè||‡|ä|‡| ø—|‡|ä|>§üøþ.|‡|‡þøä„„|ä„ „ä„€* „|ä|8ä„„|ä„€ð|‡øä„„|äø€ |pÄ„„|ä„„*8ð*ˆ„|ä„„|ää„ *„|ä|<ä„„|䄸*Nð„„|ä„„|N øä„ø*„|ä|ÿ䄸*„|ä|ÿø€ „„|ä„„ÿ€øø€ „|ä„|ä€þð*ä|ä„þøä|ä„pÐþøä „|ä€8è„þä„ð*äþø<8ä„„|ä„Ð þä„Ð|ä„þЄ|ä„|ä€þpЄ|ä„| þpÈ|ä„|äˆþä|ä„|äøþ|ä„|ä„ð* þð*|ä|ä„þøä„|*||ä„þð*„|ä„ øøÐ|ä„„|äNˆøä|䄸*|ä„|äøÀ |ä|ÿNä„„|äÀ„|ä| ä„„À„|ä|ÿ*|ä„„|䄸øä„„À „|ä|ä„€*„„|ä|ÿøä„„|䈀è| øä„€*„„|ä|Ð|ä„„|ä|ÿ䄸* „|ä|Ž|ä|ä|ä8ÿ‡N|‡‡|‡ÿ|ç|‡|‡ Ž„|üpÀ€è|NŽpÈ„|ä„„|äøð~€ |ä|þð<|‡|‡þ—|‡—|‡‡.>*è„„| €À„„|ä„|*„øøþ>—|ä|‡|‡ø‡> |‡—|‡|ä|‡þ|äÀè|þä€À|ä„|ä|ä €þøä„€ä|ä|ä„€þ|ä„„|ä€ð |ä„„|üŽ„|ä|ü€‡øç|‡|‡þ§|‡| ä|‡|‡ðð.|‡ð—|ä|‡ðä„|ä„ä|ä øð.|‡ø‡|‡|ä|‡|‡øø/8üøä„„* „„„„|‡Àä„|‡|ø‡ø‡|>——|‡ |ä|‡|‡øÿø/|‡|ü|‡|‡ø‡|‡|ä|‡þ‡|‡|ä|‡|ç øÀ„„€ˆ|ä„|ä|—|‡‡|‡þ—|‡ |ü|‡þ—|‡|ü|‡þ") then
screen:print(0,40,"Going UP!",white)
end
The symbols are bytes outside of the normal range
of printable characters. It looks like your helicopter
uses byte values between 128 and 255 fo take off. U'll
need a hex file reader to see the exact values.
(PSP Filer has a hex reader)
I posted a similar program written in lua a while back in
THIS THREAD- to print raw data
reads from Irda to the PSP screen in decimal
I've been thinking about coding an IRLearner, but I don't think I'll release that in public though.
to get the Irda write statement working, you can
convert the data to decimal byte escape sequences in Lua: \ddd
eg. to output 2 bytes 0x01 0xff , use System.irdaWrite("\1\255")
Where would I find the 0xff or whatever they are called?
think the capture prog sends all its 0xff 's to a file in the root ms0:/Quote:
Where would I find the 0xff or whatever they are called?
open the file from Lua , then read the string.byte(s)
*edit* the code is like:
PHP Code:
System.irdaInit()
codes=io.open("ms0:/capture.dat","rb")
System.irdaWrite(codes:read("*a"))
codes:close()
I don't see any file in my mem stick called capture.dat.
edit: u mean the other thread ircapture. yes i have a file called "ircapture" so I work on it
edit2: How would I get a file 1 char at a time? because string.byte() only works on 1 letter rather than a line of it
umm, yeah, Ive D/L'd the prog now; the file paths
"ms0:/irdacapture".
to read bytes into a table:
to transmit Byte[n] to the helicopter:PHP Code:
codes = io.open("ms0:/irdacapture","rb")
Byte,i={},0
repeat
i=i+1
Byte[i]=string.byte(codes:read(1))
until not Byte[i]
codes:close()
to write Byte[n] to screen:PHP Code:
System.irdaWrite(string.char(Byte[n]))
PHP Code:
screen:print(10,10,tostring(Byte[n]),Color.new(255,0,0))