diff --git a/shittyrobot.py b/shittyrobot.py index fbe817c..d1aff6a 100644 --- a/shittyrobot.py +++ b/shittyrobot.py @@ -62,13 +62,15 @@ s = setup_listener() c = [] def controlloop(last_start, next_action): + now = time.ticks_us() + #print('CTRL: ', last_start, next_action) - if time.ticks_us() < last_start + 100000: - #print(' DEADTIME -> ignore') + if time.ticks_diff(now, time.ticks_add(last_start, 100000)) < 0: + print(' DEADTIME -> ignore') return last_start - if next_action is None and time.ticks_us() > last_start + 600000: - #print(' ACTION TIMED OUT -> stopping') + if next_action is None and time.ticks_diff(time.ticks_add(last_start, 601000), now) > 0: + print(' ACTION TIMED OUT -> stopping') next_action = (0,0) elif next_action is None: return last_start @@ -96,7 +98,10 @@ def controlloop(last_start, next_action): MOTOR_B1.off() # we just started new action - return time.ticks_us() + if next_action != (0,0): + return time.ticks_us() + else: + return last_start def mainloop(l):