Class: GPIO::InputPin

Inherits:
Pin
  • Object
show all
Defined in:
lib/gpio/pins/input_pin.rb

Instance Attribute Summary collapse

Attributes inherited from Pin

#device, #file, #hardware_pin, #mode, #pin, #software_pin

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ InputPin

(pin, mode, device=:RaspberryPi)



4
5
6
7
# File 'lib/gpio/pins/input_pin.rb', line 4

def initialize(params) #(pin, mode, device=:RaspberryPi)
	params.merge!(:mode => :in)
	super(params)
end

Instance Attribute Details

#last_readingObject (readonly)

Returns the value of attribute last_reading.



3
4
5
# File 'lib/gpio/pins/input_pin.rb', line 3

def last_reading
  @last_reading
end

#readingObject (readonly)

Returns the value of attribute reading.



3
4
5
# File 'lib/gpio/pins/input_pin.rb', line 3

def reading
  @reading
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/gpio/pins/input_pin.rb', line 9

def changed?
	@last_reading != @reading
end

#readObject



12
13
14
15
# File 'lib/gpio/pins/input_pin.rb', line 12

def read
	@last_reading = @reading
	@reading = super
end