PDA

View Full Version : Mouse Mouse.Spin



bbaker
01-22-2008, 04:06 AM
I have a project working with a ksyboard and I want to add a mouse. I have mouse.spin but I can't get it to work. Does anyone have a MouseDemo.spin. Or can someone look at this and see what I am doing wrong

To start I just want to do a REPEAT and display on TV out values....

OBJ
· Num·· :······ "Numbers"
· TV··· :······ "TV_Terminal"
· kb··· :······ "keyboard"
· ms··· :······ "mouse"
PUB Video | key, mouse
· NewFilmCount := FilmCount
· Newfocus := Focus
· COGNEW(FilmCountPub, @Stack)
· COGNEW(Systemtrigger, @Stack+ 100)
· COGNEW(ServoControl, @Stack+200)
· COGNEW(AudioClk, @Stack+300)
· Num.Init··································· 'Initialize Numbers··
· TV.Start(12)······························· 'Start TV Terminal···
· kb.start(26, 27)··························· 'start the keyboard
· ms.start(24, 25)··························· 'start the mouse
····
·
· ms.delta_reset
· repeat······················ 'Monitor Keyboard
··· TV.dec(ms.buttons)
··· TV.out(" ")
··· key := kb.getkey
··· TV.Str(Num.ToStr(key Num#DEC))
··· TV.Str(Num.ToStr(ms.abs_y, Num#DEC))

·

Oldbitcollector (Jeff)
01-22-2008, 04:16 AM
I'm not near my propeller to check this, but right off the bat it looks like you aren't requesting data from the
mouse object inside your "repeat" loop. I see keyboard data, but no mouse.

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?

Getting started with the Protoboard? - Propeller Cookbook (http://ucontroller.com/Propeller%20Protoboard%20Designs%20for%20the%20Beg inner.pdf)
Got an SD card? - PropDOS (http://www.orrtech.net/propdos/)
A Living Propeller FAQ - The Propeller Wiki (http://propeller.wikispaces.com/)
(Got the Knowledge? Got a Moment? Add something today!)

bbaker
01-22-2008, 04:27 AM
Thank you for a quick reply.

I thought I was with;

TV.dec(ms.buttons)
I thought this would Call the Mouse.spin and return the buttons.

Ariba
01-22-2008, 05:39 AM
bbaker

The getkey functions waits until a key is pressed. So your Mouse is only requested one time, when you press a key on the Keyboard.
You can use gotkey to test, if a key is pressed, then the loop will not be stopped:



if kb.gotkey
key := kb.getkey
TV.str(......




Andy

bbaker
01-22-2008, 05:46 AM
I think I might be doing it right but it is not recognizing my mouse. I want to mouse.spin and I set abs_y to 8 and it it returned a value of 8.

RinksCustoms
01-22-2008, 11:27 AM
You may want to add :
waitcnt(clkfreq / 4 + cnt)

to your repeat loop to stabilize the display

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought

http://folding.stanford.edu/ (http://folding.stanford.edu/)·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats. (http://vspx27.stanford.edu/cgi-bin/main.py?qtype=teampage&teamnum=78528)

bbaker
01-22-2008, 12:12 PM
I think the display looks OK. All I want to do is get a value from the mouse, x, y and two buttons. Does any one know how to do that?

rjo_
01-22-2008, 01:15 PM
I have everything torn up... moving from one room to another, so my fleet of propellers is buried beneath one mound and my Windows computer is buried beneath a different mound right now... but mouse.spin does work. So, if it isn't working for you, it is either a hardware or a software problem... Andy is a pretty smart guy. He doesn't think your code should work... so, I'm betting that he's right. My advice is: take your keyboard calls out and just look at the mouse functions... then put your keyboard calls back in and see what happens.

You haven't said anything about what board you are using... so, you will want to check the schematics and make sure that your pin assignments for the mouse are right (which you probably have already done:)

From your snippet it looks like you are doing something fairly interesting.... kind of frustrating to get held up on a mouse function, huh? That's what I love about the Prop... it makes the impossible possible and the mundane absolutely captivating:)


Rich

rjo_
01-22-2008, 01:27 PM
By the way, the forum contains all kinds of interesting "time capsules."

You might find this one interesting. It is about mouse.spin from May 2006.
http://forums.parallax.com/forums/default.aspx?f=25&m=126471

It won't resolve your issue. I'm posting it as encouragement for recent prop converts and as a reminder of how much has been accomplished in the last 18 months.

The simplest things are only simple, once you understand them:)

Rich

Ariba
01-22-2008, 06:32 PM
Try this little Test Code:



{{ Mouse Test }}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

OBJ
ms : "Mouse"
TV : "TV_Text"

PUB Main
'start the terminal
TV.start(12)
TV.str(string("Mouse Test"))

'start the mouse
ms.start(24, 25)

waitcnt(clkfreq*2 + cnt)
TV.str(string(13,13,"Mouse Present: "))
TV.dec(ms.present)

repeat
TV.out(1) 'Home

'echo mouse events in hex
TV.out("B")
TV.out(":")
TV.dec(ms.buttons)
TV.out(" ")
TV.out("X")
TV.out(":")
TV.dec(ms.abs_x)
TV.out(" ")
TV.out("Y")
TV.out(":")
TV.dec(ms.abs_y)
TV.out(" ")
TV.out(" ")

waitcnt(clkfreq/10 + cnt)




Do you get a value > 0 for Present?
If not, I would say you have a Hardware problem.

Andy

bbaker
01-22-2008, 10:49 PM
Thank you for the test code. I will try this and I hope it works. I pulled this mouse of a working PC. We will see what happens...

rjo_
I am build this project to replace several timing circuits that are not stable enough. They work well for about 10 minutes and then they drift about .05%. and I also need a 48khz PLL locked to a 24hz pulse. There is one variable, I need to adjust in realtime in 1Milliseconds, at setup time, So, I thought I would use a mouse and then discounted it.

I think the Prop makes the most sense. I am going to use another Prop to control several stepping motors and 1 servo. The steppers are 16 degree and I have them geared 2:1, making my two tables move in about 128th of an inch. the second table has a 1 inch travel and moves at .5MM incerments.

bbaker
01-23-2008, 07:46 AM
THANK YOU very much,

The mouse works, I think it was the getkey was stopping it. The mouse.spin is now part of my two apps.

THANKS

I also ordered two more Props with boards......

rjo_
01-23-2008, 10:35 AM
I knew you were up to something good:) There is very little posted about stepper implementation... hope you can share some of it.