Class: LegoEv3::TouchSensor
- Inherits:
-
LegoSensor
- Object
- LegoSensor
- LegoEv3::TouchSensor
- Defined in:
- lib/sensors/touch.rb
Overview
More info: www.ev3dev.org/docs/drivers/lego-sensor-class/
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(connection, id, port) ⇒ TouchSensor
constructor
A new instance of TouchSensor.
- #poll ⇒ Object
- #pressed? ⇒ Boolean
Constructor Details
#initialize(connection, id, port) ⇒ TouchSensor
Returns a new instance of TouchSensor.
4 5 6 |
# File 'lib/sensors/touch.rb', line 4 def initialize(connection, id, port) super(connection, id, port, 'lego-ev3-touch') end |
Instance Method Details
#info ⇒ Object
16 17 18 19 20 21 |
# File 'lib/sensors/touch.rb', line 16 def info super.merge({ sub_type: :touch, pressed: pressed? }) end |
#poll ⇒ Object
12 13 14 |
# File 'lib/sensors/touch.rb', line 12 def poll @value = LegoEv3::Commands::LegoSensor.get_value0!(@connection, @id) end |
#pressed? ⇒ Boolean
8 9 10 |
# File 'lib/sensors/touch.rb', line 8 def pressed? @value == 1 end |