Skip to content

Commit 54766df

Browse files
authored
Merge pull request #32 from ScottDWebster/master
Make microseconds_to_angle() consistent with simpleio.Servo()
2 parents 31c948a + 6a3393e commit 54766df

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

simpleio.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ class Servo:
178178
Easy control for hobby (3-wire) servos
179179
180180
:param ~microcontroller.Pin pin: PWM pin where the servo is located.
181-
:param int min_pulse: Pulse width (microseconds) corresponding to 0 degrees.
182-
:param int max_pulse: Pulse width (microseconds) corresponding to 180 degrees.
181+
:param int min_pulse: Pulse width (milliseconds) corresponding to 0 degrees.
182+
:param int max_pulse: Pulse width (milliseconds) corresponding to 180 degrees.
183183
184184
Example for Metro M0 Express:
185185
@@ -220,7 +220,7 @@ def angle(self, degrees):
220220

221221
def microseconds_to_angle(self, us): #pylint: disable-msg=no-self-use, invalid-name
222222
"""Converts microseconds to a degree value"""
223-
return map_range(us, 500, 2500, 0, 180)
223+
return map_range(us, self.min_pulse * 1000, self.max_pulse * 1000, 0, 180)
224224

225225
def deinit(self):
226226
"""Detaches servo object from pin, frees pin"""

0 commit comments

Comments
 (0)