Class: Artoo::Drivers::Button
- Inherits:
-
Driver
- Object
- Driver
- Artoo::Drivers::Button
- Defined in:
- lib/artoo/drivers/button.rb
Overview
Button driver behaviors
Constant Summary collapse
- COMMANDS =
[:is_pressed?].freeze
- DOWN =
1
- UP =
0
Instance Method Summary collapse
-
#is_pressed? ⇒ Boolean
True if pressed.
- #start_driver ⇒ Object
Instance Method Details
#is_pressed? ⇒ Boolean
Returns True if pressed.
13 14 15 |
# File 'lib/artoo/drivers/button.rb', line 13 def is_pressed? (@pressed_val == 1) ? true : false end |
#start_driver ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/artoo/drivers/button.rb', line 17 def start_driver @pressed_val = 0 every(interval) do new_value = connection.digital_read(pin) update(new_value) if !new_value.nil? && new_value != is_pressed? end super end |