예제 #1
0
from pitftgpio import PiTFT_GPIO

pitft = PiTFT_GPIO()


def my_callback(pin):
    print "Button:" + str(pin) + " callback"


pitft.Button4Interrupt(callback=my_callback)
while True:
    if pitft.Button1:
        print "Button 1 pressed - screen off"
        pitft.Backlight(False)
    if pitft.Button2:
        print "Button 2 pressed - screen on"
        pitft.Backlight(True)
    if pitft.Button3:
        print "Button 3 pressed"
    #if pitft.Button4:
    #   print "Button 4 pressed"
예제 #2
0
    os.putenv('SDL_MOUSEDRV', 'TSLIB')
    os.putenv('SDL_MOUSEDEV', '/dev/input/touchscreen')
    tftscreen = PiTFT_GPIO()
##############################################################################
# Create a clock and set max FPS (This reduces a lot CPU ussage)
pygame.init()
# Screen size (currently fixed)
size = width, height = 320, 240
screen = pygame.display.set_mode(size)

# Set up the callback functions for the buttons
if RASPBERRYPI:
    tftscreen.Button1Interrupt(TFTBtn1Click)
    tftscreen.Button2Interrupt(TFTBtn2Click)
    tftscreen.Button3Interrupt(TFTBtn3Click)
    tftscreen.Button4Interrupt(TFTBtn4Click)

pygame.mouse.set_visible(False if RASPBERRYPI else True)

FPS = 15
clock = pygame.time.Clock()
screenindex = 0

quit = False
# b = pygame.time.get_ticks()
d = 0
newscreen = False
newwait = 0
# refresh = 60000
# refreshNow = False
# SWIPE_TO_SCREEN = 0