Module: Denko::Display::SPICommon

Includes:
PixelCommon, SPI::Peripheral
Included in:
PCD8544, SPIEPaperCommon, ST7302, ST7565
Defined in:
lib/denko/display/spi_common.rb

Constant Summary

Constants included from Behaviors::Lifecycle

Behaviors::Lifecycle::CALLBACK_METHODS

Instance Attribute Summary

Attributes included from SPI::Peripheral

#spi_bit_order, #spi_frequency, #spi_mode

Attributes included from Behaviors::State

#state

Attributes included from Behaviors::Component

#board, #params

Attributes included from Behaviors::MultiPin

#pin, #pins, #proxies

Instance Method Summary collapse

Methods included from PixelCommon

#canvas, #colors, #columns, #draw, #get_partial_buffer, #p_max, #p_min, #refresh, #rows, #x_max, #x_min, #y_max, #y_min

Methods included from SPI::Peripheral

#ensure_byte_array, #proxy_pin, #spi_listen, #spi_read, #spi_stop, #spi_transfer, #spi_write, #update

Methods included from Behaviors::Lifecycle

included

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 Method Details

#command(bytes) ⇒ Object

Commands are SPI bytes written while DC pin is low.



19
20
21
22
# File 'lib/denko/display/spi_common.rb', line 19

def command(bytes)
  dc.low
  spi_write(bytes)
end

#data(bytes) ⇒ Object

Display data are SPI SPI bytes written while DC pin is high.



25
26
27
28
# File 'lib/denko/display/spi_common.rb', line 25

def data(bytes)
  dc.high
  spi_write(bytes)
end

#initialize_pins(options = {}) ⇒ Object

SPI displays use a D/C pin to toggle whether bytes being sent are data or commands. Most also have a RESET pin which is pulsed low to initalize, then held high.



11
12
13
14
15
16
# File 'lib/denko/display/spi_common.rb', line 11

def initialize_pins(options={})
  super(options)
  proxy_pin :dc,    DigitalIO::Output
  proxy_pin :reset, DigitalIO::Output, optional: true
  reset.high if reset
end

#transfer_limitObject



30
31
32
# File 'lib/denko/display/spi_common.rb', line 30

def transfer_limit
  @transfer_limit ||= bus.board.spi_limit
end