Page 3 of 5

Re: Radio buttons under preset manager

Posted: Sun Aug 18, 2013 6:10 pm
by RJHollins
thanks for the encouraging words, billv 8-)

The last 6 months since I started with SM, and then the recent transition to FS has been very interesting. I was intriqued by the 'circuit board' [schematic] concept. Adding RUBY to FS has now expanded the Universe.

Although I still struggle to hit the '#" and often times hit the '@' key instead :roll:

As I played with with the Radio button by changing to Case...Select, I found that I can further reduce the coding.
For each of the 'WHEN' statements, we don't [seem] to need the 'i=' part.

Code: Select all

when i=4 

We can simplify to

Code: Select all

when 4

So the new code can be:

Code: Select all

def event i,v
 
case i
when 0
   output 0,0 
when 1 
   output 0,1
when 2 
   output 0,2
when 3 
   output 0,3
when 4 
   output 0,4
when 5 
   output 0,5
when 6 
   output 0,6
when 7 
   output 0,7
when 8 
   output 0,8 
end

end


This [probably] has zero influence on code efficiency or optimization ... but it can sometimes be easier to type and read. ;)

Fun stuff ! Thanks 8-)

Re: Radio buttons under preset manager

Posted: Sun Aug 18, 2013 8:50 pm
by billv
RJHollins wrote:by changing to Case...Select

Yeh RJ, that's probably much better.
I remember the "case...select" thing from back when i tried to learn VB....
but it never sunk into my repertoire...I'm still writing like a baby... :lol:

I'm finding it real hard to process all the new things I'm learning....
Seems like for every new thing I learn, there's another dozen things I pick up in
the process, that i have no time for and have to backburner it, hoping to get back to it
in the future.

Can be frustrating how powerful this software is...

Re: Radio buttons under preset manager

Posted: Mon Aug 19, 2013 5:39 am
by RJHollins
I'm going through a similar experience like that. :lol:

If it wasn't for the forums, and the kind/smart members here ... my 'projects' would be half baked ...if that.

I try not to get too overwhelmed. I do make it a point to follow every thread I can. Some of them are well above my current understanding, which is fine for the moment. There have been several times I've gone back later [often from a search], and have a new perspective and a better sense. Then I'll try to do something that should be so easy, and just have all kinds of trouble with it :roll: Oh well ... as long as I keep improving and have fun with the challenge.
8-)

Re: Radio buttons under preset manager

Posted: Mon Aug 19, 2013 10:10 am
by billv
I got to share a "Graphics Fix" for the original selector I posted.
Was working on my Pitch Mod...
one trigger has got to move 20 selectors and 10 knobs....
end result wrong...redraw's not fast enough and not "clean"....
graphics section re-drawing at three points.....background,foreground and text colour. :roll:
Now the background and green text are not re-drawn...the black text copied into every forground,
so the text is not re-drawn either, just appears with the foreground on selection.
animal list.Selector_Graphics_Fix.fsm
(2.28 KiB) Downloaded 1020 times

Re-uploaded( forgot to connect b/ground to gui)

Re: Radio buttons under preset manager

Posted: Mon Aug 19, 2013 3:14 pm
by TrojakEW
Too many componnents for this. I would recommend you great trogluddite post with example in GRAPHICS CLASSES 2_001.fsm
http://dsprobotics.com/support/viewtopic.php?f=3&t=1114
There is exactly what you need and only one ruby module.

Re: Radio buttons under preset manager

Posted: Mon Aug 19, 2013 8:40 pm
by billv
TrojakEW wrote:There is exactly what you need and only one ruby module.

Thanks for the tip :) ....got that fsm....will take a look at method later when i get home,
see if i can work out how it's done..Was way over my head last time i looked...maybe
now I can understand it a bit more....

Re: Radio buttons under preset manager

Posted: Tue Aug 20, 2013 12:37 pm
by billv
That's a great example from Trog........

Re: Radio buttons under preset manager

Posted: Wed Aug 21, 2013 8:37 am
by billv
...but hard to modify for learner....
That's the problem with Trog...he writes code in "genius" :D .... hard to access...
I failed yesterday to mod his selector to suit...at 3 different places....
So his technique is out of reach for me at the moment.
But i saw the results of his methods...and this is a MUST HAVE for my current project.
Had no choice now but to slam on the brakes.....go into the ruby "graphics" section
for the first time...work out how to do it....
User guide had the info i needed...almost there....

Re: Radio buttons under preset manager

Posted: Wed Aug 21, 2013 1:22 pm
by billv
My first attempt is working :) . Strung about 50 together and its clean...
Seems like its more work to modify than Trogs though... :lol:
But it's written in "dumb"..so for me easy to work with so far..
Suggestions welcome....
BV selector fix.fsm
(1.81 KiB) Downloaded 1025 times

Code: Select all

def draw v
#OUTPUT VALUE IN GREEN
output 0,@index

#MY LABELS
@mystring0 = "1/1"
@mystring1 = "1/4"
@mystring2 = "1/8"
@mystring3 = "16"

#FONT
font = Font.new "Arial",1.1,"bold"
sf = StringFormat.new
sf.setAlignment "center"
sf.setLineAlignment "center"

#CREATE BACKDROP
v.drawBitmap @background,[0,0,2,2]
v.drawBitmap @background,[0,2,2,2]
v.drawBitmap @background,[0,4,2,2]
v.drawBitmap @background,[0,6,2,2]
        ###DRAW BACKGROUNDS
#DRAW BACKGROUND 1
   rect = [0,0,2,2]
    v.drawString @mystring0,font,sf,rect,(Brush.new @backtext)
#DRAW BACKGROUND 2
   rect = [0,2,2,2]
    v.drawString @mystring1,font,sf,rect,(Brush.new @backtext)   
#DRAW BACKGROUND 3
   rect = [0,4,2,2]
    v.drawString @mystring2,font,sf,rect,(Brush.new @backtext)
#DRAW BACKGROUND 4
   rect = [0,6,2,2]
    v.drawString @mystring3,font,sf,rect,(Brush.new @backtext)
       
#MOVE THE GRAPHIC
if @index==0 then @level =0 end
if @index==1 then @level =2 end
if @index==2 then @level =4 end
if @index==3 then @level =6 end
v.drawBitmap @foreground,[0,@level,2,2]

#DRAW THE SELECTED TEXT
   rect = [0,@level,2,2]
   
#CHANGE THE STRING   
if @index==0 then v.drawString @mystring0,font,sf,rect,(Brush.new @color) end
if @index==1 then v.drawString @mystring1,font,sf,rect,(Brush.new @color) end
if @index==2 then v.drawString @mystring2,font,sf,rect,(Brush.new @color) end
if @index==3 then v.drawString @mystring3,font,sf,rect,(Brush.new @color) end

#REDRAW THE GRAPHIC
redraw @state
   
end

Re: Radio buttons under preset manager

Posted: Thu Aug 22, 2013 6:39 am
by RJHollins
Wow ... everyone must be so busy ... anyway,

This is some fine work here billv !!

These are nice GUI interfaces to have available. Hope to look through the coding to see if I can understand :lol:

I've been playing with arrays and strings in RUBY ... not too exciting ... except when I get something to work !

I noticed you put the CASE...SELECT to work in your last post. Looks like you have it down nicely :)

I do have a RUBY question that you might help me with ... I've noticed the use of the 'V' for some of the INs and OUTs. I need to to some manual reading, but was wondering if anyone could help explain what data is using [or needing] the 'V' type ???

Thanks!