~ni/nxt-python

5447b80a648b0ef4a628880abe63ea321fe0f48c — marvin 3 months ago 6f83ad4
Avoid spinning
1 files changed, 3 insertions(+), 1 deletions(-)

M nxt/motor.py
M nxt/motor.py => nxt/motor.py +3 -1
@@ 257,14 257,16 @@ class BaseMotor:

        try:
            while not stop_turn():
                current_time = time.time()
                time.sleep(0.1)

                if current_time - last_time < sleep_time:
                    current_time = time.time()
                    continue
                else:
                    if not blocked:  # if still blocked, don't reset the counter
                        last_tacho = tacho
                        last_time = current_time
                    current_time = time.time()

                tacho = self.get_tacho()
                blocked = self._is_blocked(tacho, last_tacho, direction)