示例#1
0
文件: lcd.py 项目: N8body/pcd8544
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")
    GPIO.init()
    #pins = [CLK, DIN, DC, RST, LIGHT, CE]
    pins = [pin_CLK, pin_DIN, pin_DC, pin_RST, pin_LIGHT, pin_CE]
    #pin_CLK, pin_DIN, pin_DC, pin_RST, pin_LIGHT, pin_CE = pins
    for pin in pins:
        GPIO.setcfg(pin, GPIO.OUTPUT)
        GPIO.output(pin,GPIO.HIGH)
    #map(lambda p: , pins)
    # Reset the device
    GPIO.output(pin_RST, GPIO.LOW)
    time.sleep(0.1)
    GPIO.output(pin_RST, GPIO.HIGH)
    set_contrast(contrast)
    #command([0x26])
    cls()
示例#2
0
文件: lcd.py 项目: HenningAust/py_LCD
import struct



# Some constants / parameter
SEND_CHR = 1
SEND_CMD = 2
X_RANGE = 84
Y_RANGE = 48
DEFAULT_CONTRAST = 0xC0
LCD_CACHE_SIZE = X_RANGE*Y_RANGE/8
LCD_Memory = [0 for i in range(LCD_CACHE_SIZE)]
LCD_TEMP = [0 for i in range(X_RANGE)],[0 for i in range(Y_RANGE)]


GPIO.init();
pin_CS = GPIO.PIN_PI16 # SPI1-CS
pin_MOSI = GPIO.PIN_PI18 #SPI1- MOSI
pin_MISO = GPIO.PIN_PI19 #SPI1 MISO
pin_CLK = GPIO.PIN_PI17 #SPI1 CLK
pin_RST = GPIO.PIN_PB18 #UEXT PIN 5 LCD RESET
pin_DC = GPIO.PIN_PB19 #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):
示例#3
0
文件: monitor.py 项目: dukenux/watch
def getProcessId(processName):
    ps = subprocess.Popen("ps ax -o pid= -o args= ", shell=True, stdout=subprocess.PIPE)
    ps_pid = ps.pid
    output = ps.stdout.read()
    ps.stdout.close()
    ps.wait()
    for line in output.split("\n"):
        res = re.findall("(\d+) (.*)", line)
        if res:
            pid = int(res[0][0])
            if processName in res[0][1] and pid != os.getpid() and pid != ps_pid:
                return pid
    return -1

print "Init monitor"
GPIO.init()
GPIO.setcfg(GPIO.PIN3_39, GPIO.INPUT)
GPIO.setcfg(GPIO.PIN3_40, GPIO.INPUT)
screenState=False
motionStatus = True
os.system("echo 1 > /sys/class/gpio/gpio27_pb2/value")
infile_path = "/dev/input/event3"
#long int, long int, unsigned short, unsigned short, unsigned int
FORMAT = 'llHHI'
EVENT_SIZE = struct.calcsize(FORMAT)
#open file in binary mode
in_file = open(infile_path, "rb")
try:
    event = in_file.read(EVENT_SIZE)
    while event:
        (tv_sec, tv_usec, type, code, value) = struct.unpack(FORMAT, event)