this seems as good a place as any to announce my new add-on shield TFT board :

You'll need to compile the kernel and modules to enable the fb1 framebuffer, as outlined in Mark's excellent blog here :
http://marks-space.com/2012/11/23/raspberrypi-tft/
Many thanks to Kamal Mostafa for sharing his code : http://www.whence.com/rpi/
Purchase details can be found here :
http://www.raspberrypi.org/phpBB3/viewt ... 59&t=40674
Sample test python code :
Code: Select all
# 1.8" TFT test prog
# v1 11/4/13
import wiringpi2 as wiringpi
from subprocess import call
import pygame, sys, os, time
from pygame.locals import *
os.environ["SDL_FBDEV"] = "/dev/fb1"
IN = OFF = 0
OUT = ON = 1
PUD_DOWN = 1
UP = 13 # gpio pin 21 = UP
DOWN = 2 # gpio pin 13 = DOWN
SELECT = 11 # gpio pin 26 = LEFT
pygame.init()
# set up the window
DISPLAYSURF = pygame.display.set_mode((128, 160), 0, 32)
pygame.mouse.set_visible(0)
pygame.display.set_caption('Drawing')
# set up the colors
BLACK = ( 0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = ( 0, 255, 0)
BLUE = ( 0, 0, 255)
# draw on the surface object
DISPLAYSURF.fill(BLACK)
print "black"
time.sleep(.5)
pygame.display.update()
DISPLAYSURF.fill(RED)
print "red"
time.sleep(.5)
pygame.display.update()
DISPLAYSURF.fill(GREEN)
print "green"
time.sleep(.5)
pygame.display.update()
DISPLAYSURF.fill(BLUE)
print "blue"
time.sleep(.5)
pygame.display.update()
DISPLAYSURF.fill(WHITE)
print "white"
time.sleep(.5)
pygame.display.update()
# demo draw some shapes
pygame.draw.polygon(DISPLAYSURF, GREEN, ((16, 0), (111, 106), (36, 277), (56, 27), (0, 106)))
pygame.draw.line(DISPLAYSURF, BLUE, (60, 60), (120, 60), 4)
pygame.draw.line(DISPLAYSURF, BLUE, (120, 60), (60, 120))
pygame.draw.line(DISPLAYSURF, BLUE, (60, 120), (120, 120), 4)
pygame.draw.circle(DISPLAYSURF, BLUE, (40, 50), 20, 0)
pygame.draw.ellipse(DISPLAYSURF, RED, (110, 200, 40, 80), 1)
pygame.draw.rect(DISPLAYSURF, RED, (100, 150, 100, 50))
pygame.display.update()
time.sleep(.5)
#player movie
#sudo mplayer -vo fbdev2:/dev/fb1 -x 128 -y 160 -zoom VfE_html5.mp4
call(["mplayer", "-vo", "fbdev2:/dev/fb1", "-x", "128", "-y", "160", "-zoom", "VfE_html5.mp4"])
#set up the gpio's for the 3 buttons
wiringpi.wiringPiSetup()
for pin in [UP, DOWN, SELECT]:
wiringpi.pinMode(pin, IN) # set to input
wiringpi.pullUpDnControl(pin, PUD_DOWN) # enable pull down resistor
# run the game loop
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
input_value1 = wiringpi.digitalRead(UP)
input_value2 = wiringpi.digitalRead(DOWN)
input_value3 = wiringpi.digitalRead(SELECT)
if input_value1 == True:
font = pygame.font.Font(None, 36)
text = font.render("UP", 1, RED)
textpos = text.get_rect(centerx=DISPLAYSURF.get_width()/2)
DISPLAYSURF.blit(text, textpos)
pygame.display.update()
elif input_value2 == True:
font = pygame.font.Font(None, 36)
text = font.render("DOWN", 1, GREEN)
textpos = text.get_rect(centerx=DISPLAYSURF.get_width()/2)
DISPLAYSURF.blit(text, textpos)
pygame.display.update()
elif input_value3 == True:
font = pygame.font.Font(None, 36)
text = font.render("SELECT", 1, BLUE)
textpos = text.get_rect(centerx=DISPLAYSURF.get_width()/2)
DISPLAYSURF.blit(text, textpos)
pygame.display.update()
else:
DISPLAYSURF.fill(WHITE)
pygame.display.update()
print "UP = ",input_value1
print "DOWN = ",input_value2
print "SELECT = ",input_value3
time.sleep(.5)
Cheers,
Texy