If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
How to get accurate mouse capture values
15 posts
• Page 1 of 2 • 1, 2
How to get accurate mouse capture values
I built a ruby version of the on/off matrix trigger.
when dragging at high speeds its not accurate.
can anyone help me avoid the empty spaces on a fast drag...?
when dragging at high speeds its not accurate.
can anyone help me avoid the empty spaces on a fast drag...?
Last edited by billv on Fri Aug 15, 2014 7:49 am, edited 1 time in total.
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: Ruby Drag Controller not accurate
Hi Billy,
To be fair, a "green" version would do the same thing. The mouse is only polled at a relatively slow speed - so if the mouse has moved more than one box width in between "samples" of the position, there may be boxes where the 'x' position was never in the box. The problem will get worse the smaller you make the boxes
To make it reliable, you need to memorise previous mouse positions, so that you know the complete range of boxes which the mouse passed over.
In "psuedo-code" it would be something like this...
To be fair, a "green" version would do the same thing. The mouse is only polled at a relatively slow speed - so if the mouse has moved more than one box width in between "samples" of the position, there may be boxes where the 'x' position was never in the box. The problem will get worse the smaller you make the boxes
To make it reliable, you need to memorise previous mouse positions, so that you know the complete range of boxes which the mouse passed over.
In "psuedo-code" it would be something like this...
- Code: Select all
def mouseLdown(x,y)
if (in a box)
@last_box = (calculation using x)
@box_setting = (make boxes on or off)
@boxes[@last_box] = @box_setting
captureMouse etc.
end
end
def mouseMoveCaptured(x,y)
box_now = (calculation using x)
(@last_box..box_now).each{|x| @boxes[x] = @box_setting}
@last_box = box_now
end
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
How to get accurate mouse capture values
Great...thanks Trog...
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: How to get accurate mouse capture values
Have made zero progress on this Trog, just havn't got the skills to apply your "psuedo-code"
to my modules.. I understand the principal, same issue
I had back in green many years ago when myco fixed it with the Float Array Draw Prim.
So I need some more help here if possible..
Trog, I'm defiantly not asking for a full fix on my fsm....
I need to get this technique 'down', otherwise my new draw wave/matrix trigger/modulators
are all dead in the water, with my main project.
Can we ditch my fsm and break the issue down somewhat.....?
My real question seems to be...
How do i get correct output for this one variable
to my modules.. I understand the principal, same issue
I had back in green many years ago when myco fixed it with the Float Array Draw Prim.
So I need some more help here if possible..
Trog, I'm defiantly not asking for a full fix on my fsm....
I need to get this technique 'down', otherwise my new draw wave/matrix trigger/modulators
are all dead in the water, with my main project.
Can we ditch my fsm and break the issue down somewhat.....?
My real question seems to be...
How do i get correct output for this one variable
- Code: Select all
def mouseMoveCaptured x,y
@x = x.to_i
output 0, @x
end
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: How to get accurate mouse capture values
Try this one. You manually enter the x step. When you are draging the mouse and x difference between current and previous position is greater then the x step, the schematic automatically interpolates the missing values, sending outputs on each one.
- Attachments
-
- MouseDrag_interpolated.fsm
- (618 Bytes) Downloaded 801 times
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: How to get accurate mouse capture values
KG_is_back wrote:x difference between current and previous position
Sounds like what Trog was trying to tell me in a way, to "memorise previous mouse positions".
Seems to work ok....code looks easy too work with...
I should be able to get a result with this...
Thanks KG...
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: How to get accurate mouse capture values
I think you don't need to complicate things, just change the method. Use the whole area (and not individual ones), and simply calculate distances between mouse drag and mouse release (start-stop points). This will tell you from-where-to-where turn on or off, and unnoticable inaccuracy will be only on border release.
Mouse rate under windows is not that fast (by default around 100Hz? but it's "green" 100Hz), especially if you use faster pointer.
Mouse rate under windows is not that fast (by default around 100Hz? but it's "green" 100Hz), especially if you use faster pointer.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: How to get accurate mouse capture values
Thanks tester....yeh method is wrong..even the basic on/off(single switch) dosnt
work right. new alt methods arn't coming easy...I spent a lot of last week trying just that,
and ended up rewriting the same way all over again...
I try, but just don't have the brain of a "coder"....it's not a good sign....
Just spent my first few hours with KG's fsm... trickier that i thought...
Hopefully i can work it out eventually and avoid plan B.
work right. new alt methods arn't coming easy...I spent a lot of last week trying just that,
and ended up rewriting the same way all over again...
I try, but just don't have the brain of a "coder"....it's not a good sign....
Just spent my first few hours with KG's fsm... trickier that i thought...
Hopefully i can work it out eventually and avoid plan B.
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: How to get accurate mouse capture values
It's a couple of months down the track now and i still can't get this technique right.
Closest I've got is with KG's fsm...
But have a problem i can't work out...
Below, the top line is mouse capture from dragging left to right
the bottom line is mouse capture from dragging right to left
Though about this method a lot, but If I have to use the mouse release to calculate, how do I
draw the mouse capture while the mouse is still down?
i havn't made the attempt with this method cause i still can't get my head around that...
Closest I've got is with KG's fsm...
But have a problem i can't work out...
Below, the top line is mouse capture from dragging left to right
the bottom line is mouse capture from dragging right to left
tester wrote:simply calculate distances between mouse drag and mouse release (start-stop points). This will tell you from-where-to-where turn on or off
Though about this method a lot, but If I have to use the mouse release to calculate, how do I
draw the mouse capture while the mouse is still down?
i havn't made the attempt with this method cause i still can't get my head around that...
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: How to get accurate mouse capture values
billv wrote:But have a problem i can't work out...
Below, the top line is mouse capture from dragging left to right
the bottom line is mouse capture from dragging right to left
The right to left issue could have given you a hint: Indeed it's your code. You use a range to iterate, but ranges only go from left to right (or up, if that's the better image for you). So, a range of -5..0 works, while 0..-5 can't work. Catching the mouse delta will go negative in your calculation (x-@a) when moving to the left (x gets smaller).
I've corrected your code by splitting it into two parts. With numeric.angle (which returns 0 for positive and pi for negative) the ranges are either 0..shift for positives, or shift..0 for negatives.
I hope this description wasn't confusing!
[/quote]billv wrote:Though about this method a lot, but If I have to use the mouse release to calculate, how do I
draw the mouse capture while the mouse is still down?
i havn't made the attempt with this method cause i still can't get my head around that...
This is not suitable for what you intend to do, so don't think about it anymore
- Attachments
-
- Draw issue [tulamide].fsm
- (1.94 KiB) Downloaded 782 times
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
15 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: Google [Bot] and 66 guests