Adafruit PiTFt and Pygame issues

Hi Team,
I acquire an Adafruit 320.240 pixel TFT Capacitative touchscreen and have configured it as per Adafruits instructions.
I don’t want to use it as a console.
I have managed to push a jpg to it using fbi and that works.
I’m now trying to write to it using Python3 and the pygame libraries.
My code doesn’t give any errors but instead of writing to the PiTFT - it pops up in a new Xwindo…
I understand pygame use the sdl and I think V1.2 is required.
I think I have SDL 1.2 installed.
Here’s the python code:

import pygame
import os
os.putenv(‘SDL_FBDEV’, ‘/dev/fb1’)
os.putenv(‘SDL_VIDEODRIVER’, ‘fbcon’)
lcd = pygame.display.set_mode((320, 240))

I am at a loss.
Any help would be much appreciated.


I solved this one myself in the end ! I usually connect to my Pi’s via VNC from my macbook, and am thus using X-Windows.
It would appear that if pygame is used in a python program called either from Geany or a shell window, it directs the output to the same X-Window matter what settings you use !
The solution ended being to ssh to the Pi from my macbook and execute the script manually from there.

1 Like

Nice find, I wouldn’t have guessed that was the reason why!

I’m still not quite out of the woods with it. The X-Window system “Freezes” when the Adafruit is in use. Which is a PITA while prototyping, but at leats I’ve worked out how to gracefully exit it.
Presently working on adding live BOM forecast data to the display…Seriously, it’s never ending !

1 Like