Skip to content

Support Different Microsteps Intervals #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions adafruit_motorkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MotorKit:
"""Class representing an Adafruit DC & Stepper Motor FeatherWing, Shield or Pi Hat kit.

Automatically uses the I2C bus on a Feather, Metro or Raspberry Pi."""
def __init__(self, address=0x60, i2c=None):
def __init__(self, address=0x60, i2c=None, steppers_microsteps=16):
self._motor1 = None
self._motor2 = None
self._motor3 = None
Expand All @@ -74,6 +74,7 @@ def __init__(self, address=0x60, i2c=None):
i2c = board.I2C()
self._pca = PCA9685(i2c, address=address)
self._pca.frequency = 1600
self._steppers_microsteps = steppers_microsteps

# We can save memory usage (~300 bytes) by deduplicating the construction of the objects for
# each motor. This saves both code size and the number of raw strings (the error message)
Expand Down Expand Up @@ -227,7 +228,8 @@ def stepper1(self):
self._pca.channels[8].duty_cycle = 0xffff
self._pca.channels[13].duty_cycle = 0xffff
self._stepper1 = stepper.StepperMotor(self._pca.channels[10], self._pca.channels[9],
self._pca.channels[11], self._pca.channels[12])
self._pca.channels[11], self._pca.channels[12],
microsteps=self._steppers_microsteps)
return self._stepper1

@property
Expand Down Expand Up @@ -261,5 +263,6 @@ def stepper2(self):
self._pca.channels[7].duty_cycle = 0xffff
self._pca.channels[2].duty_cycle = 0xffff
self._stepper2 = stepper.StepperMotor(self._pca.channels[4], self._pca.channels[3],
self._pca.channels[5], self._pca.channels[6])
self._pca.channels[5], self._pca.channels[6],
microsteps=self._steppers_microsteps)
return self._stepper2