mirror of
				https://github.com/KevinMidboe/python-gpiozero.git
				synced 2025-10-29 17:50:37 +00:00 
			
		
		
		
	Fix #76
Makes `value` an alias of `is_active` in the base `GPIODevice`, and `values` an infinite iterable of this value. Then adds `source` property to `OutputDevice` allowing simple linkage of devices via iterators.
This commit is contained in:
		| @@ -155,12 +155,25 @@ class GPIODevice(object): | ||||
|         return self._pin | ||||
|  | ||||
|     @property | ||||
|     def is_active(self): | ||||
|     def value(self): | ||||
|         """ | ||||
|         Returns `True` if the device is currently active and `False` otherwise. | ||||
|         """ | ||||
|         return self._read() | ||||
|  | ||||
|     is_active = value | ||||
|  | ||||
|     @property | ||||
|     def values(self): | ||||
|         """ | ||||
|         An infinite iterator of values read from `value`. | ||||
|         """ | ||||
|         while True: | ||||
|             try: | ||||
|                 yield self.value | ||||
|             except GPIODeviceClosed: | ||||
|                 break | ||||
|  | ||||
|     def __repr__(self): | ||||
|         try: | ||||
|             return "<gpiozero.%s object on pin=%d, is_active=%s>" % ( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user