Class: MatrixCreator::Everloop::Animation
- Inherits:
-
Object
- Object
- MatrixCreator::Everloop::Animation
- Defined in:
- lib/matrix_creator/everloop/animation.rb
Overview
Class to be inherited by Animations
Constant Summary collapse
- ANIMATION_SPEED =
Interval between animation updates in milliseconds
0.1
Class Method Summary collapse
-
.run(color = Color::WHITE) { ... } ⇒ Object
Run a block of code while displaying an animation on the Everloop driver.
Instance Method Summary collapse
-
#destroy_context ⇒ Object
Sends a request to destroy the context of the everloop comm instance.
Class Method Details
.run(color = Color::WHITE) { ... } ⇒ Object
Run a block of code while displaying an animation on the Everloop driver
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# 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 |
Instance Method Details
#destroy_context ⇒ Object
Sends a request to destroy the context of the everloop comm instance
62 63 64 |
# File 'lib/matrix_creator/everloop/animation.rb', line 62 def destroy_context @everloop_comm.destroy end |