Odd X clipping with PiTFT

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
User avatar
ab1jx
 
Posts: 19
Joined: Wed Apr 30, 2014 10:37 pm

Odd X clipping with PiTFT

Post by ab1jx »

At some point in calibrating my PiTFT I started noticing some clipping or masking on the left side and top of the TFT, which is also affecting what I get over a vnc connection. I've deleted my 99-calibration.conf, rebooted several times, done hard power offs, it's still there.

Image This is an fbgrab (haven't figured out color depth yet, it's not really green)
Image This is a digital photograph taken with a real camera
Image This is a screenshot of a vnc window done with xwd on my OpenBSD machine.

Sometimes when X is starting up it's normal until almost the end, then this happens. Sometimes I can click with a mouse in the dead area and it comes back. It's like something's writing to the root window or framebuffer over the top of what should be there. Linux is enough different from OpenBSD that I'm not sure where to look for the cause of this. It's possibly the same width and height (in terms of pixels) in both the TFT and the vnc, it's just more significant on the TFT.

I don't know if this is related, but running xinput_calibrator is weird, nothing happens at all when I click the crosshairs and it's almost as if the program has crashed but it's still on the screen. It actually never does anything visible beyond painting its initial screen. Even with my USB mouse unplugged, if I run xinput_calibrator --list it sees 2 devices:
Device "stmpe-ts" id=8
Device "stmpe-ts" id=7

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Odd X clipping with PiTFT

Post by adafruit_support_mike »

I've never seen anything like that before..

The fact that you're having trouble with the calibrator and the fact that you're seeing an offset on the screen are probably related. The only probable cause I can imagine would be some incompatibility with a package that existed on the RasPi before you installed the PiTFT packages.

Did you start from a fresh install of Raspbian or build on top of an existing system?

User avatar
ab1jx
 
Posts: 19
Joined: Wed Apr 30, 2014 10:37 pm

Re: Odd X clipping with PiTFT

Post by ab1jx »

No, I added the PiTFT to what's essentially a production machine. I use it regularly for other things and keep it reasonably up to date with apt-get update and apt-get upgrade. I did find another picture Image from earlier in the install when the problem was only at the top of the screen. It's not an offset: it's overwriting what should be there rather than moving it down. The second attempt at calibration started overwriting the side of the screen as well as the top.

I've got FRAMEBUFFER defined in my .bashrc to /dev/fb1 so I can type startx in an ssh session to bring it up. When it comes up it's normal at first then the side and top get overwritten, I just watched it again.

Why does xinput_calibrator see 2 devices? Is it possible that it "calibrated" one of them incorrectly?
(Device "stmpe-ts" id=8, Device "stmpe-ts" id=7). Or that the one it calibrated isn't the one that's in use?

I don't know how this calibration gets stored or if it's possible to undo it. I was about to try some reinstalls of all the PiTFT stuff.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Odd X clipping with PiTFT

Post by adafruit_support_mike »

It does sound like the calibration has moved the display off from where it should be.

I'm not sure what could have caused the system to recognize the touchscreen encoder twice, but that does sound like the kind of error that will snowball.

I'd suggest starting on a new SD card with a freshly installed OS. The Linux kernel has lots of moving parts, so there a countless ways for two pieces to interfere with each other.

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: Odd X clipping with PiTFT

Post by adafruit2 »

thats really weird. dont *think* its related to the touchscreen but also, you can use our default calibration numbers for X and it ought to be close to fine.

User avatar
ab1jx
 
Posts: 19
Joined: Wed Apr 30, 2014 10:37 pm

Re: Odd X clipping with PiTFT

Post by ab1jx »

You mean what the PDF had me type into /etc/X11/xorg.conf,.d/99calibration.conf? I'll try that.

Is this stuff double buffering-aware? I had a couple video programs installed since I have the official camera that plugs into the mainboard. Some of the calibration seems like it's writing to a framebuffer that's not showing. Maybe the calibration is doing something but I can't see what, except as undesirable side effects.

So rather than a clean Linux I loaded up FreeBSD release 10 on another SD card. I don't really like Linux that much and I'm much more comfortable with the BSDs, especially OpenBSD. Which probably boots me right out of Adafruit support, but I can switch back and forth. dmesg there detects the gpio and framebuffer, not the touchscreen. I just got it running last night, I've still got a lot more work to do on just the basic operating system and utilities. (by modem, that's all I've got)

root@raspberry-pi:~ # dmesg | grep fb
fb0: <BCM2835 framebuffer device> on fdtbus0
fb0: 656x416(0x0@0,0) 16bpp
fb0: pitch 1312, base 0x5e006000, screen_size 545792
root@raspberry-pi:~ #

root@raspberry-pi:~ # dmesg | grep gpio
gpio0: <BCM2708/2835 GPIO controller> mem 0x20200000-0x202000af irq 57,59,58,60 on simplebus0
gpio0: read-only pins: 46,47,48,49,50,51,52,53.
gpio0: reserved pins: 48,49,50,51,52,53.
gpioc0: <GPIO controller> on gpio0
gpiobus0: <GPIO bus> on gpio0

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Odd X clipping with PiTFT

Post by adafruit_support_mike »

I'm a long-time NetBSD junkie, so we won't kick you out over that.

Having said that though, cross-platform driver support can be challenging, so we don't guarantee it as a plug-and-play solution. If you can get it to work, by all means post a play-by-play.

User avatar
ab1jx
 
Posts: 19
Joined: Wed Apr 30, 2014 10:37 pm

Re: Odd X clipping with PiTFT

Post by ab1jx »

I started this thread http://www.raspberrypi.org/forums/viewt ... 85&t=76372 rather than reinvent the wheel. I write a little code, mainly plain C, but I'm not about to start from scratch. I don't know where to find source code of your drivers, all I've got are binaries.

Is it possible to write to the PiTFT as if it were memory-mapped? I'm thinking not through X but mostly for plotting.

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: Odd X clipping with PiTFT

Post by adafruit2 »

If you want, you can raw-write to the PiTFT and skip the framebuffer altogether. but you'd have to port this code to userspace which is like totally not supported (but ought to work!)

https://github.com/adafruit/Adafruit_ILI9341

User avatar
ab1jx
 
Posts: 19
Joined: Wed Apr 30, 2014 10:37 pm

Re: Odd X clipping with PiTFT

Post by ab1jx »

I'll try it. I sort of miss Borland Graphics like from Turbo C and Turbo Pascal. I might try to make a minimal implementation of those, but I've also used hpgl and simple postscript among others. I've done plotting into a memory buffer where you write to x + (y * width) as an offset, then I pirated a font from giflib, and write the buffer out to jpeg or raw, or whatever. Being able to define visual buttons on the TFT and read touchscreen events to associate with them should do what I want.

Back to the original problem: where does this calibration live and how can I reset it? Even with the PiTFT unplugged my screen still isn't normal.

Looks like I'll have to rethink FreeBSD, I'm still having issues building some ports.

User avatar
notro
 
Posts: 93
Joined: Tue Sep 11, 2012 9:59 am

Re: Odd X clipping with PiTFT

Post by notro »

Back to the original problem: where does this calibration live and how can I reset it?
If you have followed the tutorial, it's in /etc/X11/xorg.conf.d/99-calibration.conf
I guess it's xinput-calibrator_0.7.5-1_armhf.deb that creates this file.
tutorial
Is it possible to write to the PiTFT as if it were memory-mapped?
You can have a look at fbtest: https://github.com/notro/fbtft/wiki/Testing#fbtest
The actual mmap'ing is done in fb.c:fb_map(): https://git.kernel.org/cgit/linux/kerne ... /fb.c#n202

If speed isn't important, here's something I have done in Python:
https://github.com/notro/fbtft_test/blob/master/gfx.py
https://github.com/notro/fbtft_test/blob/master/fb.py
https://github.com/notro/fbtft_test/blo ... test_fb.py

If you want to make a simple GUI, pygame is very easy to start with.
Have a look at Adafruits camera app that uses pygame: https://learn.adafruit.com/diy-wifi-ras ... m/pi-setup
Just uncomment the camera lines in the code if you want to run it without a camera.

This is a minimal example: https://github.com/notro/fbtft/wiki/Pygame

User avatar
ab1jx
 
Posts: 19
Joined: Wed Apr 30, 2014 10:37 pm

Re: Odd X clipping with PiTFT

Post by ab1jx »

I guess I'll end this thread. The calibration I was trying to undo may have been in the file /etc/pointercal which is the output from ts_calibrate. Unfortunately in removing stuff I removed the bootloader without replacing it, the Pi wouldn't boot, so I salvaged my files and dumped a new image onto the SD card. I'm still getting things back to normal but I'm not seeing the same problem anymore with something overwriting part of the screen.

One suggestion: you might mention in your documentation that when running ts_calibrate you should see 5 calibration crosshairs to click on. I was getting some bounce effect and sometimes only seeing 2 or 3 because it was registering my clicks multiple times and advancing through the calibration too fast.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Odd X clipping with PiTFT

Post by adafruit_support_mike »

That's a good point. I'll pass that along to the folks who manage the Learning System.

User avatar
ab1jx
 
Posts: 19
Joined: Wed Apr 30, 2014 10:37 pm

Re: Odd X clipping with PiTFT

Post by ab1jx »

The same seems to be true for xinput_calibrator which has 4 crosshairs.

I think some of my problem came from getting bogus calibration values in /etc/pointercal because of the bouncing. If the screen width or height is 0 (or negative?) because 2 calibration points were the same physical point something strange is bound to happen. Publishing a typical pointercal might be good, mine now looks like:
33 -5831 21475954 4235 -24 -706044 65536.6.

I'm still not out of the woods but I'm playing with a freshly imaged SD card. My touchscreen seems very sensitive to even bumping the power wire. Trying to figure out if it's more of a hardware or software problem.

User avatar
ab1jx
 
Posts: 19
Joined: Wed Apr 30, 2014 10:37 pm

Re: Odd X clipping with PiTFT

Post by ab1jx »

OK, I've got everything working on the Pi running the fresh image, now I need to put my 64 gig card back and fix that. But it's a software issue, not hardware, so I don't need to return my PiTFT. The latest problem was having smtpe-ts where it should have been stmpe-ts in the MatchProduct of my 99-calibration file, which made SwapAxes not work.

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”