Hi zusammen,
ich komme gerade nicht weiter mit der Ausgabe von Text auf meinem Display einem Sainsmart1,8" ST7735R (SPI) mit 128x160Pixel Auflösung.
Ich wollte mit folgenden Beispielprogramm von Martin Text auf dem Display darstellen
Python
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# TFT display
# 2013-04-22 V0.1 by Thomas Hoeser
# http://www.hoeser-medien.de
# based on Martin's Hobby Projects:
# http://harizanov.com/2013/02/using-my-1-8-tft-as-a-raspberry-pi-status-display/
#
# Pygame-Modul importieren.
import pygame
import sys
import os
import time
time_stamp_prev=0
# Set the framebuffer device to be the TFT
os.environ["SDL_FBDEV"] = "/dev/fb1"
# don't have X11 running when you start it
# could be "fbcon", "directfb", try "aalib" for extra fun
os.environ['SDL_VIDEODRIVER']="fbcon"
#------------------------------------------------------------------------------------------------------
def displayText(text, size, line, color, clearScreen):
"""Used to display text to the screen. displayText is only configured to display
two lines on the TFT. Only clear screen when writing the first line"""
# screen-Surface mit Schwarz (RGB = 0, 0, 0) füllen.
if clearScreen:
screen.fill((0, 0, 0))
font = pygame.font.Font(None, size)
text = font.render(text, 0, color)
textRotated = pygame.transform.rotate(text, -90)
textpos = textRotated.get_rect()
textpos.centery = 80
if line == 1:
textpos.centerx = 90
screen.blit(textRotated,textpos)
elif line == 2:
textpos.centerx = 40
screen.blit(textRotated,textpos)
#------------------------------------------------------------------------------------------------------
def main():
global screen
# Initialisieren aller Pygame-Module und
# Fenster erstellen (wir bekommen eine Surface, die den Bildschirm repräsentiert).
pygame.init()
pygame.mouse.set_visible(0)
size = width, height = 128, 160
screen = pygame.display.set_mode(size)
sleep_time = 5
while True:
displayText('Aussen-Temp.', 30, 1, (200,200,1), True )
displayText(' 32 Grad ', 50, 2, (200,200,1), False )
pygame.display.flip() #Update the full display Surface to the screen
time.sleep(sleep_time)
if __name__ == '__main__':
main()
Alles anzeigen
Ich arbeite über VNC auf dem Raspberry Pi.
Nach dem Start des Programmes im Terminal bekomme ich folgende Fehlermeldung:
Zitat
Client is not authorized to connect to Serverxcb_Connection_has_error() returned true
Traceback (most recent call last):
File "tft.py", line 65, in main
Screen = pygame.Display.set_mode(size)
pygame.error: No Video mode large enough for128x160
Kann mir jemand einen Tipp geben warum die Fehlermeldung kommt?
Gruß Andreas