|
OK, here's some basic code for doing this with p1_sw_trig.
In itit section:
p1_sw_trig_old var bit
p1_sw_trig_old=0
p1_sw_trig_toggleVal var bit
p1_sw_trig_toggleVal=0
Sometime after serin:
if((p1_sw_trig=0) or (p1_sw_trig_old=1)) then dontToggleValue
p1_sw_trig_toggleVal=1-p1_sw_trig_toggleVal
dontToggleValue:
Sometime before serout
p1_sw_trig_old=p1_sw_trig
Using this code, the value of p1_sw_trig_toggleVal will flip between 0 and 1 everytime you press the trigger. If you want to do some other action (such as incremement some form of counter), replace p1_sw_trig_toggleVal=1-p1_sw_trig_toggleVal with the appropriate code. If you have any questions about this, please go ahead and ask. I should be able to answer within a few hours at the most.
|