From 23fabb68ce424c32903ccfa27e0482848301c800 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 26 Jul 2016 22:45:38 +0200 Subject: [PATCH 1/2] Use PIGPIO_ADDR and PIGPIO_PORT environment variable if they exist to configure PiGPIO, otherwise it use the default value 'localhost' and 8888. This is the same behaviour as the pigpio library for initialisation. --- gpiozero/pins/pigpiod.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gpiozero/pins/pigpiod.py b/gpiozero/pins/pigpiod.py index a14ef9e..463e049 100644 --- a/gpiozero/pins/pigpiod.py +++ b/gpiozero/pins/pigpiod.py @@ -8,6 +8,7 @@ str = type('') import warnings import pigpio +import os from . import Pin from .data import pi_info @@ -98,7 +99,7 @@ class PiGPIOPin(Pin): GPIO_PULL_UP_NAMES = {v: k for (k, v) in GPIO_PULL_UPS.items()} GPIO_EDGES_NAMES = {v: k for (k, v) in GPIO_EDGES.items()} - def __new__(cls, number, host='localhost', port=8888): + def __new__(cls, number, host=os.getenv("PIGPIO_ADDR", 'localhost'), port=os.getenv("PIGPIO_PORT", 8888)): try: return cls._PINS[(host, port, number)] except KeyError: From 76ab6badd26946658aa0d160b440fcf36e796b5b Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 27 Jul 2016 00:17:20 +0200 Subject: [PATCH 2/2] Applying suggestion by lurch in https://github.com/RPi-Distro/python-gpiozero/pull/395 comment. --- gpiozero/pins/pigpiod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpiozero/pins/pigpiod.py b/gpiozero/pins/pigpiod.py index 463e049..bbb63f9 100644 --- a/gpiozero/pins/pigpiod.py +++ b/gpiozero/pins/pigpiod.py @@ -99,7 +99,7 @@ class PiGPIOPin(Pin): GPIO_PULL_UP_NAMES = {v: k for (k, v) in GPIO_PULL_UPS.items()} GPIO_EDGES_NAMES = {v: k for (k, v) in GPIO_EDGES.items()} - def __new__(cls, number, host=os.getenv("PIGPIO_ADDR", 'localhost'), port=os.getenv("PIGPIO_PORT", 8888)): + def __new__(cls, number, host=os.getenv('PIGPIO_ADDR', 'localhost'), port=int(os.getenv('PIGPIO_PORT', 8888))): try: return cls._PINS[(host, port, number)] except KeyError: