diff --git a/src/GPIO.php b/src/GPIO.php index 4689827..30dd792 100644 --- a/src/GPIO.php +++ b/src/GPIO.php @@ -66,11 +66,12 @@ public function __construct(AdapterInterface $adapter = null) * * @param int $pin The GPIO pin number * @param string $type The pin type (input or output) - Use GPIO::IN and GPIO::OUT + * @param bool $invert Invert the logic so that high->low and low->high * @return Pin */ - public function pin(int $pin, string $type): Pin + public function pin(int $pin, string $type, bool $invert = false): Pin { - return new Pin($pin, $type, $this->ioAdapter); + return new Pin($pin, $type, $this->ioAdapter, $invert); } /** diff --git a/src/Pin.php b/src/Pin.php index 495d628..64a0356 100644 --- a/src/Pin.php +++ b/src/Pin.php @@ -44,12 +44,13 @@ class Pin * @param int $pin The BCM pin number * @param string $type The pin type (Input or Output) * @param AdapterInterface $adapter The GPIO adapter interface + * @param bool $invert Invert the logic so that high->low and low->high */ - public function __construct(int $pin, string $type, AdapterInterface $adapter) + public function __construct(int $pin, string $type, AdapterInterface $adapter, bool $invert = false) { $this->adapter = $adapter; - $this->adapter->setDirection($pin, $type); + $this->adapter->setDirection($pin, $type, $invert); $this->validatePin($pin); $this->pin = $pin;