Introducing the Humble_RPi-plugin-TiltSensor gem

Testing the plugin

require 'humble_rpi-plugin-tiltsensor'

class Echo

  def notice(s)
    puts "%s: %s" % [Time.now, s]
  end
end

sensor = HumbleRPiPluginTiltSensor.new(settings: {pins: [4], \
              duration: '10 seconds'}, variables: {notifier: Echo.new})
sensor.start

Output:

2016-03-05 18:37:05 +0000: pi/tilt/0: detected 7 times within the past 10 seconds
2016-03-05 18:37:27 +0000: pi/tilt/0: detected
2016-03-05 18:37:37 +0000: pi/tilt/0: detected 14 times within the past 10 seconds

Using the plugin with the HumbleRPi gem

require 'humble_rpi'
require 'humble_rpi-plugin-tiltsensor'

r = HumbleRPi.new device_name: 'ottavia', sps_address: '192.168.4.140',\
  plugins: {TiltSensor: {pins: [4]} }
r.start

Resources