Add this line to your application's Gemfile:
gem 'animatedledstrip-client'
Or install with:
$ gem install animatedledstrip-client
An AnimationSender
is constructed with two arguments:
host
: The IP address of the server (as a string)port
: The port that the client should connect to (as an integer)
sender = AnimationSender.new("10.0.0.254", 5);
An AnimationSender
is started by calling the start()
method on the instance.
sender.start
To stop the AnimationSender
, call its end()
method.
sender.end
An animation can be sent to the server by creating an AnimationData
instance, then calling send_animation
with the instance as the argument.
cc = ColorContainer.new
cc.add_color 0xFF
cc.add_color 0xFF00
data = AnimationData.new
data.add_color cc
sender.send_animation data
The end of an animation can be sent to the server by creating an EndAnimation
instance, then calling send_end_animation
with the instance as the argument.
end_anim = EndAnimation.new
end_anim.id = "ANIM_ID"
sender.send_end_animation end_anim
A new section can be sent to the server by creating a Section
instance, then calling send_section
with the instance as the argument.
Note that changing num_leds
or physical_start
will have no effect on the new section.
sect = Section.new
sect.name = "SECTION"
sect.start_pixel = 5
sect.end_pixel = 30
sender.send_section sect
The Ruby library uses the following values for continuous
and direction
:
continuous
:nil
,true
,false
direction
:Direction::FORWARD
,Direction::BACKWARD
Supported animations are stored in the sender's supported_animations
hash.
Running animations are stored in the sender's running_animations
hash.
Animations are removed from the sender's running_animations
hash.
Sections are stored in the sender's sections
hash.
The strip's info is stored in the sender's strip_info
attribute.