@@ -81,21 +81,15 @@ def __init__(self, trigger_pin, echo_pin, *, timeout=0.1):
81
81
"""
82
82
:param trigger_pin: The pin on the microcontroller that's connected to the
83
83
``Trig`` pin on the HC-SR04.
84
- :type trig_pin: str or microcontroller.Pin
84
+ :type trig_pin: microcontroller.Pin
85
85
:param echo_pin: The pin on the microcontroller that's connected to the
86
86
``Echo`` pin on the HC-SR04.
87
- :type echo_pin: str or microcontroller.Pin
87
+ :type echo_pin: microcontroller.Pin
88
88
:param float timeout: Max seconds to wait for a response from the
89
89
sensor before assuming it isn't going to answer. Should *not* be
90
90
set to less than 0.05 seconds!
91
91
"""
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
97
92
self ._timeout = timeout
98
-
99
93
self ._trig = DigitalInOut (trigger_pin )
100
94
self ._trig .direction = Direction .OUTPUT
101
95
@@ -139,8 +133,7 @@ def distance(self):
139
133
:return: Distance in centimeters.
140
134
:rtype: float
141
135
"""
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
144
137
145
138
def _dist_two_wire (self ):
146
139
if _USE_PULSEIO :
0 commit comments