class MatrixCreator::Everloop::Animation
Class to be inherited by Animations
Constants
- ANIMATION_SPEED
Interval between animation updates in milliseconds
Public Class Methods
run(color = Color::WHITE) { || ... }
click to toggle source
Run a block of code while displaying an animation on the Everloop
driver
@param color [Hash] with the rgb+w values for the color @yield Block of code to be executed while displaying the spinner @return response from the block of code execution
@example Run a block of code and display a spinner until it finishes
MatrixCreator::Everloop::Spinner.run { // Do Something }
@example Run a block of code and display a green spinner until it finishes
color = MatrixCreator::Everloop::Color::GREEN MatrixCreator::Everloop::Spinner.run(color) { // Do Something }
@example Run a block of code and display a pulse until it finishes
MatrixCreator::Everloop::Pulse.run { // Do Something }
# File lib/matrix_creator/everloop/animation.rb, line 36 def self.run(color = Color::WHITE, &block) result = nil code_thread = Thread.new do Thread.current[:finished] = false result = yield if block Thread.current[:finished] = true end animation_thread = Thread.new do animation = new(color, code_thread) animation.loop_animation animation.destroy_context end # Turn off the leds on the Everloop driver code_thread.join animation_thread.join Everloop.modify_color(Color::OFF) # Return result of the code block result end
Public Instance Methods
destroy_context()
click to toggle source
Sends a request to destroy the context of the everloop comm instance
# File lib/matrix_creator/everloop/animation.rb, line 62 def destroy_context @everloop_comm.destroy end