New to prop plz help - PS2_HIDEngine
LA3QMA
Posts: 13
Trying to get to know SPIN :idea:
So i have been trying to use PS2_HIDEngine
I'm using Propeller Demo Board.
Reading the documentation for PS2_HIDEngine i have to start the engine.
The demoboard is using 26 and 27 for the keyboard.
Trying this code:
I'm expecting to get the LED flashing if the keyboard is connected and ok.
"Returns true if the keyboard is present and ready and false if not."
I just need a kick in the b*t to get started...
So i have been trying to use PS2_HIDEngine
I'm using Propeller Demo Board.
Reading the documentation for PS2_HIDEngine i have to start the engine.
The demoboard is using 26 and 27 for the keyboard.
Trying this code:
CON _clkmode = xtal1 + pll16x ' Crystal and PLL settings _xinfreq = 5_000_000 ' 5 MHz crystal x 16 = 80 MHz OBJ keyb : "PS2_HIDEngine" PUB Main keyb.HIDEngineStart(27, 26, -1, -1, %001, 0, 0) keyb.keyboardReady if result == true LED_Flash(16,30,5) PUB LED_Flash(Pin, Duration, Count) Duration := clkfreq / 100 * Duration dira[16..23]~~ repeat Count * 2 !outa[Pin] waitcnt(Duration + cnt)
I'm expecting to get the LED flashing if the keyboard is connected and ok.
"Returns true if the keyboard is present and ready and false if not."
I just need a kick in the b*t to get started...
Comments
John Abshier
I don't know about the PS2 engine of Kye's. However, that should not be a problem to track down your problem.
Have you tried commenting out the 3 lines (2 with keyb.xxx and the if line) and replace the if line with "repeat". This way you will just flash the led permanently.
Now, your clkfreq = 80,000,000 (probably) so...
duration := 80,000,000 / 100 * 30
:= 800,000 * 30
:= 24,000,000
So you are going to flash the led for
24,000,000 * 12.5ns = 300ms or ~1/3 second which you should see.
Personally, I prefer to use
DIR[Pin]:=1
After this works, then remove the repeat and put all lines back and just before the if line insert
result := true
This way you will prove if the PS2 engine is returning true or not true.
should be changed to:
As your code is now, result would still be zero.
Many methods do not return TRUE on sucessful. TRUE is also -1 ($FFFFFFFF). The method rxcheck in FullDuplexSerial returns -1 (TRUE) if no new byte was received.
Follow Cluso99's advice if adding "result :=" doesn't fix things (I don't think Cluso99 noticed it was missing in your code) .
Cluso99's advice has a typo. He left out the A in DIRA.
As your code is now:
Will not set "Pin" to and output if the parameter (Pin) is outside of the range 16 to 23.
Duane
Browsing the code i can see that it should return something in "result".
I have tried this:
So i guess the first ting is to check what the PS2_HIDEngine is actually returning.
Regarding the DIRA[] this was just added because i don't like the "debugger". Is is possible to send "debug" information to something other than the parallax serial terminal? I liked the BS2 editor better.
Tnx for the help so far... I'm probably going to post more newbequestions to get to learn the SPIN better.
result is a local variable inside a methode (subroutine) which holds the value that the methode returns. You can't access this variable outside the methode with "if result == true".
You can assign the returned value to a variable:
varX := keyb.keyboardReady
or you use the methode inside an expression:
if keyb.keyboardReady == true
you even can write:
Andy
PS2_HIDEngine has been abandoned for now.
So i'm using the original parallax "Keyboard" object and my "advanced" code actually works. The object is a bit limited but it's enough to get me started.
I can always use PS2_HIDEngine or similar later but i don't want to use more time on this now...
So problem solved.... so stay tuned for my next questions :smilewinkgrin: