diff --git a/gpiozero/input_devices.py b/gpiozero/input_devices.py index be2afd1..2d7f27a 100644 --- a/gpiozero/input_devices.py +++ b/gpiozero/input_devices.py @@ -13,13 +13,17 @@ class InputDevice(object): if pin is None: raise InputDeviceError('No GPIO pin number given') - self.pin = pin + self._pin = pin self._pull = GPIO.PUD_UP self._edge = GPIO.FALLING self._active_state = 0 self._inactive_state = 1 GPIO.setup(pin, GPIO.IN, self._pull) + @property + def pin(self): + return self._pin + @property def is_active(self): return GPIO.input(self.pin) == self._active_state @@ -77,9 +81,13 @@ class LightSensor(object): if pin is None: raise InputDeviceError('No GPIO pin number given') - self.pin = pin + self._pin = pin self.darkness_level = darkness_level + @property + def pin(self): + return self._pin + @property def value(self): return self._get_average_light_level(5)