Skip to content

Commit

Permalink
emit :temp event #1
Browse files Browse the repository at this point in the history
  • Loading branch information
shokai committed Aug 7, 2013
1 parent 97aea48 commit b7fa852
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bin/arduino_ir_remote
Expand Up @@ -8,6 +8,7 @@ if ARGV.empty?
end

ir = IR::Remote.new ARGV.shift
ir.temp_pin = 0
ir.on :read do |data|
p data
end
Expand All @@ -17,6 +18,9 @@ end
ir.on :analog do |pin, value|
# puts "[analog#{pin}] #{value}"
end
ir.on :temp do |temp|
puts "temp #{temp}"
end

last_ir_data = ""

Expand Down
6 changes: 6 additions & 0 deletions libs/ir_remote.rb
Expand Up @@ -6,6 +6,7 @@
module IR
class Remote
include EventEmitter
attr_accessor :temp_pin

def initialize(port)
@state = nil
Expand All @@ -15,6 +16,11 @@ def initialize(port)
process_input @sp.gets.strip
end
end
@temp_pin = 0
this = self
on :analog do |pin, value|
this.emit :temp, value.to_f*5*100/1024 if pin == @temp_pin
end
end

private
Expand Down

0 comments on commit b7fa852

Please sign in to comment.