def init(CLK=11, DIN=10, DC=23, RST=24, LIGHT=18, CE=8, contrast=default_contrast): """ init screen, clearscreen """ wiringPy.debug(0) if wiringPy.setup_gpio() != 0: raise IOError("Failed to initialize wiringPy properly") fd = wiringPy.setup_bitbang(CE, DIN, CLK, 0) if fd == -1: raise IOError("Failed to initialize bitbang properly") pins = [CLK, DIN, DC, RST, LIGHT, CE] pin_CLK, pin_DIN, pin_DC, pin_RST, pin_LIGHT, pin_CE = pins map(lambda p: wiringPy.pin_mode(p, ON), pins) # Reset the device wiringPy.digital_write(pin_RST, OFF) time.sleep(0.1) wiringPy.digital_write(pin_RST, ON) set_contrast(contrast) cls()
def main(window): wiringPy.setup(); for pin in range(0,8): wiringPy.pin_mode(pin, 1) curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_BLUE) curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_GREEN) curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_YELLOW) curses.init_pair(4, curses.COLOR_BLACK, curses.COLOR_RED) curses.curs_set(0) window.nodelay(True) window.clear() window.border(0) window.addstr(2, 2, "Raspberry Ladder VU meter") window.refresh() while window.getch() < 0: draw(window) window.refresh() time.sleep(0.05) window.clear() window.refresh()
def initDevice(self): """Initialise the screen""" wiringPy.debug(0) if wiringPy.setup_gpio() != 0: raise IOError("Failed to initialize wiringPy properly") fd = wiringPy.setup_bitbang(self._CS, self._SDATA, self._SCLK, 0) if fd == -1: raise IOError("Failed to initialize bitbang properly") pins = [self._SDATA, self._SCLK, self._RST, self._CS] map(lambda p: wiringPy.pin_mode(p, ON), pins) # Reset the device self.reset() #Exit LCD sleep mode self.__spiInterface.command(0x11) #Turns on Booster voltage self.__spiInterface.command(0x03) #Display inversion ON self.__spiInterface.command(0x21) #Set LCD params: self.__spiInterface.command(0x36) self.__spiInterface.sData(0xC8) #Set pixel format self.__spiInterface.command(0x3A) #Set Contrast self.setContrast() #Clear All pixels #self.__spiInterface.command(0x22) #Display on self.ON() #Set to no operation self.__spiInterface.command(0x00)
def init(CLK = 11, DIN = 10, DC = 23, RST = 24, LIGHT = 18, CE = 8, contrast = default_contrast): """ init screen, clearscreen """ wiringPy.debug(0) if wiringPy.setup_gpio() != 0: raise IOError("Failed to initialize wiringPy properly") fd = wiringPy.setup_bitbang(CE, DIN, CLK, 0) if fd == -1: raise IOError("Failed to initialize bitbang properly") pins = [CLK, DIN, DC, RST, LIGHT, CE] pin_CLK, pin_DIN, pin_DC, pin_RST, pin_LIGHT, pin_CE = pins list(map(lambda p: wiringPy.pin_mode(p, ON), pins)) # Reset the device wiringPy.digital_write(pin_RST, OFF) time.sleep(0.1) wiringPy.digital_write(pin_RST, ON) set_contrast(contrast) cls()
#!/usr/bin/env python import wiringPy import time wiringPy.setup() for pin in range(0,8): wiringPy.pin_mode(pin, 1) wiringPy.digital_write_byte(255) print "whats your name?" name = raw_input() print "hello " + name doubles = [1,2,4,8,16,32,64,128] snooze = 0.1 while (True): for no in doubles: wiringPy.digital_write_byte(no) time.sleep(snooze) doubles.reverse() #for no in range (0,256): # wiringPy.digital_write_byte(no) # time.sleep(0.0625)
#!/usr/bin/env python import time import wiringPy if wiringPy.setup() < 0: print "Failed to initialize wiringPi" exit(-1) print "Rasberry Pi - Board revision:", wiringPy.board_revision() wiringPy.pin_mode(1, 2) for bright in range(0, 1024): wiringPy.pwm_write(1, bright) time.sleep(0.001) for bright in range(1024, -1, -1): wiringPy.pwm_write(1, bright) time.sleep(0.001) for pin in range(0, 8): wiringPy.pin_mode(pin, 1) for i in range(0, 256): wiringPy.digital_write_byte(i) time.sleep(0.02) wiringPy.digital_write_byte(0)