Sha256: c9273a4c11b10ad06b2fe8cbed7e3711dbf0ad4e3a45c34440a7bcae11746e38
Contents?: true
Size: 881 Bytes
Versions: 2
Compression:
Stored size: 881 Bytes
Contents
module Brewby module Outputs class GPIO attr_reader :gpio_path, :pin def initialize options = {} @pin = options[:pin] @gpio_path = options[:gpio_path] || '/sys/class/gpio' initialize_gpio_pin initialize_gpio_direction end def initialize_gpio_pin unless File.exists? File.join(gpio_path, "gpio#{pin}", "value") File.write File.join(gpio_path, "export"), pin end end def initialize_gpio_direction File.write File.join(gpio_path, "gpio#{pin}", "direction"), 'out' end def on write(1) end def off write(0) end def on? '1' == File.read(File.join(gpio_path, "gpio#{pin}", "value")) end def write value File.write File.join(gpio_path, "gpio#{pin}", "value"), value end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
brewby-0.1.1 | lib/brewby/outputs/gpio.rb |
brewby-0.1.0 | lib/brewby/outputs/gpio.rb |