Class: Denko::DigitalIO::Output

Inherits:
Object
  • Object
show all
Includes:
Behaviors::Callbacks, Behaviors::OutputPin, Behaviors::Threaded
Defined in:
lib/denko/digital_io/output.rb

Direct Known Subclasses

Relay, PulseIO::PWMOutput

Instance Attribute Summary

Attributes included from Behaviors::Threaded

#interrupts_enabled, #thread

Attributes included from Behaviors::Callbacks

#callback_mutex

Attributes included from Behaviors::SinglePin

#mode, #pin

Attributes included from Behaviors::Component

#board

Instance Method Summary collapse

Methods included from Behaviors::Threaded

#enable_interrupts, included, #stop, #stop_thread, #threaded, #threaded_loop

Methods included from Behaviors::Callbacks

#add_callback, #callbacks, #initialize, #remove_callback, #update

Methods included from Behaviors::State

#initialize, #state

Methods included from Behaviors::Component

#initialize, #micro_delay

Instance Method Details

#after_initialize(options = {}) ⇒ Object



9
10
11
12
# File 'lib/denko/digital_io/output.rb', line 9

def after_initialize(options={})
  super(options)
  board.digital_read(pin)
end

#digital_write(value) ⇒ Object Also known as: write



18
19
20
21
# File 'lib/denko/digital_io/output.rb', line 18

def digital_write(value)
  @board.digital_write(@pin, value)
  self.state = value
end

#highObject Also known as: on



29
30
31
# File 'lib/denko/digital_io/output.rb', line 29

def high
  digital_write(board.high)
end

#high?Boolean Also known as: on?

Returns:

  • (Boolean)


40
# File 'lib/denko/digital_io/output.rb', line 40

def high?; state == board.high end

#lowObject Also known as: off



25
26
27
# File 'lib/denko/digital_io/output.rb', line 25

def low
  digital_write(board.low)
end

#low?Boolean Also known as: off?

Returns:

  • (Boolean)


41
# File 'lib/denko/digital_io/output.rb', line 41

def low?;  state == board.low  end

#pre_callback_filter(board_state) ⇒ Object



14
15
16
# File 'lib/denko/digital_io/output.rb', line 14

def pre_callback_filter(board_state)
  board_state.to_i
end

#toggleObject



33
34
35
# File 'lib/denko/digital_io/output.rb', line 33

def toggle
  state == board.low ? high : low
end