Skip to content

Commit 3436e30

Browse files
passed black
1 parent e4fb842 commit 3436e30

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

adafruit_motor/motor.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
FAST_DECAY = const(0) # Recirculation current fast decay mode (coasting)
2929
SLOW_DECAY = const(1) # Recirculation current slow decay mode (braking)
3030

31+
3132
class DCMotor:
3233
"""DC motor driver. ``positive_pwm`` and ``negative_pwm`` can be swapped if the motor runs in
3334
the opposite direction from what was expected for "forwards".
@@ -75,11 +76,11 @@ def throttle(self, value):
7576
duty_cycle = int(0xFFFF * abs(value))
7677
if self._decay_mode == SLOW_DECAY: # Slow Decay (Braking) Mode
7778
if value < 0:
78-
self._positive.duty_cycle = 0xffff - duty_cycle
79-
self._negative.duty_cycle = 0xffff
79+
self._positive.duty_cycle = 0xFFFF - duty_cycle
80+
self._negative.duty_cycle = 0xFFFF
8081
else:
81-
self._positive.duty_cycle = 0xffff
82-
self._negative.duty_cycle = 0xffff - duty_cycle
82+
self._positive.duty_cycle = 0xFFFF
83+
self._negative.duty_cycle = 0xFFFF - duty_cycle
8384
else: # Default Fast Decay (Coasting) Mode
8485
if value < 0:
8586
self._positive.duty_cycle = 0
@@ -100,7 +101,9 @@ def decay_mode(self, mode=FAST_DECAY):
100101
if mode in (FAST_DECAY, SLOW_DECAY):
101102
self._decay_mode = mode
102103
else:
103-
raise ValueError("Decay mode value must be either motor.FAST_DECAY or motor.SLOW_DECAY")
104+
raise ValueError(
105+
"Decay mode value must be either motor.FAST_DECAY or motor.SLOW_DECAY"
106+
)
104107

105108
def __enter__(self):
106109
return self

0 commit comments

Comments
 (0)