User manual
Now you can simplify your previous code this way:
from synapse.platforms import *
pulsePin(GPIO_1, 500, True)
For an RF100, the GPIO_1 constant will already be defined as 1, and for an
RF200 it will already be defined as 6. You don’t need to make any condional
branch in order to affect the same pin on the SNAP-Engine-footprint. Just refer
to the pin by its posion on the SNAP Engine and the table of constants
performs the translaon for you.
The RF100.py and RF200.py files (and others like them) provide other useful
conversions, too. Each contains a tuple constant, GPIO_TO_IO_LIST, that maps SNAP Engine pins to their
corresponding SNAP constant values (i.e., for an RF200, posion 1 in the tuple contains a 6), and another tuple
constant, IO_TO_GPIO_LIST, that maps SNAP constants to their corresponding SNAP Engine pins (i.e., for an
RF200, posion 6 in the tuple contains a 1). This can be useful for code like this:
from synapse.platforms import *
@setHook(HOOK_GPIN)
def onSignal(whichPin, isSet):
gPin = IO_TO_GPIO_LIST[whichPin]
print 'GPIO_', gPin, ' is ', isSet
If this were set on the boom right pin on a SNAP Engine, it would print “GPIO_11 is False” or “GPIO_11 is True”
(depending on the isSet state) when the state of that pin changed (assuming you were monitoring that pin). This
translaon to 11 would occur whether the whichPin variable received an 11 (as it would on an RF100) or a 24 (as
it would on an RF200), making the output easy to interpret.
It’s important to consider that these GPIO numbers are only meaningful in the context of a SNAP Engine, a SNAP
node on Synapse’s 24-pin through-hole module footprint. If you are working with one of the surface-mount
SNAP modules, such as the SM200 or the SM220, the pin notaon is not useful.
For surface-mount modules, then, the plaorms file imports constants based on the eight-by-eight grid of pads
on the module’s underside. GPIO_D2 on an SM200 is equal to 6 when used in your SNAPpy code. That is the
same pin, internally, that comes out as GPIO_1 on an RF200. But on the surface-mount module, it is the second
pin up in the fourth row (row D) over. Similarly, GPIO_A4 on an SM200 is 24, which would be GPIO_11 on an
RF200. (Any pad that does not have a meaningful value to SNAP, such as a power or ground pin, is set equal to -1
for the surface-mount modules.)
For either of these formats, you could use the GPIO_TO_IO_LIST tuple, for example, to drive all the output pins
on a SNAP Engine high:
from synapse.platforms import *
def setAllHigh():
whichPin = 0
while whichPin < len(GPIO_TO_IO_LIST):
pin = GPIO_TO_IO_LIST[whichPin]
setPinDir(pin, True)
writePin(pin, True)
whichPin += 1
SNAP® Network Operang System 29