Support

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

For general discussion related FlowStone

How to get accurate mouse capture values

Postby billv » Tue Aug 12, 2014 3:21 pm

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...?
Ruby Matrix Trigger.fsm
(82.49 KiB) Downloaded 850 times
Last edited by billv on Fri Aug 15, 2014 7:49 am, edited 1 time in total.
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: Ruby Drag Controller not accurate

Postby trogluddite » Tue Aug 12, 2014 10:04 pm

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...
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!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

How to get accurate mouse capture values

Postby billv » Tue Aug 12, 2014 11:28 pm

Great...thanks Trog... :)
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: How to get accurate mouse capture values

Postby billv » Tue Aug 19, 2014 9:46 am

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
Code: Select all
def mouseMoveCaptured x,y
    @x = x.to_i
    output 0, @x
end
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: How to get accurate mouse capture values

Postby KG_is_back » Tue Aug 19, 2014 11:02 am

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 800 times
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: How to get accurate mouse capture values

Postby billv » Tue Aug 19, 2014 12:46 pm

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...
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: How to get accurate mouse capture values

Postby tester » Tue Aug 19, 2014 2:31 pm

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.
Need to take a break? I have something right for you.
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

Postby billv » Wed Aug 20, 2014 6:37 am

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... :roll:
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.
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: How to get accurate mouse capture values

Postby billv » Fri Nov 21, 2014 6:38 am

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
ScreenShot014.png
ScreenShot014.png (1.83 KiB) Viewed 14545 times

Draw issue.fsm
(1.26 KiB) Downloaded 810 times


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... :?
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: How to get accurate mouse capture values

Postby tulamide » Fri Nov 21, 2014 11:42 am

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!


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... :?
[/quote]
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

Next

Return to General

Who is online

Users browsing this forum: No registered users and 49 guests