kbanks
02-08-2008, 02:09 PM
A new function was added to Snappy a while back.
The new function is called setRate().
setRate() takes a single parameter 0-3, with the values controlling the sampling rate for the monitorPin() feature.
0 = OFF
This might come in handy if you are being overrun by HOOK_BUTTON, and just want cancel them all
1 = 100 ms sampling
This was the only sample rate prior to this upgrade, and this is now the default rate
2 = 10 ms sampling
3 = 1 ms sampling
The "sampling rate speedup" applies to all 19 GPIO pins, it is not specific to only one (or a few) pins.
So, a Snappy script similiar to the following could be the basis for your measurement code:
--- Begin script ---
def startupEvent():
setPinPullup(0,True)
setPinDir(0,False) # NOT an output
monitorPin(0,True)
setRate(3) # switch to 1 ms sampling
(more code goes here)
Note that you may hit other performance limitations if you try to monitor too many pins, at too high a sample rate.
The new function is called setRate().
setRate() takes a single parameter 0-3, with the values controlling the sampling rate for the monitorPin() feature.
0 = OFF
This might come in handy if you are being overrun by HOOK_BUTTON, and just want cancel them all
1 = 100 ms sampling
This was the only sample rate prior to this upgrade, and this is now the default rate
2 = 10 ms sampling
3 = 1 ms sampling
The "sampling rate speedup" applies to all 19 GPIO pins, it is not specific to only one (or a few) pins.
So, a Snappy script similiar to the following could be the basis for your measurement code:
--- Begin script ---
def startupEvent():
setPinPullup(0,True)
setPinDir(0,False) # NOT an output
monitorPin(0,True)
setRate(3) # switch to 1 ms sampling
(more code goes here)
Note that you may hit other performance limitations if you try to monitor too many pins, at too high a sample rate.