Skip to content

Commit 51b04ec

Browse files
committed
fixes for review
1 parent 1f246e4 commit 51b04ec

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

adafruit_hcsr04.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,15 @@ def __init__(self, trigger_pin, echo_pin, *, timeout=0.1):
8181
"""
8282
:param trigger_pin: The pin on the microcontroller that's connected to the
8383
``Trig`` pin on the HC-SR04.
84-
:type trig_pin: str or microcontroller.Pin
84+
:type trig_pin: microcontroller.Pin
8585
:param echo_pin: The pin on the microcontroller that's connected to the
8686
``Echo`` pin on the HC-SR04.
87-
:type echo_pin: str or microcontroller.Pin
87+
:type echo_pin: microcontroller.Pin
8888
:param float timeout: Max seconds to wait for a response from the
8989
sensor before assuming it isn't going to answer. Should *not* be
9090
set to less than 0.05 seconds!
9191
"""
92-
if isinstance(trigger_pin, str):
93-
trigger_pin = getattr(board, trigger_pin)
94-
if isinstance(echo_pin, str):
95-
echo_pin = getattr(board, echo_pin)
96-
self.dist_cm = self._dist_two_wire
9792
self._timeout = timeout
98-
9993
self._trig = DigitalInOut(trigger_pin)
10094
self._trig.direction = Direction.OUTPUT
10195

@@ -139,8 +133,7 @@ def distance(self):
139133
:return: Distance in centimeters.
140134
:rtype: float
141135
"""
142-
if self._trig is not None:
143-
return self._dist_two_wire()
136+
return self._dist_two_wire() # at this time we only support 2-wire meausre
144137

145138
def _dist_two_wire(self):
146139
if _USE_PULSEIO:

0 commit comments

Comments
 (0)