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

Ruby UP/Down Arrows

For general discussion related FlowStone

Re: Ruby UP/Down Arrows

Postby DaveyBoy » Fri Jul 27, 2018 1:37 pm

Well . . . this is going to be a lot more difficult than I expected.

I've been googling and reading the few Ruby books I have for a couple of days now and there doesn't seem to be much information available anywhere. Plenty of results for C & VB but hardly anything for Ruby, apart from a couple of Gems that we can't use (yet . .. :D )

I'm not asking anyone to code it for me but if someone could show me a simple example that I could adapt for my own purposes that would be great!

Failing that I'll just have to increase my clock speed :(
User avatar
DaveyBoy
 
Posts: 131
Joined: Wed May 11, 2016 9:18 pm
Location: Leeds UK

Re: Ruby UP/Down Arrows

Postby tiffy » Wed Aug 01, 2018 4:23 pm

DaveyBoy, did you try to ask for help here:

https://stackoverflow.com/questions/

If they can they will help you, just place your question clearly and under the applicable section.

Hope this help.
User avatar
tiffy
 
Posts: 400
Joined: Wed May 08, 2013 12:14 pm

Re: Ruby UP/Down Arrows

Postby DaveyBoy » Thu Aug 02, 2018 8:39 am

Hi Tiffy

No I haven't,I've been busy at work this last week so it's been on the back burner but thanks for the suggestion, that's my next port of call.

I haven't given up yet :)
User avatar
DaveyBoy
 
Posts: 131
Joined: Wed May 11, 2016 9:18 pm
Location: Leeds UK

Re: Ruby UP/Down Arrows

Postby DaveyBoy » Tue Aug 28, 2018 10:24 pm

Been playing with this again recently.
Not got anywhere with the windowproc suggestion but am getting a little bit nearer.

The attached FSM is a hybrid of Spogg's green suggestion, Tiffy's trigger limiter and my original hack.

It seems to be working as required ie instantaneously or key held down, and includes a ruby module to detect if the Flowstone window is on top or not (if there's a better way to do this please let me know), I am thinking this should work with exported exes and vsts but have not tested this.

As always any suggestions are welcome.
Feel free to use as you wish.

isKeyPressed Green Ruby - 2.fsm
(971 Bytes) Downloaded 905 times
User avatar
DaveyBoy
 
Posts: 131
Joined: Wed May 11, 2016 9:18 pm
Location: Leeds UK

Re: Ruby UP/Down Arrows

Postby tiffy » Wed Aug 29, 2018 8:15 pm

Hi Daveyboy, I am not sure what the schematic is supposed to do due to my lack of experience.

However, I had a look at the schematic and I noticed that the Tick 100 sends those triggers to all parts of your schematic none stop putting an unnecessary load on your computer.

Thus, I blocked most of if not all of the unnecessary triggers and your schematic still appears to be working as before.

Please check it out as I have left the Trigger Counters in the schematic so you can inspect and see that the triggers passing through the schematic now are only those when needed.

Cheers.
Attachments
isKeyPressed Green Ruby - 2.1.fsm
(1.94 KiB) Downloaded 880 times
User avatar
tiffy
 
Posts: 400
Joined: Wed May 08, 2013 12:14 pm

Re: Ruby UP/Down Arrows

Postby DaveyBoy » Sat Sep 01, 2018 2:40 pm

Hi Tiffy


The attached schematic shows what I am trying to do.

Once an item in the list is selected with the mouse the selection can then be changed with the up and down arrow keys.
The selection will respond to fast repetitive arrow key presses or will auto-change if the arrow key is held down . . just like on most windows programs.

I was trying to find a way to do this using ruby only without the green triggers flying around all over the place but so far without success.

If i block the triggers like you suggest it doesn't work as desired.

Hope this helps.

Select Demo.fsm
(10.53 KiB) Downloaded 917 times
User avatar
DaveyBoy
 
Posts: 131
Joined: Wed May 11, 2016 9:18 pm
Location: Leeds UK

Re: Ruby UP/Down Arrows

Postby HughBanton » Thu Feb 21, 2019 5:52 pm

I just came across this thread, apologies for being 6 months behind! I discovered earlier this week what you'd been doing because I was hunting for something similar using keyboard arrow keys, for pushing bar-graph elements up and down. Not exactly the same application but I thought I'd offer up a demo of my recent experiments in case they're of interest.

I've added a conventional auto-repeat feature, incorporating a delay after the first trigger, by calling the 'fast' method immediately after it to change gear. I've probably committed Ruby-crimes here (as usual), but it seems to basically work correctly - I'm sure someone will advise!

I've also added the 3 trigger-blocker modules, they're the type that check two consecutive values for a repeat (Not one of mine..). Seems to eliminate the need for the separate trigger input into Ruby, and stops the Tick25 propogating any further than necessary.

I've been surprised at the simplicity that I've arrived at here, particularly that 'input 100' does not seem to be needed in the 'if ..' lines in order to trigger a repeat event .. surprised at that and I'm not exactly clear what goes on here :?

up_down_auto.fsm
(6.98 KiB) Downloaded 821 times
User avatar
HughBanton
 
Posts: 265
Joined: Sat Apr 12, 2008 3:10 pm
Location: Evesham, Worcestershire

Re: Ruby UP/Down Arrows

Postby tulamide » Sat Feb 23, 2019 3:53 pm

Hugh, I've cleaned it up a little bit and tweaked it. I also commented in the RubyEdit, so that it hopefully explains what's happening sufficiently.
Attachments
up_down_auto[tweaks].fsm
(16.87 KiB) Downloaded 803 times
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2686
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby UP/Down Arrows

Postby HughBanton » Sun Feb 24, 2019 11:39 am

Thanks Tulamide. But strangely I can only get that to do as you specify if I re-insert 'clearEvents', like this :
Code: Select all
def event i,v,t
clearEvents
   if @up == true
      output 0, nil
   elsif @down == true
      output 1, nil
   end
   input 100, nil, t + 0.04
###
end

:?:
Like this you can indeed set the repeat rate at 0.04, or any other rate; otherwise it just seems to run at full speed and fall over.

Anyway, it's interesting, thanks for the explanation. So presumably a Ruby event is always - and only - called from physical inputs, yet can be sustained ad infinitum by a virtual input such as 'input 100' .. is that the case?

I've also since realised that my original '2-speed' auto-repeat only needs a single 'clearEvents' (same as the above); like this :
Code: Select all
def event i,v,t
   clearEvents
   if @up == true
      output 0, nil
      output 2, nil  # redraw
      scheduleMethod "fast", t + 0.4
   elsif @down == true
      output 1, nil
      output 2, nil # redraw
      scheduleMethod "fast", t + 0.4
   elsif @up == false && @down == false
      @t = 0.4
   end
   input 100, nil, t + @t
end

def fast
@t = 0.04
end

Seems quite useful I think, assuming it's legit (i.e. not a cpu disaster!)
Cheers
Hugh
User avatar
HughBanton
 
Posts: 265
Joined: Sat Apr 12, 2008 3:10 pm
Location: Evesham, Worcestershire

Re: Ruby UP/Down Arrows

Postby RJHollins » Sun Feb 24, 2019 11:57 am

Adding 'clearEvents' works better in my version of FS.
RJHollins
 
Posts: 1567
Joined: Thu Mar 08, 2012 7:58 pm

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 43 guests

cron