Class: AVR::Oscillator
- Inherits:
-
Clock
- Object
- Clock
- AVR::Oscillator
show all
- Extended by:
- T::Sig
- Defined in:
- lib/avr/oscillator.rb
Instance Attribute Summary
Attributes inherited from Clock
#count, #name, #scale, #sinks, #ticks, #watches
Instance Method Summary
collapse
Methods inherited from Clock
#clear_sinks, #initialize, #notify_at_tick, #push_sink, #tick, #unshift_sink
Constructor Details
This class inherits a constructor from AVR::Clock
Instance Method Details
#infinite ⇒ Object
9
10
11
|
# File 'lib/avr/oscillator.rb', line 9
def infinite
[true].cycle
end
|
#run(limit = infinite) ⇒ Object
22
23
24
25
26
|
# File 'lib/avr/oscillator.rb', line 22
def run(limit = infinite)
start_ticks = ticks
limit.each { tick }
ticks - start_ticks
end
|
#run_timed(time) ⇒ Object
29
30
31
|
# File 'lib/avr/oscillator.rb', line 29
def run_timed(time)
run(time_limit(time))
end
|
#time_limit(time) ⇒ Object
14
15
16
17
18
19
|
# File 'lib/avr/oscillator.rb', line 14
def time_limit(time)
Enumerator.new do |y|
end_time = Time.now.to_f + time
y << true while Time.now.to_f < end_time
end
end
|