Class: Denko::SPI::Bus

Inherits:
Object
  • Object
show all
Includes:
BusCommon
Defined in:
lib/denko/spi/bus.rb

Constant Summary

Constants included from Behaviors::Reader

Behaviors::Reader::READ_WAIT_TIME

Constants included from Behaviors::Lifecycle

Behaviors::Lifecycle::CALLBACK_METHODS

Instance Attribute Summary collapse

Attributes included from Behaviors::State

#state

Attributes included from Behaviors::Component

#board, #params

Instance Method Summary collapse

Methods included from BusCommon

#add_component, #convert_pin, #remove_component, #set_pin_mode, #stop

Methods included from Behaviors::Reader

#_read, #read, #read_busy?, #read_nb, #read_raw, #read_using, #update

Methods included from Behaviors::Callbacks

#add_callback, #callbacks, #pre_callback_filter, #remove_callback, #update

Methods included from Behaviors::State

#update_state

Methods included from Behaviors::Lifecycle

included

Methods included from Behaviors::BusController

#mutex

Methods included from Behaviors::Subcomponents

#add_component, #add_hw_i2c, #add_hw_spi, #add_single_pin, #components, #hw_i2c_comps, #hw_spi_comps, #remove_component, #remove_hw_i2c, #remove_hw_spi, #remove_single_pin, #single_pin_components

Methods included from Behaviors::Component

#initialize, #micro_delay

Instance Attribute Details

#pinObject (readonly)

Board expects all components to have #pin.



7
8
9
# File 'lib/denko/spi/bus.rb', line 7

def pin
  @pin
end

Instance Method Details

#listen(*args, **kwargs) ⇒ Object



19
20
21
22
# File 'lib/denko/spi/bus.rb', line 19

def listen(*args, **kwargs)
  args.unshift(spi_index)
  board.spi_listen(*args, **kwargs)
end

#show_ws2812(*args) ⇒ Object

This is for WS2812 strips on PiBoard.



25
26
27
# File 'lib/denko/spi/bus.rb', line 25

def show_ws2812(*args)
  board.show_ws2812(*args, spi_index: spi_index)
end

#spi_indexObject



9
10
11
# File 'lib/denko/spi/bus.rb', line 9

def spi_index
  @spi_index ||= params[:spi_index] || params[:index] || 0
end

#transfer(*args, **kwargs) ⇒ Object

Prepend spi_index to these and forward to the board.



14
15
16
17
# File 'lib/denko/spi/bus.rb', line 14

def transfer(*args, **kwargs)
  args.unshift(spi_index)
  board.spi_transfer(*args, **kwargs)
end