debug print statements optional

This commit is contained in:
Tassilo Schweyer 2025-12-29 01:20:21 +01:00
parent e6daa24561
commit a7c3d5f84d

View file

@ -61,20 +61,27 @@ do_ap()
s = setup_listener() s = setup_listener()
c = [] c = []
debug = False
def controlloop(last_start, next_action): def controlloop(last_start, next_action):
now = time.ticks_us() now = time.ticks_us()
if debug:
print('CTRL: ', last_start, next_action) print('CTRL: ', last_start, next_action)
if time.ticks_diff(now, time.ticks_add(last_start, 100000)) < 0: if time.ticks_diff(now, time.ticks_add(last_start, 100000)) < 0:
if debug:
print(' DEADTIME -> ignore') print(' DEADTIME -> ignore')
return last_start return last_start
if next_action is None and time.ticks_diff(time.ticks_add(last_start, 601000), now) > 0: if next_action is None and time.ticks_diff(time.ticks_add(last_start, 601000), now) > 0:
if debug:
print(' ACTION TIMED OUT -> stopping') print(' ACTION TIMED OUT -> stopping')
next_action = (0,0) next_action = (0,0)
elif next_action is None: elif next_action is None:
return last_start return last_start
if debug:
print('Starting action: ', next_action) print('Starting action: ', next_action)
if next_action[0] == 1: if next_action[0] == 1:
@ -134,6 +141,7 @@ def mainloop(l):
a = None a = None
try: try:
a = y.read(1) a = y.read(1)
if debug:
print('RCV: ', a) print('RCV: ', a)
y.write(a) y.write(a)
except OSError: except OSError: