DigitalOutputDevice

DigitalOutputDevice

new DigitalOutputDevice(pin, active_highopt, initial_valueopt)

Source:
Represents a generic output device with typical on/off behaviour. This class extends OutputDevice with a blink method which toggles the device state without further interaction.
Parameters:
Name Type Attributes Description
pin int | Pin The GPIO pin (in BCM numbering) or an instance of Pin that the device is connected to.
active_high boolean <optional>
If `true` (the default), the on method will set the GPIO to HIGH. If `false`, the on method will set the GPIO to LOW (the off method always does the opposite).
initial_value boolean <optional>
If `false` (the default), the device will be off initially. If `undefined`, the device will be left in whatever state the pin is found in when configured for output (warning: this can be on). If `true`, the device will be switched on initially.
Throws:
GPIOPinMissing - When pin is undefined.

Extends

Methods

active_high(valueopt)

Source:
Inherited From:
This property can be set after construction; be warned that changing it will invert value (i.e. changing this property doesn't change the device's pin state - it just changes how that state is interpreted).
Parameters:
Name Type Attributes Description
value boolean <optional>
When ``true``, the value property is ``true`` when the device's pin is high. When ``false`` the value property is ``true`` when the device's pin is low (i.e. the value is inverted).
Source:
Make the device turn on and off repeatedly.
Parameters:
Name Type Description
on_time float Number of seconds on. Defaults to 1 second.
off_time float Number of seconds off. Defaults to 1 second.
n int Number of times to blink; ``None`` (the default) means forever.
{@callback} callback - Function to be called upon completion in the form (error, data).

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

off()

Source:
Inherited From:
Turns the device off.

on()

Source:
Inherited From:
Turns the device on.

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

toggle()

Source:
Inherited From:
Reverse the state of the device. If it's on, turn it off; if it's off, turn it on.

toString() → {string}

Source:
Inherited From:
Returns:
- Description of the device.
Type
string

value(valueopt) → {boolean|float}

Source:
Inherited From:
Parameters:
Name Type Attributes Description
value boolean | float <optional>
When supplied the device output is changed to the value.
Returns:
- When value is undefined, the function returns the current value of the device.
Type
boolean | float