from time import sleep
from pyA20EVB.gpio import gpio
from pyA20EVB.gpio import port

__author__ = "Stefan Mavrodiev"
__copyright__ = "Copyright 2014, Olimex LTD"
__credits__ = ["Stefan Mavrodiev"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = __author__
__email__ = "*****@*****.**"

led = port.PG9

gpio.init()
gpio.setcfg(led, gpio.OUTPUT)

try:
    print("Press CTRL+C to exit")
    while True:
        gpio.output(led, 1)
        sleep(0.1)
        gpio.output(led, 0)
        sleep(0.1)

        gpio.output(led, 1)
        sleep(0.1)
        gpio.output(led, 0)
        sleep(0.1)

        sleep(0.6)
Example #2
0
from pyA20EVB.gpio import gpio
from pyA20EVB.gpio import port

__author__ = "Stefan Mavrodiev"
__copyright__ = "Copyright 2014, Olimex LTD"
__credits__ = ["Stefan Mavrodiev"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = __author__
__email__ = "*****@*****.**"


led = port.PG9

gpio.init()
gpio.setcfg(led, gpio.OUTPUT)

try:
    print ("Press CTRL+C to exit")
    while True:
        gpio.output(led, 1)
        sleep(0.1)
        gpio.output(led, 0)
        sleep(0.1)

        gpio.output(led, 1)
        sleep(0.1)
        gpio.output(led, 0)
        sleep(0.1)

        sleep(0.6)
Example #3
0
__author__ = "Stefan Mavrodiev"
__copyright__ = "Copyright 2014, Olimex LTD"
__credits__ = ["Stefan Mavrodiev"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = __author__
__email__ = "*****@*****.**"

led = connector.gpio0p0     # This is the same as port.PH2
button = connector.gpio3p40

"""Init gpio module"""
gpio.init()

"""Set directions"""
gpio.setcfg(led, gpio.OUTPUT)
gpio.setcfg(button, gpio.INPUT)

"""Enable pullup resistor"""
gpio.pullup(button, gpio.PULLUP)
#gpio.pullup(button, gpio.PULLDOWN)     # Optionally you can use pull-down resistor

try:
    print ("Press CTRL+C to exit")
    while True:
        state = gpio.input(button)      # Read button state

        """Since we use pull-up the logic will be inverted"""
        gpio.output(led, not state)

except KeyboardInterrupt:
Example #4
0
        print colored('Fail', 'red')
    except NameError:
        print 'Fail'
    sys.exit(0)
    

print 'Initializating GPIO-MODULE.....',   
try:
    #GPIO.setmode(GPIO.BCM)
    #GPIO.setwarnings(False)
    #GPIO.setup(0, GPIO.OUT)     #SDA -> LCD_C/#D
    #GPIO.setup(1, GPIO.OUT)     #SCL -> #LCD_RESET
    #GPIO.output(0, True)
    #GPIO.output(1, True)
    GPIO.init();
    GPIO.setcfg(pin_RST,GPIO.OUTPUT) #UEXT PIN 5 LCD RESET
    GPIO.setcfg(pin_DC,GPIO.OUTPUT) #UEXT PIN 6 LCD DC
    GPIO.output(pin_RST, GPIO.HIGH)
    GPIO.output(pin_DC, GPIO.HIGH)
    try:
        print colored('Done', 'green')
    except NameError:
        print 'Done'
except ImportError:
    try:
        print colored('Fail', 'red')
    except NameError:
        print 'Fail'
    sys.exit(0)
   
Example #5
0
#pin_MOSI = port.PI18 #SPI1- MOSI
#pin_MISO = port.PI19 #SPI1 MISO
#pin_CLK = port.PI17 #SPI1 CLK
#pin_RST = port.PB18 #UEXT PIN 5 LCD RESET
#pin_DC = port.PB19 #UEXT PIN 6 LCD DC

# UEXT1
pin_CS = port.PC19 # SPI2-CS
pin_MOSI = port.PC21 #SPI2- MOSI
pin_MISO = port.PC22 #SPI2 MISO
pin_CLK = port.PC20 #SPI2 CLK
pin_RST = port.PB20 #UEXT PIN 5 LCD RESET
pin_DC = port.PB21 #UEXT PIN 6 LCD DC


GPIO.setcfg(pin_CS,GPIO.OUTPUT) # SPI1-CS
GPIO.setcfg(pin_MOSI,GPIO.OUTPUT)  #SPI1- MOSI
GPIO.setcfg(pin_MISO,GPIO.INPUT) #SPI1 MISO
GPIO.setcfg(pin_CLK,GPIO.OUTPUT) #SPI1 CLK
GPIO.setcfg(pin_RST,GPIO.OUTPUT) #UEXT PIN 5 LCD RESET
GPIO.setcfg(pin_DC,GPIO.OUTPUT) #UEXT PIN 6 LCD DC

def send(cmd,type):
	GPIO.output(pin_CS, GPIO.LOW)
	if(type == SEND_CHR):
		GPIO.output(pin_DC, GPIO.HIGH)
	else:	
		GPIO.output(pin_DC, GPIO.LOW)
	SPIsendByte(cmd)
	GPIO.output(pin_CS, GPIO.HIGH)