sparkfun / PiServoHat_Py

Python package for the Pi Sevo Hat
MIT License
3 stars 2 forks source link

Added ability to change min and max pulse time widths #8

Closed zeetwii closed 4 months ago

zeetwii commented 1 year ago

In the original code, the min and max pulse widths for a servo movement were hard coded to 1ms and 2ms respectively.

I changed the code to make these two fields variables that the user can set to whatever value they wanted and added getter and setter methods so that they can be updated on the fly. The default value is still a 1 ms minimum pulse time and a 2 ms max pulse time, so nothing changes for a user who doesn't want to use these commands.

I made these changes after noticing that many of the servos on Amazon have a control range of 0.5 ms to 2.5 ms, which meant when I used this board with those servos I would only get half the movement range I was expecting. Once I made this change, I was able to get my expected movement range from all of my servos.

sfe-SparkFro commented 4 months ago

Thanks for your contribution! This helps address an issue brought up in #10 and looks fine to me, I just changed things to all be snake case to match the rest of the file, and made get_pulse_time() return a tuple instead of a string to make it so a string doesn't have to be parsed just to get those 2 numbers.