Class: Denko::DigitalIO::Input

Inherits:
Object
  • Object
show all
Includes:
Behaviors::InputPin, Behaviors::Lifecycle, Behaviors::Listener, Behaviors::Poller, Behaviors::Reader
Defined in:
lib/denko/digital_io/input.rb

Direct Known Subclasses

Button, Sensor::GenericPIR

Constant Summary

Constants included from Behaviors::Lifecycle

Behaviors::Lifecycle::CALLBACK_METHODS

Constants included from Behaviors::Reader

Behaviors::Reader::READ_WAIT_TIME

Constants included from Behaviors::InputPin

Behaviors::InputPin::INPUT_MODES

Instance Attribute Summary

Attributes included from Behaviors::Listener

#divider

Attributes included from Behaviors::State

#state

Attributes included from Behaviors::Threaded

#interrupts_enabled, #thread

Attributes included from Behaviors::SinglePin

#mode, #pin

Attributes included from Behaviors::Component

#board, #params

Instance Method Summary collapse

Methods included from Behaviors::Lifecycle

included

Methods included from Behaviors::Listener

#listen, #stop

Methods included from Behaviors::Callbacks

#add_callback, #callbacks, #remove_callback, #update

Methods included from Behaviors::State

#update_state

Methods included from Behaviors::Poller

#poll, #poll_using, #stop

Methods included from Behaviors::Threaded

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

Methods included from Behaviors::Reader

#read, #read_busy?, #read_nb, #read_raw, #read_using, #update

Methods included from Behaviors::InputPin

#_stop_listener, #debounce_time=

Methods included from Behaviors::SinglePin

#convert_pins, #initialize_pins

Methods included from Behaviors::Component

#initialize, #micro_delay

Instance Method Details

#_listen(divider = nil) ⇒ Object



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

def _listen(divider=nil)
  @divider = divider || @divider
  board.digital_listen(pin, @divider)
end

#_readObject



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

def _read
  board.digital_read(pin)
end

#high?Boolean

Returns:

  • (Boolean)


39
# File 'lib/denko/digital_io/input.rb', line 39

def high?; state == board.high end

#low?Boolean

Returns:

  • (Boolean)


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

def low?;  state == board.low  end

#on_high(&block) ⇒ Object



23
24
25
26
27
# File 'lib/denko/digital_io/input.rb', line 23

def on_high(&block)
  add_callback(:high) do |data|
    block.call(data) if data.to_i == board.high
  end
end

#on_low(&block) ⇒ Object



29
30
31
32
33
# File 'lib/denko/digital_io/input.rb', line 29

def on_low(&block)
  add_callback(:low) do |data|
    block.call(data) if data.to_i == board.low
  end
end

#pre_callback_filter(value) ⇒ Object



35
36
37
# File 'lib/denko/digital_io/input.rb', line 35

def pre_callback_filter(value)
  value.to_i
end