Skip to content

Commit d814f57

Browse files
committed
Make microseconds_to_angle() consistent with simpleio.Servo()
- simpleio.Servo() allows for the fine tuning of pulse length via min_pulse and max_pulse but microseconds_to_angle() formerly ignored those values and used hard coded ones. - That would lead to an inaccurate conversion if fine tuning had been used. - This patch makes use of self.min_pulse and self.max_pulse in order to make correct use of any fine tuning specified during object instantiation.
1 parent 31c948a commit d814f57

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

simpleio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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)