Class: Denko::DigitalIO::Input
- Inherits:
-
Object
- Object
- Denko::DigitalIO::Input
- Includes:
- Behaviors::InputPin, Behaviors::Lifecycle, Behaviors::Listener, Behaviors::Poller, Behaviors::Reader
- Defined in:
- lib/denko/digital_io/input.rb
Direct Known Subclasses
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
Attributes included from Behaviors::State
Attributes included from Behaviors::Threaded
Attributes included from Behaviors::SinglePin
Attributes included from Behaviors::Component
Instance Method Summary collapse
- #_listen(divider = nil) ⇒ Object
- #_read ⇒ Object
- #high? ⇒ Boolean
- #low? ⇒ Boolean
- #on_high(&block) ⇒ Object
- #on_low(&block) ⇒ Object
- #pre_callback_filter(value) ⇒ Object
Methods included from Behaviors::Lifecycle
Methods included from Behaviors::Listener
Methods included from Behaviors::Callbacks
#add_callback, #callbacks, #remove_callback, #update
Methods included from Behaviors::State
Methods included from Behaviors::Poller
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
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 |
#_read ⇒ Object
14 15 16 |
# File 'lib/denko/digital_io/input.rb', line 14 def _read board.digital_read(pin) end |
#high? ⇒ Boolean
39 |
# File 'lib/denko/digital_io/input.rb', line 39 def high?; state == board.high end |
#low? ⇒ 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 |