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
194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/chip-gpio/Pin.rb', line 194 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| sym = "CSI#{index}".to_sym; pins[sym] = Pin::Pin.new(gpio, sym) } xio.each_with_index { |gpio, index| sym = "XIO#{index}".to_sym; pins[sym] = Pin::Pin.new(gpio, sym) } return pins end |
.get_xio_base ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/chip-gpio/Pin.rb', line 179 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 |