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
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
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.
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