mirror of
				https://github.com/KevinMidboe/python-gpiozero.git
				synced 2025-10-29 17:50:37 +00:00 
			
		
		
		
	| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user