View Full Version : Mouse Mouse.Spin

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....

· 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.


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!)

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

I thought I was with;

I thought this would Call the Mouse.spin and return the buttons.

01-22-2008, 05:39 AM

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


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.

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)

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?

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:)


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.

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:)


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

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

ms : "Mouse"
TV : "TV_Text"

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

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

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

TV.out(1) 'Home

'echo mouse events in hex
TV.out(" ")
TV.out(" ")
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.


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...

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.

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.


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

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.