Skip to content

Commit

Permalink
Merge pull request #830 from gpiozero/fix-817
Browse files Browse the repository at this point in the history
Ensure pin_factory is sent to both echo and trigger devices in DistanceSensor, close #817
  • Loading branch information
bennuttall committed Jan 20, 2020
2 parents 4733fd9 + 533d81b commit 23be8f7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gpiozero/input_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ class DistanceSensor(SmoothedInputDevice):
Alternatively, the 3V3 tolerant HC-SR04P sensor (which does not require a
voltage divider) will work with this class.
.. note::
Expand Down Expand Up @@ -864,7 +864,7 @@ def __init__(
self._max_distance = max_distance
self.threshold = threshold_distance / max_distance
self.speed_of_sound = 343.26 # m/s
self._trigger = GPIODevice(trigger)
self._trigger = GPIODevice(trigger, pin_factory=pin_factory)
self._echo = Event()
self._echo_rise = None
self._echo_fall = None
Expand All @@ -877,7 +877,7 @@ def __init__(
except:
self.close()
raise

if PiGPIOFactory is None or not isinstance(self.pin_factory, PiGPIOFactory):
warnings.warn(PWMSoftwareFallback(
'For more accurate readings, use the pigpio pin factory.'
Expand Down

0 comments on commit 23be8f7

Please sign in to comment.