time-out code for waitpeq
in Propeller 1
Is there a way to time out and restart some code from the beginning after a certain period of time, like 15 seconds if a waitpeq is not is not progressed past?
repeat
if INA[7]==1
lcd.str(string(12))
waitcnt(clkfreq/100+cnt)
lcd.str(string("deposit 2",17,13))
waitcnt(clkfreq/100+cnt)
lcd.str(string("quarters."))
waitcnt(clkfreq/100+cnt) 'initial call for audio triggered by pir, ina[7]
dac.playWAVFile(string("whistle.wav"))
waitpeq(%100000000000000000000, |< 20, 0) 'Wait for Pin 20 to go high
waitpeq(%000000000000000000000, |< 20, 0) 'Then wait for Pin 20 to go low

Comments
pub wait4pin(pin, state, toms) | t '' Wait for pin to match state for no longer that toms milliseconds '' -- returns true if pin matches state before timeout '' -- pin is 0..27 '' -- state is 0..1 '' -- toms is milliseconds (positive) t := cnt repeat toms if (ina[pin] == state) return true waitcnt(t += clkfreq/1000)