Class: Denko::SPI::Bus
- Inherits:
-
Object
- Object
- Denko::SPI::Bus
- Extended by:
- Forwardable
- Defined in:
- lib/denko/spi/bus.rb
Instance Attribute Summary collapse
-
#pin ⇒ Object
readonly
Board expects all components to have #pin.
Attributes included from Behaviors::Callbacks
Attributes included from Behaviors::Component
Instance Method Summary collapse
-
#add_component(component) ⇒ Object
Add peripheral to self and the board.
-
#remove_component(component) ⇒ Object
Remove peripheral from self and the board.
Methods included from Behaviors::Reader
#_read, #read, #read_using, #wait_for_read
Methods included from Behaviors::Callbacks
#add_callback, #callbacks, #initialize, #pre_callback_filter, #remove_callback, #update
Methods included from Behaviors::State
Methods included from Behaviors::BusController
Methods included from Behaviors::Subcomponents
#components, #single_pin_components
Methods included from Behaviors::Component
Instance Attribute Details
#pin ⇒ Object (readonly)
Board expects all components to have #pin.
9 10 11 |
# File 'lib/denko/spi/bus.rb', line 9 def pin @pin end |
Instance Method Details
#add_component(component) ⇒ Object
Add peripheral to self and the board. It gets callbacks directly from the board.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/denko/spi/bus.rb', line 24 def add_component(component) # Treat pin 255 as the component having no select pin. Mostly for APA102. return if component.pin == 255 pins = components.map { |c| c.pin } if pins.include? component.pin raise ArgumentError, "duplicate select pin for #{component}" end components << component board.add_component(component) end |
#remove_component(component) ⇒ Object
Remove peripheral from self and the board.
38 39 40 41 |
# File 'lib/denko/spi/bus.rb', line 38 def remove_component(component) components.delete(component) board.remove_component(component) end |