예제 #1
0
    os.environ["SDL_MOUSEDRV"] = "TSLIB"

# Initialize pygame modules individually (to avoid ALSA errors) and hide mouse
pygame.font.init()
pygame.display.init()
pygame.mouse.set_visible(0)

# Initialise GPIO
GPIO.setwarnings(False)


#While loop to manage touch screen inputs
state = [False for x in range(10)]
while 1:
    if SCREEN==4:
        for touch in ts.poll():
            if state[touch.slot] != touch.valid:
                if touch.valid:
                    sys.exit()
    else:
        for event in pygame.event.get():
            if event.type == pygame.MOUSEBUTTONDOWN:
            sys.exit()

        #Debug:
        #ensure there is always a safe way to end the program if the touch screen fails
        ##if event.type == KEYDOWN:
        ##    if event.key == K_ESCAPE:
        ##        sys.exit()

    time.sleep(0.4)
예제 #2
0
    # Display splash screen.
    splash = pygame.image.load('freqshow_splash.png')
    screen.fill(MAIN_BG)
    screen.blit(splash, ui.align(splash.get_rect(), (0, 0, size[0], size[1])))
    pygame.display.update()
    splash_start = time.time()
    # Create model and controller.
    fsmodel = model.FreqShowModel(size[0], size[1])
    fscontroller = controller.FreqShowController(fsmodel)
    time.sleep(0.25)
    # Main loop to process events and render current view.

    ts = Touchscreen()

    def touch_handler(event, touch):
        fscontroller.current().click((touch.x, touch.y))

    for touch in ts.touches:
        touch.on_press = touch_handler

    while True:
        # Ignore pygame events
        for event in pygame.event.get():
            pass

        ts.poll()

        # Update and render the current view.
        fscontroller.current().render(screen)
        pygame.display.update()