def setup_touch_exit(self): import ft5406 as TS self.ts = TS.Touchscreen() self.ts_press_event = TS.TS_PRESS for touch in self.ts.touches: touch.on_press = self._touch_handler touch.on_release = self._touch_handler self.ts.run()
def setup_touch_exit(self): try: import ft5406 as TS self.ts = TS.Touchscreen() self.ts_press_event = TS.TS_PRESS for touch in self.ts.touches: touch.on_press = self._touch_handler touch.on_release = self._touch_handler self.ts.run() except: self.ts = False print('Cannot create a touch exit!')
def __init__(self, logger, params): import ft5406 as TS super(TouchBehavior, self).__init__(logger, params) self.screen_sz = np.array([800, 480]) self.touch_area = 50 # +/- area in pixels that a touch can occur self.since = 0 self.has_touched = False self.buttons = list() self.loc2px = lambda x: self.screen_sz/2 + np.array(x)*self.screen_sz[0] self.px2loc = lambda x: np.array(x)/self.screen_sz[0] - self.screen_sz/2 self.interface = RPProbe(logger) self.ts = TS.Touchscreen() self.ts_press_event = TS.TS_PRESS self.last_touch_tmst = 0 for touch in self.ts.touches: touch.on_press = self._touch_handler touch.on_release = self._touch_handler self.ts.run()
def __init__(self): # Connect to receive images self.image_conn = ImageConnection() self.image_conn.connect(IMG_HOST, IMG_PORT, as_receiver=True) # Set up connection to send commands self.cmd = CommandConnection() self.cmd.connect(CMD_HOST, CMD_PORT, as_receiver=False) pygame.init() self._display_surf = pygame.display.set_mode( (MATRIX_WIDTH, MATRIX_HEIGHT)) pygame.display.set_caption("Info Screen") pygame.mouse.set_visible(False) self.clock = pygame.time.Clock() self.ts = ft5406.Touchscreen() self.touch_id = -1 self.running = True
# activate pins io.setmode(io.BCM) io.setup(pinEnable, io.OUT) for pin in range(4): io.setup(pinMotor[pin], io.OUT) io.setup(pinButton, io.IN, pull_up_down=io.PUD_DOWN) io.setup(pinLedI, io.OUT) io.output(pinLedI, True) io.setup(pinLedO, io.IN, pull_up_down=io.PUD_DOWN) io.add_event_detect(pinLedO, io.FALLING, callback=photo_callback) # start touchscreen ts = ft5406.Touchscreen() else: rootPath = "/Users/baptiste/Documents/python/rPi" # start pygame pygame.init() ##win = pygame.display.set_mode((screenWidth,screenHeight), pygame.FULLSCREEN, 32) win = pygame.display.set_mode((screenWidth, screenHeight), 32) clock = pygame.time.Clock() pygame.font.init() myfont = pygame.font.SysFont('Helvetica', 30) pygame.mouse.set_visible(0) winSize = (screenWidth, screenHeight) winCenter = (int(screenWidth / 2), int(screenHeight / 2))