Page 1 of 1

Waveshare 3.2" TFT, Pi model 3, pygame problem

Posted: Wed Apr 13, 2016 11:11 pm
by The German
Hi yall,
I am going crazy with this issue - the installation of the 3.2 Waveshare is fine when running X11 and with

Code: Select all

TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event2 ts_calibrate
I get the calibration from the command line done just fine, it shows the values and all is good. Now in my small python script, I can do the graphical output just fine, the problem is trying to read the mouse input - the x/y values are all over the place even when touching the screen..
Here's the code:

Code: Select all

#!/usr/bin/python
import os
import sys
import time
import pygame

os.environ['SDL_VIDEODRIVER'] = 'Allwinner A10/A13 FBDEV'
os.environ["SDL_FBDEV"] = "/dev/fb1"
os.environ["SDL_MOUSEDRV"] = "TSLIB"
os.environ["SDL_MOUSEDEV"] = "/dev/input/event2"

pygame.init()
blue = (0,0,255)
black = (0,0,0)
white = (255,255,255)
gpos =(0,0)
bgimage = pygame.image.load('bg0003.jpg')
bgimage = pygame.transform.scale(bgimage, (320,240))
screen = pygame.display.set_mode((320,240))

screen.fill (black)
screen.blit(bgimage, (0,0))
myfont = pygame.font.SysFont("Computerfont",40)
prglabel  = myfont.render('Test cheapo TFT', 1, white)
pygame.draw.rect(screen, blue, (0,0,480,40),)
screen.blit(prglabel, (40, 5))
pygame.display.update()
while True:
   for event in pygame.event.get():
      if event.type == 6:
         cpos = pygame.mouse.get_pos()
         if (cpos <> gpos):
            print cpos
            gpos = cpos
Here is an example of the output when pressing the screen at exactly one location with the stylus

Code: Select all

(263, 0)
(179, 0)
(185, 0)
(319, 0)
(319, 239)
(319, 0)
(269, 28)
(34, 198)
(319, 121)
(242, 0)
(143, 239)
(319, 0)
(319, 23)
(319, 0)
(261, 0)
(319, 202)
(319, 239)
(319, 0)
(319, 148)
(265, 0)
(79, 92)
(247, 161)
(237, 239)
Any idea how this could be fixed??

Re: Waveshare 3.2" TFT, Pi model 3, pygame problem

Posted: Fri Apr 15, 2016 6:56 pm
by The German
Well, I tried two of the same displays with the same result and both work just fine on a Pi 2. Looks like Waveshare did not update the drivers correctly, maybe the Pi 3 is simply too fast for their touchscreen driver. Back to the Pi 2 for me :-(

Re: Waveshare 3.2" TFT, Pi model 3, pygame problem

Posted: Sat May 14, 2016 3:29 am
by barneyman
sorry, late to the party - i'm having the same problems with the 4d 2.4" TFT

It's a wheezy SDL 1.2 issue for me ...

https://learn.adafruit.com/adafruit-pit ... ygame-tips