mirror of
				https://github.com/KevinMidboe/python-gpiozero.git
				synced 2025-10-29 17:50:37 +00:00 
			
		
		
		
	Try and import the right compat...
And remove all the nonsense you re-factored into PiPin...
This commit is contained in:
		| @@ -309,23 +309,16 @@ class NativePin(LocalPiPin): | ||||
|         finally: | ||||
|             self.when_changed = f | ||||
|  | ||||
|     def _get_when_changed(self): | ||||
|         return self._when_changed | ||||
|     def _enable_event_detect(self): | ||||
|         self._change_thread = Thread(target=self._change_watch) | ||||
|         self._change_thread.daemon = True | ||||
|         self._change_event.clear() | ||||
|         self._change_thread.start() | ||||
|  | ||||
|     def _set_when_changed(self, value): | ||||
|         if self._when_changed is None and value is not None: | ||||
|             self._when_changed = value | ||||
|             self._change_thread = Thread(target=self._change_watch) | ||||
|             self._change_thread.daemon = True | ||||
|             self._change_event.clear() | ||||
|             self._change_thread.start() | ||||
|         elif self._when_changed is not None and value is None: | ||||
|             self._change_event.set() | ||||
|             self._change_thread.join() | ||||
|             self._change_thread = None | ||||
|             self._when_changed = None | ||||
|         else: | ||||
|             self._when_changed = value | ||||
|     def _disable_event_detect(self): | ||||
|         self._change_event.set() | ||||
|         self._change_thread.join() | ||||
|         self._change_thread = None | ||||
|  | ||||
|     def _change_watch(self): | ||||
|         offset = self._edge_offset | ||||
| @@ -334,5 +327,5 @@ class NativePin(LocalPiPin): | ||||
|         while not self._change_event.wait(0.001): | ||||
|             if self.factory.mem[offset] & mask: | ||||
|                 self.factory.mem[offset] = mask | ||||
|                 self._when_changed() | ||||
|                 self._call_when_changed() | ||||
|  | ||||
|   | ||||
| @@ -12,7 +12,7 @@ from weakref import ref, proxy | ||||
| try: | ||||
|     from weakref import WeakMethod | ||||
| except ImportError: | ||||
|     from .compat import WeakMethod | ||||
|     from ..compat import WeakMethod | ||||
| import warnings | ||||
|  | ||||
| try: | ||||
|   | ||||
| @@ -8,11 +8,6 @@ str = type('') | ||||
|  | ||||
| import os | ||||
| from weakref import proxy | ||||
| from threading import RLock | ||||
| try: | ||||
|     from weakref import WeakMethod | ||||
| except ImportError: | ||||
|     from .compat import WeakMethod | ||||
|  | ||||
| import pigpio | ||||
|  | ||||
| @@ -170,8 +165,6 @@ class PiGPIOPin(PiPin): | ||||
|         self._pull = 'up' if factory.pi_info.pulled_up(self.address[-1]) else 'floating' | ||||
|         self._pwm = False | ||||
|         self._bounce = None | ||||
|         self._when_changed_lock = RLock() | ||||
|         self._when_changed = None | ||||
|         self._callback = None | ||||
|         self._edges = pigpio.EITHER_EDGE | ||||
|         try: | ||||
|   | ||||
| @@ -7,13 +7,6 @@ from __future__ import ( | ||||
| str = type('') | ||||
|  | ||||
| import warnings | ||||
| from types import MethodType | ||||
| from threading import RLock | ||||
| from weakref import ref | ||||
| try: | ||||
|     from weakref import WeakMethod | ||||
| except ImportError: | ||||
|     from .compat import WeakMethod | ||||
|  | ||||
| from RPi import GPIO | ||||
|  | ||||
| @@ -97,8 +90,6 @@ class RPiGPIOPin(LocalPiPin): | ||||
|         self._frequency = None | ||||
|         self._duty_cycle = None | ||||
|         self._bounce = -666 | ||||
|         self._when_changed_lock = RLock() | ||||
|         self._when_changed = None | ||||
|         self._edges = GPIO.BOTH | ||||
|         GPIO.setup(self.number, GPIO.IN, self.GPIO_PULL_UPS[self._pull]) | ||||
|  | ||||
|   | ||||
| @@ -8,11 +8,6 @@ str = type('') | ||||
|  | ||||
|  | ||||
| import warnings | ||||
| from threading import RLock | ||||
| try: | ||||
|     from weakref import WeakMethod | ||||
| except ImportError: | ||||
|     from .compat import WeakMethod | ||||
|  | ||||
| import RPIO | ||||
| import RPIO.PWM | ||||
| @@ -89,8 +84,6 @@ class RPIOPin(LocalPiPin): | ||||
|         self._pwm = False | ||||
|         self._duty_cycle = None | ||||
|         self._bounce = None | ||||
|         self._when_changed_lock = RLock() | ||||
|         self._when_changed = None | ||||
|         self._edges = 'both' | ||||
|         try: | ||||
|             RPIO.setup(self.number, RPIO.IN, self.GPIO_PULL_UPS[self._pull]) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user