Class: Smalruby::Hardware::Sensor

Inherits:
Dino::Components::Sensor
  • Object
show all
Defined in:
lib/smalruby/hardware/sensor.rb

Overview

汎用的なセンサーを表現するクラス

Constant Summary collapse

DEFAULT_THRESHOLD =

デフォルトのセンサーの値に変化があったかどうかをチェックする閾値

32

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Sensor

Returns a new instance of Sensor.



14
15
16
# File 'lib/smalruby/hardware/sensor.rb', line 14

def initialize(options)
  super(board: world.board, pin: Pin.smalruby_to_dino(options[:pin]))
end

Instance Attribute Details

#thresholdObject

Returns the value of attribute threshold.



12
13
14
# File 'lib/smalruby/hardware/sensor.rb', line 12

def threshold
  @threshold
end

#valueObject (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

#stopObject



18
19
20
# File 'lib/smalruby/hardware/sensor.rb', line 18

def stop
  @board.remove_analog_hardware(self)
end