output state not changing
Tumbler
Posts: 323
Hello,
I'm having troubles with my code:
When i press buttons 1 to 11, an output will be toggled: ok
When i press the 0 button an half a second, i see the message 'All Off' in the terminal. so the second cog is running, however, the ouputs are not changing.
What i'm doing wrong here?
I'm having troubles with my code:
PUB Main | i 'start cogs cognew(BtnAllOff, @stack[0]) dira[0..15] := %0000_0000_0000_0000 ' P0 -P15 → input (this command is redundant) dira[16..27]:= %1111_1111_1111 ' P16-P27 → output Pause(100) vid.Start(115_200) 'start debug screen 'set first relais on set(16) pause (100) repeat 'check buttons 1..11 repeat i from 1 to 11 if button.ChkBtnPulse(i, 0, 60) toggle(16+i) PUB BtnAllOff | time repeat time := button.ChkBtnHoldTime(0, 0, 60, 500) if time if time==500 AllOff PUB Set(output) outa[output]:=1 vid.str(string("Set Output ")) vid.dec(output) vid.str(string(" ",cr)) PUB Reset(output) outa[output]:=0 vid.str(string("Reset Output ")) vid.dec(output) vid.str(string(" ",cr)) PUB AllOn 'set = ~~ 'reset= ~ outa[16..27]~~ vid.str(string("All On",cr)) PUB AllOff outa[16..27]~ vid.str(string("All Off",cr)) PUB Toggle(output) vid.str(string("Toggle output ")) vid.dec(output) vid.str(string(" ",cr)) !outa[output] PUB pause(ms) | t t := cnt repeat ms waitcnt(t += MS_001)
When i press buttons 1 to 11, an output will be toggled: ok
When i press the 0 button an half a second, i see the message 'All Off' in the terminal. so the second cog is running, however, the ouputs are not changing.
What i'm doing wrong here?
Comments
-Phil
If one cog sets a pin as high another cog can't change to low.
Edit: Phil bet me to it (again).
Solved with some global vars