diff --git a/gpiozero/devices.py b/gpiozero/devices.py index 88f9fe5..592ecc3 100644 --- a/gpiozero/devices.py +++ b/gpiozero/devices.py @@ -31,6 +31,10 @@ class GPIODevice(object): def is_active(self): return self._read() + def __repr__(self): + return "" % ( + self.__class__.__name__, self.pin, self.is_active) + _GPIO_THREADS = set() diff --git a/gpiozero/input_devices.py b/gpiozero/input_devices.py index bef371d..5fc18a3 100644 --- a/gpiozero/input_devices.py +++ b/gpiozero/input_devices.py @@ -36,6 +36,10 @@ class InputDevice(GPIODevice): def pull_up(self): return self._pull_up + def __repr__(self): + return "" % ( + self.__class__.__name__, self.pin, self.pull_up, self.is_active) + class WaitableInputDevice(InputDevice): def __init__(self, pin=None, pull_up=False): @@ -143,6 +147,13 @@ class SmoothedInputDevice(WaitableInputDevice): self._queue = GPIOQueue(self, queue_len, sample_wait, partial) self.threshold = float(threshold) + def __repr__(self): + if self.partial or self._queue.full.wait(0): + return super(SmoothedInputDevice, self).__repr__() + else: + return "" % ( + self.__class__.__name__, self.pin, self.pull_up) + @property def queue_len(self): return self._queue.queue.maxlen