Shop OBEX P1 Docs P2 Docs Learn Events
Mouse Mouse.Spin — Parallax Forums

Mouse Mouse.Spin

bbakerbbaker Posts: 16
edited 2008-01-23 03:35 in Propeller 1
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))

·

Comments

  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-01-21 21:16
    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
    Got an SD card? - PropDOS
    A Living Propeller FAQ - The Propeller Wiki
    (Got the Knowledge? Got a Moment? Add something today!)

  • bbakerbbaker Posts: 16
    edited 2008-01-21 21:27
    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.
  • AribaAriba Posts: 2,685
    edited 2008-01-21 22:39
    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
  • bbakerbbaker Posts: 16
    edited 2008-01-21 22:46
    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.
  • RinksCustomsRinksCustoms Posts: 531
    edited 2008-01-22 04:27
    You may want to add :
    waitcnt(clkfreq / 4 + cnt)

    to your repeat loop to stabilize the display

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

    http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
  • bbakerbbaker Posts: 16
    edited 2008-01-22 05:12
    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_rjo_ Posts: 1,825
    edited 2008-01-22 06:15
    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[noparse]:)[/noparse]

    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[noparse]:)[/noparse]


    Rich
  • rjo_rjo_ Posts: 1,825
    edited 2008-01-22 06:27
    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[noparse]:)[/noparse]

    Rich
  • AribaAriba Posts: 2,685
    edited 2008-01-22 11:32
    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
  • bbakerbbaker Posts: 16
    edited 2008-01-22 15:49
    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.
  • bbakerbbaker Posts: 16
    edited 2008-01-23 00:46
    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_rjo_ Posts: 1,825
    edited 2008-01-23 03:35
    I knew you were up to something good[noparse]:)[/noparse] There is very little posted about stepper implementation... hope you can share some of it.
Sign In or Register to comment.