LEDs and Buttons

The SNAPconnect E20 includes three tri-color LEDs that you can control from your programs, plus three buttons you can monitor.

LEDs

Each of the three LEDs can be red, green, or amber. Each has a script you can use to set the LED state:

led-a red
led-b green
led-c amber
led-a off

You do not need to use sudo to control the LEDs. You can simply add the users you want to have control of the LEDs to the leds group.

By default, all three of these LEDs will turn amber when the gateway is powered on and then turn off after the device boots.

Each of the three LEDs is controlled by a pair of GPIOs from the i.MX6 processor, with one controlling the red, one controlling the green, and the two of them together generating amber.

If you would rather control the LEDs using the GPIOs rather than the scripts, these are the lines for each LED and color:

GPIO 40

LED-1

red

GPIO 41

LED-1

green

GPIO 42

LED-2

red

GPIO 43

LED-2

green

GPIO 44

LED-3

red

GPIO 45

LED-3

green

SNAP Module-Controlled LED

The unit’s SNAP module controls the tri-color LED labeled “SNAP” via GPIO_A4 (green) and GPIO_A5 (red). (For amber, use both green and red.) This LED is only accessible via the SNAP module. It cannot be controlled by the E20’s i.MX6 processor, except through calls to the SNAP module.

These two IO lines from the SNAP module will light their respective colors when written high. This sample code demonstrates its use:

from synapse.platforms import *

@setHook(HOOK_STARTUP)
def onStartup():
    setPinDir(GPIO_A4, True)
    setPinDir(GPIO_A5, True)
    LED_off()

def LED_off():
    writePin(GPIO_A4, False)
    writePin(GPIO_A5, False)

def LED_green():
    writePin(GPIO_A4, True)
    writePin(GPIO_A5, False)

def LED_red():
    writePin(GPIO_A4, False)
    writePin(GPIO_A5, True)

def LED_amber():
    writePin(GPIO_A4, True)
    writePin(GPIO_A5, True)

The SNAP LED is the only LED controllable directly from the SNAP module. The other three LEDs are controlled from the E20’s i.MX6 processor.

Buttons

The three buttons on the left side of the SNAPconnect E20 are fully user-accessible. There are button commands that print the button status to STDIO and return the button status (as 1 for up or 0 for pressed):

button-1
button-2
button-3

You can monitor the i.MX6 processor GPIOs directly rather than using the Bash scripts if you find that to be easier:

GPIO 117

BUTTON-1

GPIO 118

BUTTON-2

GPIO 119

BUTTON-3