Compare commits
2 commits
48fd906e49
...
a7c3d5f84d
| Author | SHA1 | Date | |
|---|---|---|---|
| a7c3d5f84d | |||
| e6daa24561 |
1 changed files with 25 additions and 17 deletions
|
|
@ -61,21 +61,28 @@ 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:
|
||||||
print(' DEADTIME -> ignore')
|
if debug:
|
||||||
return last_start
|
print(' DEADTIME -> ignore')
|
||||||
|
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:
|
||||||
print(' ACTION TIMED OUT -> stopping')
|
if debug:
|
||||||
next_action = (0,0)
|
print(' ACTION TIMED OUT -> stopping')
|
||||||
|
next_action = (0,0)
|
||||||
elif next_action is None:
|
elif next_action is None:
|
||||||
return last_start
|
return last_start
|
||||||
|
|
||||||
print('Starting action: ', next_action)
|
if debug:
|
||||||
|
print('Starting action: ', next_action)
|
||||||
|
|
||||||
if next_action[0] == 1:
|
if next_action[0] == 1:
|
||||||
MOTOR_A0.on()
|
MOTOR_A0.on()
|
||||||
|
|
@ -117,24 +124,25 @@ def mainloop(l):
|
||||||
|
|
||||||
last_pixel_update = 0
|
last_pixel_update = 0
|
||||||
|
|
||||||
for i in range(6):
|
#for i in range(6):
|
||||||
LED_NP[i] = (255,255,255, 255)
|
# LED_NP[i] = (255,255,255, 255)
|
||||||
LED_NP.write()
|
#LED_NP.write()
|
||||||
time.sleep(1)
|
#time.sleep(1)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
ctr += 1
|
ctr += 1
|
||||||
# run one iteration of control loop
|
# run one iteration of control loop
|
||||||
last_action_start = controlloop(last_action_start, next_action)
|
last_action_start = controlloop(last_action_start, next_action)
|
||||||
if time.time() > last_pixel_update + 0.5:
|
#if time.time() > last_pixel_update + 0.5:
|
||||||
#LED_NP[ctr % 6] = (ctr*3 % 255, ctr*2 % 255, (ctr+1)*3 % 255)
|
# #LED_NP[ctr % 6] = (ctr*3 % 255, ctr*2 % 255, (ctr+1)*3 % 255)
|
||||||
last_pixel_update = time.time()
|
# last_pixel_update = time.time()
|
||||||
LED_NP.write()
|
# LED_NP.write()
|
||||||
|
|
||||||
a = None
|
a = None
|
||||||
try:
|
try:
|
||||||
a = y.read(1)
|
a = y.read(1)
|
||||||
print('RCV: ', a)
|
if debug:
|
||||||
|
print('RCV: ', a)
|
||||||
y.write(a)
|
y.write(a)
|
||||||
except OSError:
|
except OSError:
|
||||||
# timeout
|
# timeout
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue