InputDevice

InputDevice

new InputDevice(pin, pullupopt)

Source:
Represents a generic GPIO input device. This class extends GPIODevice to add facilities common to GPIO input devices. The constructor adds the optional *pull_up* parameter to specify how the pin should be pulled by the internal resistors. The is_active property is adjusted accordingly so that ``true`` still means active regardless of the pullup setting.
Parameters:
Name Type Attributes Description
pin int | Pin The GPIO pin (in Broadcom numbering) that the device is connected to.
pullup boolean <optional>
If ``true``, the pin will be pulled high with an internal resistor. If ``false`` (the default), the pin will be pulled low.
Throws:
GPIODeviceError

Extends

Methods

close()

Source:
Inherited From:
Close the device and remove the pin allocation allowing it to be reused.

closed() → {boolean}

Source:
Inherited From:
Returns:
- Is ``true`` is no pin is allocated.
Type
boolean

is_active() → {boolean}

Source:
Inherited From:
Returns:
- Is true is the device value is currently set.
Type
boolean

pin() → {undefined|*|int|Pin}

Source:
Inherited From:
Returns:
- The Pin that the device is connected to. This will be ``undefined`` if the device has been closed (see the :meth:`close` method). When dealing with GPIO pins, query ``pin.number`` to discover the GPIO pin (in BCM numbering) that the device is connected to.
Type
undefined | * | int | Pin

pull_up()

Source:
If ``true``, the device uses a pull-up resistor to set the GPIO pin "high" by default.

toString() → {string}

Source:
Overrides:
Returns:
- Description of the device.
Type
string

value() → {int|Boolean}

Source:
Inherited From:
Returns:
- Current value of the pin.
Type
int | Boolean