Module: ChipGPIO
- Defined in:
- lib/chip-gpio/SoftwareSpi.rb,
lib/chip-gpio.rb,
lib/chip-gpio/Pin.rb,
lib/chip-gpio/HardwareSpi.rb
Overview
*** TODO *** Reads *** Baudrate *** Phase
Defined Under Namespace
Modules: Pin Classes: HardwareSPI, SoftwareSPI
Class Method Summary collapse
Class Method Details
.get_pins ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/chip-gpio/Pin.rb', line 85 def self.get_pins cis = [132, 133, 134, 135, 136, 137, 138, 139 ] xio = [] xio_base = get_xio_base() (0..7).each { |i| xio << (xio_base + i) } pins = {} cis.each_with_index { |gpio, index| pins["CSI#{index}".to_sym] = Pin::Pin.new(gpio) } xio.each_with_index { |gpio, index| pins["XIO#{index}".to_sym] = Pin::Pin.new(gpio) } return pins end |
.get_xio_base ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/chip-gpio/Pin.rb', line 70 def self.get_xio_base labels = Dir::glob("/sys/class/gpio/*/label") labels.each do |label| value = File.read(label).strip if value == "pcf8574a" base_path = File.dirname(label) base_path = File.join(base_path, 'base') base = File.read(base_path).strip return base.to_i end end throw "Could not find XIO base" end |