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)
def SPIsendByte(byteTosend): i = 0 for i in range(1,9): if (byteTosend & 0x80): GPIO.output(pin_MOSI, GPIO.HIGH) else: GPIO.output(pin_MOSI, GPIO.LOW) #sleep(0.00001) GPIO.output(pin_CLK, GPIO.LOW) #sleep(0.00001) GPIO.output(pin_CLK, GPIO.HIGH) byteTosend = byteTosend << 1 return
def init(): # SET CS HIGH GPIO.output(pin_CS, GPIO.HIGH) #Reset LCD GPIO.output(pin_RST, GPIO.LOW) sleep(1) GPIO.output(pin_RST, GPIO.HIGH) sleep(1) send(0x21,SEND_CMD) send(0xC8,SEND_CMD) send(0x04,SEND_CMD) send(0x40,SEND_CMD) send(0x12,SEND_CMD) send(0xE4,SEND_CMD)# Set Display offset line 1 send(0x45,SEND_CMD)# Set Display offset line 2: shiftet 5 pixels up and then use lines 1 to 6 send(0x20,SEND_CMD) send(0x08,SEND_CMD) send(0x0C,SEND_CMD) setContrast(DEFAULT_CONTRAST) clear() update()
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) except KeyboardInterrupt: print("Goodbye.")
__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) except KeyboardInterrupt: print ("Goodbye.")
def LCDReset(): GPIO.output(pin_RST, GPIO.LOW) time.sleep(0.05) GPIO.output(pin_RST, GPIO.HIGH)
def LCD_DC_LOW(): GPIO.output(pin_DC, GPIO.LOW) return
def LCD_DC_HIGH(): GPIO.output(pin_DC, GPIO.HIGH) return
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)
__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: print ("Goodbye.")