I had a very similar problem and when running ts_test and ts_calibrate I had perfect results. But when I used pygame to run a simple test program, the mouse was all over the place and very wonky.
I realized that the issue must be with pygame, but I couldn't figure out what it was. I guess I skipped over the suggestions from Adafruit in their guide, but eventually I figured out that the issue was with my SDL version. To solve it I used this script to downgrade SDL to 1.2 and now everything works properly!
#!/bin/bash
# enable wheezy package sources
echo "deb http://archive.raspbian.org/raspbian wheezy main
" > /etc/apt/sources.list.d/wheezy.list
# set wheezy as default package source
echo "APT::Default-release \"wheezy\";
" > /etc/apt/apt.conf.d/10defaultRelease
# set the priority for libsdl from wheezy higher than the stretch package
echo "Package: libsdl1.2debian
Pin: release n=stretch
Pin-Priority: -10
Package: libsdl1.2debian
Pin: release n=wheezy
Pin-Priority: 900
" > /etc/apt/preferences.d/libsdl
# install
apt-get update
apt-get -y --allow-downgrades install libsdl1.2debian/wheezy
And this is the code I used for a simple test in pygame. Before running the previous script, the mouse was unreliable and all over the place. After running the previous script, it was doing a great job tracking with my finger.
import pygame
import os
from time import sleep
os.environ['SDL_VIDEODRIVER'] = 'fbcon'
os.environ['SDL_FBDEV'] = '/dev/fb1'
os.environ['SDL_MOUSEDRV'] = 'TSLIB'
os.environ['SDL_MOUSEDEV'] = '/dev/input/event0'
pygame.init()
lcd = pygame.display.set_mode((320,480))
lcd.fill((0,0,0))
while True:
for event in pygame.event.get():
mouse_position = pygame.mouse.get_pos()
print ""
print ("Tap on window at: {}".format(mouse_position))
pygame.display.update()
sleep(0.02)
UPDATE:
For this example, in my /boot/config.txt I have the following setting:
dtoverlay=pitft35-resistive,rotate=0,speed=32000000,fps=60
And make sure to run ts_calibrate if you change the rotation.
sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0