class BirdbrainHummingbirdInput

Public Class Methods

dial(device, port) click to toggle source
# File lib/birdbrain/birdbrain_hummingbird_input.rb, line 21
def self.dial(device, port)
  sensor(device, port, 0.43478260869565216) # factor=100/230
end
distance(device, port) click to toggle source
# File lib/birdbrain/birdbrain_hummingbird_input.rb, line 17
def self.distance(device, port)
  sensor(device, port, 1.17) # factor=117/100
end
hummingbird?(device) click to toggle source
# File lib/birdbrain/birdbrain_hummingbird_input.rb, line 5
def self.hummingbird?(device)
  request_status(response_body('hummingbird', 'in', 'isHummingbird', 'static', device))
end
light(device, port) click to toggle source
# File lib/birdbrain/birdbrain_hummingbird_input.rb, line 9
def self.light(device, port)
  sensor(device, port, 0.39215686274509803) # factor=100/255
end
sound(device, port) click to toggle source
# File lib/birdbrain/birdbrain_hummingbird_input.rb, line 13
def self.sound(device, port)
  sensor(device, port, 0.7843137254901961) # factor=200/255
end
voltage(device, port) click to toggle source
# File lib/birdbrain/birdbrain_hummingbird_input.rb, line 25
def self.voltage(device, port)
  sensor(device, port, 0.012941176470588235) # factor=3.3/255
end

Private Class Methods

sensor(device, port, factor) click to toggle source
# File lib/birdbrain/birdbrain_hummingbird_input.rb, line 29
                     def self.sensor(device, port, factor)
  response = response_body('hummingbird', 'in', 'sensor', port, device)

  (response.nil? ? nil : bounds((response.to_f * factor).to_i, 0, 100))
end