Class: GoEasyButton
- Inherits:
-
Object
- Object
- GoEasyButton
- Defined in:
- lib/go_easy_btn.rb
Constant Summary collapse
- BTN_COMMAND =
'PRESSED'
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ GoEasyButton
constructor
A new instance of GoEasyButton.
- #make_it_easy ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ GoEasyButton
Returns a new instance of GoEasyButton.
8 9 10 11 12 13 14 15 |
# File 'lib/go_easy_btn.rb', line 8 def initialize( = {}) raise Errno::ENOENT, 'not found serial port has been' unless File.exists? [:dev] @cmd = [:cmd] @device = [:dev] @baud = [:baud] || 115200 @count = 0 @start_time = Time.now end |
Instance Method Details
#make_it_easy ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/go_easy_btn.rb', line 17 def make_it_easy SerialPort.open @device, @baud do |port| begin puts "Making It Easy\n\n" while data = port.readline run_command if data.strip == BTN_COMMAND end rescue Interrupt puts "\rgoing bye bye now", stats(true) rescue EOFError handle_disconnect end end end |