Test
pub config(pin1, mode1, state1) 'pin, 0-single 1-dual, 0-manual 1-auto refresh, returns ID of refresh cog
if (not state) and state1 'clears cog influence when transitioning from manual state to auto state
dira[pin1]~
outa[pin1]~
pin := pin1 'set internal
mode := mode1 'configuration
state := state1 'variables
if not state 'get cog ready to pulse and kill any auto cog
stop
dira[pin]~~
outa[pin]~
if state 'setup and launch refresh cog in auto mode
if not motor1 'set motor1 pulsewidth if not set
set_motor1(1500)
if not motor2 'set motor2 pulsewidth if not set
set_motor2(1500)
if not cog 'launch refresh cog if not already running
cog := cognew(refresh_cog, @hb_stack) + 1
return cog - 1 'returns cog running refresh code, returns -1 if no refresh cog running
End of test

Comments
whole program? Thanks.