示例#1
0
def GetButton(): 
    global B1
    global B2
    global B3
    global B4
    btn = 0
    if GPIO.input(B1)==0: btn = 1
    if GPIO.input(B2)==0: btn = 2
    if GPIO.input(B3)==0: btn = 3
    if GPIO.input(B4)==0: btn = 4
    return btn
示例#2
0
    print('Drawing image')
    disp.display(background)

    res = nmp.start()
    if ('error' in res):
        print "Error: "+res["error"]
    else:
        usuario = res["user"]
        password = res["password"]
        extra =  res["extra"]
        if (usuario=='test' and password=='test1'):
            image = Image.open ('logo.png')
            openDoor()
        else:
            image = Image.open ('logo-no.png')
            closeDoor()
        disp.display(image)


while True:
    input_state = GPIO.input(27)
    if (opencnt>0):
        opencnt=opencnt-1
    if (opencnt==0):
        closeDoor()
        opencnt = -1;
    if (input_state == False):
        print ("Pulsado")
        showqr()
    time.sleep(0.2)
示例#3
0
    textimage = Image.new('RGBA', (width, height), (0,0,0,0))
    # Render the text.
    textdraw = ImageDraw.Draw(textimage)
    textdraw.text((0,0), text, font=font, fill=fill)
    # Rotate the text image.
    rotated = textimage.rotate(angle, expand=1)
    # Paste the text into the image, using it as a mask for transparency.
    image.paste(rotated, position, rotated)


while(True):#repeat
    disp.clear((0, 0, 0))
    # --------------------SWITCH BETWEEN SCREENS--------------------
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    input_state = GPIO.input(16)
    if input_state == False:
        dist_sens = False
        time.sleep(0.2)
    else:
        dist_sens = True
    #--------------------DISTANCE SENSOR DATA SCREEN--------------------
    if (dist_sens == False):
        sens_accX, sens_accY, sens_accZ = motion.accelerometer()

        draw.rectangle((217, 310, 23, 260), outline=(255, 255, 255), fill=(0, 120, 255))

        draw.rectangle((217, 250, 23, 200), outline=(255, 255, 255), fill=(0, 120, 255))
        i = sens_accY * 57.295779513
        w, h = draw.textsize(str(round(int(i))))
        draw_rotated_text(disp.buffer, str(round(i)), (120 - w, 220), text_rotation, font,fill=(255, 255, 255))