Class: Smalruby::Hardware::Sensor
- Inherits:
-
Dino::Components::Sensor
- Object
- Dino::Components::Sensor
- Smalruby::Hardware::Sensor
- Defined in:
- lib/smalruby/hardware/sensor.rb
Overview
汎用的なセンサーを表現するクラス
Constant Summary collapse
- DEFAULT_THRESHOLD =
デフォルトのセンサーの値に変化があったかどうかをチェックする閾値
32
Instance Attribute Summary collapse
-
#threshold ⇒ Object
Returns the value of attribute threshold.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(options) ⇒ Sensor
constructor
A new instance of Sensor.
- #stop ⇒ Object
Constructor Details
#initialize(options) ⇒ Sensor
Returns a new instance of Sensor.
14 15 16 |
# File 'lib/smalruby/hardware/sensor.rb', line 14 def initialize() super(board: world.board, pin: Pin.smalruby_to_dino([:pin])) end |
Instance Attribute Details
#threshold ⇒ Object
Returns the value of attribute threshold.
12 13 14 |
# File 'lib/smalruby/hardware/sensor.rb', line 12 def threshold @threshold end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
11 12 13 |
# File 'lib/smalruby/hardware/sensor.rb', line 11 def value @value end |
Instance Method Details
#stop ⇒ Object
18 19 20 |
# File 'lib/smalruby/hardware/sensor.rb', line 18 def stop @board.remove_analog_hardware(self) end |