Skip to content

istvanzk/python-multitouch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Multitouch Drivers

Multi-touch Python drivers

  1. FT5406: for the official 7" touchscreen display (pure Python by Pimoroni).

  2. EP0510M09: for the 4DSystems GEN4-4DPI-50CT-CLB, https://4dsystems.com.au/gen4-4dpi-50ct-clb (by IstvanZK)

EP0510M09 Beta (based on Pimoroni FT5406 Beta)

Uses python3-evdev, https://python-evdev.readthedocs.io/en/latest/index.html

Uses asyncio to read and store the touchscreen events returned from evdev

FT5406 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 FT5406 Beta 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 the EP0510M09 Beta Library

import ep0510m09
ts = ep0510m09.Touchscreen()

while True:
    for touch in ts.touches:
        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 and ep0510m09:

  • 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 Python drivers for FT5406 and EP0510M09 touchscreens

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.5%
  • Shell 0.5%