def screenSYS(): # set up the window screen=lib.setupwindow() #Variable Sys date= time.strftime("%d %b %Y") t = os.popen("/opt/vc/bin/vcgencmd measure_temp") temp= t.read() page = urllib.urlopen("http://www.monip.org/").read() ip = page.split("IP : ")[1].split("<br>")[0] # set up background background = pygame.Surface(screen.get_size()) background = background.convert() background.fill(WHITE) # Set up forms bx3 = pygame.draw.rect(background, BLUE, (100, 0, 120, 30)) cir = pygame.draw.circle(background, BLACK, (21, 219), 20) # Display some text font36 = pygame.font.Font(None, 36) font25 = pygame.font.Font(None, 25) txt = font36.render("Systeme", 12, (BLACK)) txt1 = font36.render("<<", 1, (YELLOW)) txtdate = font25.render(date,1, (BLACK)) txttemp = font25.render(temp,1, (BLACK)) txtIP = font25.render(ip,1, (BLACK)) #text = pygame.transform.rotate(text,270) txtpos = txt.get_rect(center=(160,12)) txtpos2= txt1.get_rect(center=(20,215)) datepos= txtdate.get_rect(center=(270,230)) temppos= txttemp.get_rect(center=(276,200)) ippos = txtIP.get_rect(center=(160,120)) background.blit(txttemp, temppos) background.blit(txtdate, datepos) background.blit(txtIP, ippos) background.blit(txt, txtpos) background.blit(txt1, txtpos2) screen.blit(background, (0, 0)) pygame.display.flip() running = True # run the game loop while running: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() running = False elif event.type == pygame.MOUSEBUTTONDOWN: if cir.collidepoint(pygame.mouse.get_pos()): screenMain() pygame.display.update()
def screenMain(): # set up the window screen=lib.setupwindow() # Fill background background = pygame.Surface(screen.get_size()) background = background.convert() background.fill(WHITE) bx2 = pygame.draw.rect(background, YELLOW, (0, 80, 320, 80)) bxin2= pygame.draw.rect(background, WHITE, (5,85,310,70)) bx3 = pygame.draw.rect(background, RED, (0, 0, 320, 80)) bxin3 = pygame.draw.rect(background, WHITE, (5, 5, 310, 70)) bx4 = pygame.draw.rect(background, BLUE, (0, 160, 320, 80)) bxin4 = pygame.draw.rect(background, WHITE, (5, 165, 310, 70)) # Display some text font = pygame.font.Font(None, 36) txt = font.render("Systeme", 2, (BLACK)) txt1 = font.render("GPIO", 2, (BLACK)) txt2 = font.render("Camera",2, (BLACK)) #text = pygame.transform.rotate(text,270) txtpos = txt.get_rect(center=(160,40)) txtpos2= txt1.get_rect(center=(160,120)) txtpos3= txt2.get_rect(center=(160,200)) background.blit(txt, txtpos) background.blit(txt1, txtpos2) background.blit(txt2, txtpos3) screen.blit(background, (0, 0)) pygame.display.flip() running = True # run the game loop while running: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() running = False elif event.type == pygame.MOUSEBUTTONDOWN: if bxin2.collidepoint(pygame.mouse.get_pos()): screenGPIO() if bxin3.collidepoint(pygame.mouse.get_pos()): screenSYS() if bxin4.collidepoint(pygame.mouse.get_pos()): screenCamera() pygame.display.update()
def screenGPIO(): # set up the window screen=lib.setupwindow() # Fill background background = pygame.Surface(screen.get_size()) background = background.convert() background.fill(WHITE) # Set up forms box1 = pygame.draw.rect(background, YELLOW,(0, 0, 80, 80)) box2 = pygame.draw.rect(background, BLACK,(80, 0, 80, 80)) box3 = pygame.draw.rect(background, BLUE, (160, 0, 80, 80)) box4 = pygame.draw.rect(background, GREEN, (240, 0, 80, 80)) box5 = pygame.draw.rect(background, MAGENTA,(0, 80, 80, 80)) # box6 = pygame.draw.rect(background, RED,(80, 80, 80, 80)) # box7 = pygame.draw.rect(background, CYAN, (160, 80, 80, 80)) # box8 = pygame.draw.rect(background, BLACK, (240, 80, 80, 80)) # box9 = pygame.draw.rect(background, GREEN,(80, 160, 80, 80)) # box10 = pygame.draw.rect(background, BLUE, (160, 160, 80, 80)) # box11 = pygame.draw.rect(background, CYAN, (240, 160, 80, 80)) cir = pygame.draw.circle(background, BLACK, (22, 219), 20) # Display some text font = pygame.font.Font(None, 20) GPIO24 = font.render("GPIO 24", 1, (BLACK)) GPIO23 = font.render("GPIO 23", 1, (RED)) GPIO22 = font.render("GPIO 22",1, (YELLOW)) GPIO21 = font.render("GPIO 21",1, (BLACK)) GPIO4 = font.render("GPIO 4",1, (BLACK)) # GPIO21 = font.render("GPIO 21",1,(YELLOW)) # GPIO10 = font.render("GPIO 10",1,(BLACK)) # GPIO9 = font.render("GPIO 9 ",1,(BLACK)) # GPIO11 = font.render("GPIO 11",1,(BLACK)) # GPIO0 = font.render("GPIO 0",1,(BLACK)) # GPIO1 = font.render("GPIO 1",1,(BLACK)) text3 = font.render("<<",1, (YELLOW)) #text = pygame.transform.rotate(text,270) textpos = GPIO24.get_rect(center=(40,40)) textpos2= GPIO23.get_rect(center=(120,40)) textpos5= GPIO22.get_rect(center=(200,40)) textpos6= GPIO21.get_rect(center=(280,40)) textpos3= GPIO4.get_rect(center=(40,120)) #textpos7= GPIO21.get_rect(center=(120,120)) #textpos8= GPIO10.get_rect(center=(200,120)) #textpos9= GPIO9.get_rect(center=(280,120)) # textpos10= GPIO11.get_rect(center=(40,200)) # textpos11= GPIO0.get_rect(center=(120,200)) # textpos12= GPIO1.get_rect(center=(200,200)) textpos4= text3.get_rect(center=(21,215)) background.blit(GPIO24, textpos) background.blit(GPIO23, textpos2) background.blit(GPIO22, textpos5) background.blit(GPIO21, textpos6) background.blit(GPIO4, textpos3) # background.blit(GPIO21,textpos7) # background.blit(GPIO10,textpos8) # background.blit(GPIO9,textpos9) # background.blit(GPIO11,textpos10) # background.blit(GPIO0,textpos11) # background.blit(GPIO1,textpos12) background.blit(text3, textpos4) screen.blit(background, (0, 0)) pygame.display.flip() running = True #State of GPIO state18=0 state16=0 state15=0 state13=0 state7=0 state13=0 state19=0 state21=0 state23=0 state3=0 state5=0 # run the game loop while running: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() running = False elif event.type == pygame.MOUSEBUTTONDOWN: # 4 top buttons if box1.collidepoint(pygame.mouse.get_pos()): state18=lib.SRGPIO(state18,18) if box2.collidepoint(pygame.mouse.get_pos()): state16=lib.SRGPIO(state16,16) if box3.collidepoint(pygame.mouse.get_pos()): state15=lib.SRGPIO(state15,15) if box4.collidepoint(pygame.mouse.get_pos()): state13=lib.SRGPIO(state13,13) # # 4 middle buttons if box5.collidepoint(pygame.mouse.get_pos()): state7=lib.SRGPIO(state7,7) # if box21.collidepoint(pygame.mouse.get_pos()): # state13=lib.SRGPIO(state13,13) # if box2.collidepoint(pygame.mouse.get_pos()): # state21=lib.SRGPIO(state21,21) # if box5.collidepoint(pygame.mouse.get_pos()): # state19=lib.SRGPIO(state19,19) # # # 4 bottom button # if box4.collidepoint(pygame.mouse.get_pos()): # state23=lib.SRGPIO(state23,23) # if box6.collidepoint(pygame.mouse.get_pos()): # state3=lib.SRGPIO(state3,3) # if box9.collidepoint(pygame.mouse.get_pos()): # state5=lib.SRGPIO(state5,5) # back to screenMain if cir.collidepoint(pygame.mouse.get_pos()): lib.reset(18,16) screenMain() elif event.type == KEYDOWN and event.key == K_ESCAPE: running = False pygame.display.update()