Before diving in to this tutorial, first follow the setup instructions for your PiTFT. Make sure to choose the correct guide particularly for resistive vs capacitive displays and carefully follow the section on PiTFT Pygame Tips - in particular you really need SDL 1.2!

You can also grab all the tutorial source code from git:

git clone https://github.com/jerbly/tutorials.git

To test the display you can run through these steps in the python console:

[email protected] ~ $ sudo python
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>> import os
>>> os.putenv('SDL_FBDEV', '/dev/fb1')
>>> pygame.init()
(6, 0)
>>> lcd = pygame.display.set_mode((320, 240))
>>> lcd.fill((255,0,0))
<rect(0, 0, 320, 240)>
>>> pygame.display.update()
>>> pygame.mouse.set_visible(False)
>>> lcd.fill((0,0,0))
<rect(0, 0, 320, 240)>
>>> pygame.display.update()

You can also run this test (with a one second sleep) from the pygamelcd project:

sudo python test1.py

OK now you're ready!

Last updated on 2016-04-11 at 12.11.08 PM Published on 2016-02-01 at 03.40.14 PM