Class: Ledstrip::Effects::Base
- Inherits:
-
Object
- Object
- Ledstrip::Effects::Base
show all
- Defined in:
- lib/ledstrip/effects/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(strip, options = {}) ⇒ Base
Returns a new instance of Base.
7
8
9
10
11
12
|
# File 'lib/ledstrip/effects/base.rb', line 7
def initialize(strip, options = {})
@strip = strip
@options = options
@running = false
@frame = 1
end
|
Instance Attribute Details
#running ⇒ Object
Returns the value of attribute running.
5
6
7
|
# File 'lib/ledstrip/effects/base.rb', line 5
def running
@running
end
|
Instance Method Details
#run ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/ledstrip/effects/base.rb', line 33
def run
Thread.new do
while(running) do
tick
sleep sleep_time
end
end
end
|
#sleep_time ⇒ Object
14
15
16
|
# File 'lib/ledstrip/effects/base.rb', line 14
def sleep_time
1
end
|
#start ⇒ Object
18
19
20
21
|
# File 'lib/ledstrip/effects/base.rb', line 18
def start
@running = true
run
end
|
#stop ⇒ Object
23
24
25
|
# File 'lib/ledstrip/effects/base.rb', line 23
def stop
@running = false
end
|
#tick ⇒ Object
27
28
29
30
31
|
# File 'lib/ledstrip/effects/base.rb', line 27
def tick
@strip.leds = step(@strip.leds)
@strip.draw
@frame += 1
end
|