Class: Denko::SPI::BaseRegister
- Inherits:
-
Object
- Object
- Denko::SPI::BaseRegister
- Includes:
- Behaviors::BoardProxy, Behaviors::Lifecycle, Peripheral
- Defined in:
- lib/denko/spi/base_register.rb
Direct Known Subclasses
Constant Summary
Constants included from Behaviors::Lifecycle
Behaviors::Lifecycle::CALLBACK_METHODS
Instance Attribute Summary collapse
-
#bytes ⇒ Object
Default registers to 1 byte, or 8 pins when used as Board Proxy.
Attributes included from Peripheral
#spi_bit_order, #spi_frequency, #spi_mode
Attributes included from Behaviors::Component
Attributes included from Behaviors::MultiPin
Instance Method Summary collapse
- #is_a_register? ⇒ Boolean
- #platform ⇒ Object
-
#state ⇒ Object
When used as BoardProxy, store the state of each register pin as a 0 or 1 in an array that is (@bytes * 8) long.
Methods included from Behaviors::BoardProxy
#analog_read_high, #analog_write_high, #convert_pin, #high, #low, #set_pin_mode, #start_read
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::Lifecycle
Methods included from Peripheral
#ensure_byte_array, #initialize_pins, #proxy_pin, #spi_listen, #spi_read, #spi_stop, #spi_transfer, #spi_write, #update
Methods included from Behaviors::Callbacks
#add_callback, #callbacks, #pre_callback_filter, #remove_callback, #update
Methods included from Behaviors::State
Methods included from Behaviors::BusPeripheral
Methods included from Behaviors::Component
Methods included from Behaviors::MultiPin
#convert_pins, #proxy_pin, #proxy_states, #require_pin, #require_pins
Instance Attribute Details
#bytes ⇒ Object
Default registers to 1 byte, or 8 pins when used as Board Proxy. Can be ignored if reading / writing the register directly.
22 23 24 |
# File 'lib/denko/spi/base_register.rb', line 22 def bytes @bytes = params[:bytes] || 1 end |
Instance Method Details
#is_a_register? ⇒ Boolean
16 17 18 |
# File 'lib/denko/spi/base_register.rb', line 16 def is_a_register? true end |
#platform ⇒ Object
12 13 14 |
# File 'lib/denko/spi/base_register.rb', line 12 def platform :spi_register end |
#state ⇒ Object
When used as BoardProxy, store the state of each register pin as a 0 or 1 in an array that is (@bytes * 8) long.
36 37 38 |
# File 'lib/denko/spi/base_register.rb', line 36 def state @state ||= Array.new(bytes*8) { 0 } end |