3-Color Dynamic LED Switch

Post any examples or modules that you want to share here
Post Reply
User avatar
pwesynthmaker
Posts: 82
Joined: Fri Feb 12, 2016 7:18 pm

3-Color Dynamic LED Switch

Post by pwesynthmaker »

My 'almost-all-my-very-own ruby code' .fsm schematic.
A LED switch with 3-colored 'dynamic' text and 'float' value input/output.
.
Download Link:
https://www.inventorefx.com/_ifxfstone/3colorubysw.zip

Here is the Ruby Code:

==========

# ledsw32pxmultilbl ruby code

def draw v

# Calculate the rect to draw the text inside
# Rectangle width & height = relative to font size w/word wrap
# + led diam
rect1 = [0,-3.5,v.width,v.height]
rect2 = [0,0.75,v.width,v.height]
rect3 = [0,4,v.width,v.height]

# Setup font1 and alignment
font1 = Font.new "Arial",1.75,"bold"
sf1 = StringFormat.new
sf1.setAlignment "center"
sf1.setLineAlignment "center"

# Draw the label
v.drawString @label1,font1,sf1,rect1,(Brush.new @color1)


# Setup font2 and alignment
font2 = Font.new "Arial",1.75,"bold"
sf2 = StringFormat.new
sf2.setAlignment "center"
sf2.setLineAlignment "center"

# Draw the label
v.drawString @label2,font2,sf2,rect2,(Brush.new @color2)


# Setup font3 and alignment
font3 = Font.new "Arial",1.75,"bold"
sf3 = StringFormat.new
sf3.setAlignment "center"
sf3.setLineAlignment "center"

# Draw the label
v.drawString @label3,font3,sf3,rect3,(Brush.new @color3)

end

def event i,v
redraw 0
end

==========
Attachments
3colorubysw.jpg
3colorubysw.jpg (35.47 KiB) Viewed 11995 times
https://www.inventorefx.com/_ifxfstone/_ifxfstone.htm
Inventor eFX Technology FlowStone WebPage

https://www.inventorefx.com/
Inventor eFX Technology
Post Reply