Class: Denko::SPI::BaseRegister

Inherits:
Object
  • Object
show all
Includes:
Behaviors::BoardProxy, Behaviors::Lifecycle, Peripheral
Defined in:
lib/denko/spi/base_register.rb

Direct Known Subclasses

InputRegister, OutputRegister

Constant Summary

Constants included from Behaviors::Lifecycle

Behaviors::Lifecycle::CALLBACK_METHODS

Instance Attribute Summary collapse

Attributes included from Peripheral

#spi_bit_order, #spi_frequency, #spi_mode

Attributes included from Behaviors::Component

#board, #params

Attributes included from Behaviors::MultiPin

#pin, #pins, #proxies

Instance Method Summary collapse

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

included

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

#update_state

Methods included from Behaviors::BusPeripheral

#atomically

Methods included from Behaviors::Component

#initialize, #micro_delay

Methods included from Behaviors::MultiPin

#convert_pins, #proxy_pin, #proxy_states, #require_pin, #require_pins

Instance Attribute Details

#bytesObject

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

Returns:

  • (Boolean)


16
17
18
# File 'lib/denko/spi/base_register.rb', line 16

def is_a_register?
  true
end

#platformObject



12
13
14
# File 'lib/denko/spi/base_register.rb', line 12

def platform
  :spi_register
end

#stateObject

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