class Pigpio
This class has some constances for pigpio library.
Constants
- VERSION
Attributes
pi[R]
Public Class Methods
new(addr=nil,port=nil,&blk)
click to toggle source
# File lib/pigpio.rb, line 19 def initialize(addr=nil,port=nil,&blk) @pi=IF.pigpio_start(addr,port) if blk && connect blk.call(self) IF.pigpio_stop(@pi) end end
Public Instance Methods
bank(num)
click to toggle source
# File lib/pigpio.rb, line 43 def bank(num) Bank.new(@pi,num) end
connect()
click to toggle source
# File lib/pigpio.rb, line 26 def connect @pi>=0 end
current_tick()
click to toggle source
# File lib/pigpio.rb, line 33 def current_tick IF.get_current_tick(@pi) end
gpio(gpio)
click to toggle source
# File lib/pigpio.rb, line 46 def gpio(gpio) (gpio<32 ? UserGPIO : GPIO).new(@pi,gpio) end
hardware_revision()
click to toggle source
# File lib/pigpio.rb, line 36 def hardware_revision IF.get_hardware_revision(@pi) end
i2c(i2c_bus,i2c_addr)
click to toggle source
# File lib/pigpio.rb, line 61 def i2c(i2c_bus,i2c_addr) I2C.new(@pi,i2c_bus,i2c_addr) end
pigpio_version()
click to toggle source
# File lib/pigpio.rb, line 39 def pigpio_version IF.get_pigpio_version(@pi) end
serial(rx,tx=nil,baud=9600,data_bits=8,stop_bits=1,parity_type=:none)
click to toggle source
# File lib/pigpio.rb, line 52 def serial(rx,tx=nil,baud=9600,data_bits=8,stop_bits=1,parity_type=:none) return BitBangSerialRx.new(rx,baud,data_bits) if tx==nil return BitBangSerialTx.new(tx,baud,data_bits,stop_bits) if rx==nil return BitBangSerial.new(rx,tx,baud,data_bits,stop_bits) end
spi(spi_channel=0,enable_cex=1,baud=500000, bits_per_word: 8,first_MISO: false,first_MOSI: false,idol_bytes: 0,is_3wire: false,active_low_cex: 0,spi_mode: 0)
click to toggle source
# File lib/pigpio.rb, line 57 def spi(spi_channel=0,enable_cex=1,baud=500000, bits_per_word: 8,first_MISO: false,first_MOSI: false,idol_bytes: 0,is_3wire: false,active_low_cex: 0,spi_mode: 0) SPI.new(@pi,spi_channel,enable_cex,baud,bits_per_word: bits_per_word,first_MISO:first_MISO,first_MOSI:first_MOSI,idol_bytes:idol_bytes,is_3wire:is_3wire,active_low_cex:active_low_cex,spi_mode:spi_mode) end
stop()
click to toggle source
# File lib/pigpio.rb, line 29 def stop IF.pigpio_stop(@pi) @pi=-1 end
wave()
click to toggle source
# File lib/pigpio.rb, line 49 def wave() Wave.new(@pi) end