Skip to content

Remove call to _update_coils in __init__ #29

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
May 31, 2019
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion adafruit_motor/stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def __init__(self, ain1, ain2, bin1, bin2, *, microsteps=16):
self._microsteps = microsteps
self._curve = [int(round(0xffff * math.sin(math.pi / (2 * microsteps) * i)))
for i in range(microsteps + 1)]
self._update_coils()

def _update_coils(self, *, microstepping=False):
duty_cycles = [0, 0, 0, 0]
Expand Down
12 changes: 6 additions & 6 deletions tests/test_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_single_coil():
motor = stepper.StepperMotor(coil[2], coil[0], coil[1], coil[3])
# Always start with a single step.
for j in range(4):
assert coil[j].duty_cycle == (0xffff if j == 0 else 0)
assert coil[j].duty_cycle == 0
for i in range(1, 7): # Test 6 steps so we wrap around
motor.onestep()
for j in range(4):
Expand All @@ -45,7 +45,7 @@ def test_double_coil():
motor = stepper.StepperMotor(coil[2], coil[0], coil[1], coil[3])
# Despite double stepping we always start with a single step.
for j in range(4):
assert coil[j].duty_cycle == (0xffff if j == 0 else 0)
assert coil[j].duty_cycle == 0
for i in range(6): # Test 6 steps so we wrap around
motor.onestep(style=stepper.DOUBLE)
for j in range(4):
Expand All @@ -57,7 +57,7 @@ def test_interleave_steps():
motor = stepper.StepperMotor(coil[2], coil[0], coil[1], coil[3])
# We always start with a single step.
for j in range(4):
assert coil[j].duty_cycle == (0xffff if j == 0 else 0)
assert coil[j].duty_cycle == 0
for i in range(15): # Test 15 half steps so we wrap around
motor.onestep(style=stepper.INTERLEAVE)
for j in range(4):
Expand All @@ -83,7 +83,7 @@ def test_microstep_steps():
motor = stepper.StepperMotor(coil[2], coil[0], coil[1], coil[3], microsteps=2)
# We always start with a single step.
for j in range(4):
assert coil[j].duty_cycle == (0xffff if j == 0 else 0)
assert coil[j].duty_cycle == 0
motor.onestep(style=stepper.MICROSTEP)
assert coil[0].duty_cycle == 0xb504
assert coil[1].duty_cycle == 0xb504
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_double_to_single():
motor = stepper.StepperMotor(coil[2], coil[0], coil[1], coil[3])
# We always start with a single step.
for j in range(4):
assert coil[j].duty_cycle == (0xffff if j == 0 else 0)
assert coil[j].duty_cycle == 0

motor.onestep(direction=stepper.BACKWARD, style=stepper.DOUBLE)
assert coil[0].duty_cycle == 0xffff
Expand Down Expand Up @@ -146,7 +146,7 @@ def test_microstep_to_single():
motor = stepper.StepperMotor(coil[2], coil[0], coil[1], coil[3])
# We always start with a single step.
for j in range(4):
assert coil[j].duty_cycle == (0xffff if j == 0 else 0)
assert coil[j].duty_cycle == 0

motor.onestep(direction=stepper.BACKWARD, style=stepper.MICROSTEP)
assert coil[0].duty_cycle == 0xfec3
Expand Down