Class: RfBeam::KLD7::Streamer
- Inherits:
-
Object
- Object
- RfBeam::KLD7::Streamer
- Defined in:
- lib/rfbeam/kld7/streamer.rb
Instance Attribute Summary collapse
-
#radar ⇒ Object
Returns the value of attribute radar.
Instance Method Summary collapse
-
#initialize(radar) ⇒ Streamer
constructor
A new instance of Streamer.
- #monitor_keypress ⇒ Object
- #rfft ⇒ Object
Constructor Details
#initialize(radar) ⇒ Streamer
Returns a new instance of Streamer.
13 14 15 |
# File 'lib/rfbeam/kld7/streamer.rb', line 13 def initialize(radar) @radar = radar end |
Instance Attribute Details
#radar ⇒ Object
Returns the value of attribute radar.
11 12 13 |
# File 'lib/rfbeam/kld7/streamer.rb', line 11 def radar @radar end |
Instance Method Details
#monitor_keypress ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/rfbeam/kld7/streamer.rb', line 17 def monitor_keypress loop do key = $stdin.getch if key.casecmp('q').zero? @stop_streaming = true break end end end |
#rfft ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rfbeam/kld7/streamer.rb', line 27 def rfft out = StringIO.new def out.tty? true end Thread.new { monitor_keypress } loop do out.truncate(0) plot = rfft_plot(@radar) plot.render(out) lines = out.string.lines lines.each { |line| $stdout.print "\r#{line}" } $stdout.print "\e[0J" $stdout.flush break if @stop_streaming n = lines.count $stdout.print "\e[#{n}F" end end |