Class: Denko::UART::BitBang

Inherits:
Object
  • Object
show all
Includes:
Behaviors::Callbacks, Behaviors::Lifecycle, Behaviors::MultiPin, Common
Defined in:
lib/denko/uart/bit_bang.rb

Constant Summary

Constants included from Behaviors::Lifecycle

Behaviors::Lifecycle::CALLBACK_METHODS

Instance Attribute Summary collapse

Attributes included from Behaviors::State

#state

Attributes included from Behaviors::MultiPin

#pin, #pins, #proxies

Attributes included from Behaviors::Component

#board, #params

Instance Method Summary collapse

Methods included from Common

#flush, #gets, #initialize_buffer

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::MultiPin

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

Methods included from Behaviors::Component

#initialize, #micro_delay

Instance Attribute Details

#baudObject (readonly)

Returns the value of attribute baud.



15
16
17
# File 'lib/denko/uart/bit_bang.rb', line 15

def baud
  @baud
end

Instance Method Details

#hook_rx_callbackObject



41
42
43
# File 'lib/denko/uart/bit_bang.rb', line 41

def hook_rx_callback
  rx.add_callback { |data| self.update(data) }
end

#initialize_pins(options = {}) ⇒ Object



17
18
19
20
# File 'lib/denko/uart/bit_bang.rb', line 17

def initialize_pins(options={})
  require_pin(:tx)
  proxy_pin(:rx, UARTRxPin)
end

#start(baud) ⇒ Object



28
29
30
31
# File 'lib/denko/uart/bit_bang.rb', line 28

def start(baud)
  @baud = baud
  board.uart_bb_start(pins[:tx], pins[:rx], @baud)
end

#stopObject



33
34
35
# File 'lib/denko/uart/bit_bang.rb', line 33

def stop()
  board.uart_bb_stop
end

#write(data) ⇒ Object



37
38
39
# File 'lib/denko/uart/bit_bang.rb', line 37

def write(data)
  board.uart_bb_write(data)
end