Skip to content

Commit 4701a64

Browse files
authored
Fix logic for checking PWMOut
Thanks @jepler for catching the faulty logic!
1 parent 44bdcf4 commit 4701a64

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

adafruit_motor/stepper.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,12 @@ def __init__(
113113
# set a safe pwm freq for each output
114114
self._coil = (ain2, bin1, ain1, bin2)
115115
for i in range(4):
116-
if self._coil[i].frequency < 1500 and self._coil[i].variable_frequency:
117-
self._coil[i].frequency = 2000
118-
else:
116+
if self._coil[i].frequency < 1500 and not self._coil[i].variable_frequency:
119117
raise ValueError(
120118
"PWMOut outputs must either be set to at least "
121119
"1500 Hz or allow variable frequency."
122120
)
121+
self._coil[i].frequency = 2000
123122
if microsteps < 2:
124123
raise ValueError("Microsteps must be at least 2")
125124
if microsteps % 2 == 1:

0 commit comments

Comments
 (0)