From 643fb5b91ebc08e5332e0cb2a43255f76500cb55 Mon Sep 17 00:00:00 2001 From: Jej Date: Thu, 11 Jun 2020 09:13:28 +0000 Subject: [PATCH] Allow negative step count and angle for backward rotation motor.angle(-90) == motor.angle(90, -1) motor.step(-500) == motor.step(500, -1) --- Stepper.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Stepper.py b/Stepper.py index a62620c..9a1e0ea 100644 --- a/Stepper.py +++ b/Stepper.py @@ -37,6 +37,9 @@ class Stepper: def step(self, count, direction=1): """Rotate count steps. direction = -1 means backwards""" + if count<0: + direction = -1 + count = -count for x in range(count): for bit in self.mode[::direction]: self.pin1(bit[0])