Skip to content

Multi-touch pure Python driver for the official 7" touchscreen display.

Notifications You must be signed in to change notification settings

zithro/python-multitouch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python FT5406 Multitouch Driver

Multi-touch pure Python driver for the official 7" touchscreen display.

Beta

This is a work in progress, but lets you use all 10 points of multitouch on the official 7" Pi Touchscreen in Python.

Note: It will only work with any sort of sanity in fullscreen mode currently

Hit ESC to exit the examples.

Installing

Navigate into the library folder, and run setup like so:

cd library
sudo python3 setup.py install

See the examples folder for usage!

Using The Library

import ft5406
ts = ft5406.Touchscreen()

while True:
    for touch in ts.poll():
        print(touch.slot, touch.id, touch.valid, touch.x, touch.y)

The slot is a number from 0 to 9, denoting which index the touch is at.

The touch id is a unique ID given to the touch by evdev.

Touch valid indicates whether the touch is active- ie: is synonymous to pressed.

Both x and y should be self explanatory!

Using Events

Three different kinds of event are generated by ft5406:

  • Press TS_PRESS
  • Release TS_RELEASE
  • Move TS_MOVE

You can assign handlers to individual touches and events or just use the same handler for all of them.

The example below shows the base minimum you need to set up and handle events. This doesn't even include a GUI- Python will monitor the touchscreen directly.

from ft5406 import Touchscreen, TS_PRESS, TS_RELEASE, TS_MOVE

ts = Touchscreen()

def touch_handler(event, touch):
    if event == TS_PRESS:
        print("Got Press", touch)
    if event == TS_RELEASE:
        print("Got release", touch)
    if event == TS_MOVE:
        print("Got move", touch)

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

ts.run()

while True:
    # Redraw Code etc
    try:
        pass
    except KeyboardInterrupt:
        ts.stop()
        exit()

About

Multi-touch pure Python driver for the official 7" touchscreen display.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.2%
  • Shell 0.8%