Skip to content

Commit 36ac241

Browse files
authored
Merge pull request #29 from MrYsLab/master
Remove call to _update_coils in __init__
2 parents 93a9163 + 04cfe38 commit 36ac241

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

adafruit_motor/stepper.py

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def __init__(self, ain1, ain2, bin1, bin2, *, microsteps=16):
8686
self._microsteps = microsteps
8787
self._curve = [int(round(0xffff * math.sin(math.pi / (2 * microsteps) * i)))
8888
for i in range(microsteps + 1)]
89-
self._update_coils()
9089

9190
def _update_coils(self, *, microstepping=False):
9291
duty_cycles = [0, 0, 0, 0]

tests/test_stepper.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_single_coil():
3333
motor = stepper.StepperMotor(coil[2], coil[0], coil[1], coil[3])
3434
# Always start with a single step.
3535
for j in range(4):
36-
assert coil[j].duty_cycle == (0xffff if j == 0 else 0)
36+
assert coil[j].duty_cycle == 0
3737
for i in range(1, 7): # Test 6 steps so we wrap around
3838
motor.onestep()
3939
for j in range(4):
@@ -45,7 +45,7 @@ def test_double_coil():
4545
motor = stepper.StepperMotor(coil[2], coil[0], coil[1], coil[3])
4646
# Despite double stepping we always start with a single step.
4747
for j in range(4):
48-
assert coil[j].duty_cycle == (0xffff if j == 0 else 0)
48+
assert coil[j].duty_cycle == 0
4949
for i in range(6): # Test 6 steps so we wrap around
5050
motor.onestep(style=stepper.DOUBLE)
5151
for j in range(4):
@@ -57,7 +57,7 @@ def test_interleave_steps():
5757
motor = stepper.StepperMotor(coil[2], coil[0], coil[1], coil[3])
5858
# We always start with a single step.
5959
for j in range(4):
60-
assert coil[j].duty_cycle == (0xffff if j == 0 else 0)
60+
assert coil[j].duty_cycle == 0
6161
for i in range(15): # Test 15 half steps so we wrap around
6262
motor.onestep(style=stepper.INTERLEAVE)
6363
for j in range(4):
@@ -83,7 +83,7 @@ def test_microstep_steps():
8383
motor = stepper.StepperMotor(coil[2], coil[0], coil[1], coil[3], microsteps=2)
8484
# We always start with a single step.
8585
for j in range(4):
86-
assert coil[j].duty_cycle == (0xffff if j == 0 else 0)
86+
assert coil[j].duty_cycle == 0
8787
motor.onestep(style=stepper.MICROSTEP)
8888
assert coil[0].duty_cycle == 0xb504
8989
assert coil[1].duty_cycle == 0xb504
@@ -114,7 +114,7 @@ def test_double_to_single():
114114
motor = stepper.StepperMotor(coil[2], coil[0], coil[1], coil[3])
115115
# We always start with a single step.
116116
for j in range(4):
117-
assert coil[j].duty_cycle == (0xffff if j == 0 else 0)
117+
assert coil[j].duty_cycle == 0
118118

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

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

0 commit comments

Comments
 (0)