Hyperpixel, tocuh screen callibration


#1

Hello, I am playing with the Hyperpixel in terminal using pygame but I am having issues with callibration. This is the code.

import pygame, os

os.putenv('SDL_VIDEODRIVER', 'fbcon')
pygame.init()

screen = pygame.display.set_mode((800, 480), pygame.FULLSCREEN)
pygame.mouse.set_visible(False)

screen.fill((0,100,255))
pygame.display.update()

font_big = pygame.font.Font(None, 100)

while True:
    for event in pygame.event.get():
        pass
    screen.fill((0,100,255))
    mouse =  pygame.mouse.get_pos()
    print mouse
    pygame.draw.circle(screen, (255,0,0), mouse, 100, 0)
    pygame.display.update()

It works fine but the X and Y of the mouse is not aligned to the size of the screen, is this because I have to do callibration or is it another issue? standard callibration does not seem to work because it looks like there is no input in /dev/input/touchscreen


#2

There shouldn’t be any need for calibration. The driver is reporting min and max range values, plus coordinates within those explicitly, see: https://github.com/pimoroni/hyperpixel/blob/master/requirements/usr/bin/hyperpixel-touch#L31-L4

If I remember correctly, PyGame’s support for touchscreens is just terrible. That’s why I whipped up a multi-touch capable driver for the official touchscreen, which just happens to work with HyperPixel too: https://github.com/pimoroni/python-multitouch

You will have to tweak this line to make it work with HyperPixel: https://github.com/pimoroni/python-multitouch/blob/master/library/ft5406.py#L115, changing it to “Touchscreen” which is how HyperPixel identifies itself.

Once we’ve cracked how to write our own touch recognition driver based on just the analog readings from HyperPixel I’ll be making a bigger deal of this library, and also probably offering a “direct mode” Python driver that skips all the uinput stuff and just talks directly to the touchscreen.


Can I use the Hyperpixel touch screen with the Kivy GUI library without X server?
#3

Hey, Thanks it worked!

It seems to have a lot more lag as if it is buffering all the messages whilst I am rendering the screen in pygame ( I am selecting by one touch and only when pressed ) and tips on improving this?

while True:
    for touch in ts.poll():
        if touch.valid:
            pos = (touch.x, touch.y)
    # Do render here