I want to use pygame on a raspi to display pictures on the screen connected to the hdmi port of the raspi. I want to do this via a ssh connection.
As a first test, I tried the very basic (and classic) script that tests for the available drivers:
import os
import pygame
disp_no = os.getenv('DISPLAY')
print("I'm running under {}".format(disp_no))
drivers = ['directfb', 'fbcon', 'svgalib']
found = False
for driver in drivers:
if not os.getenv('SDL_VIDEODRIVER'):
os.putenv('SDL_VIDEODRIVER', driver)
os.environ["SDL_FBDEV"] = "/dev/fb0"
try:
pygame.display.init()
print('OK with',driver)
except pygame.error:
print('Driver: {0} failed.'.format(driver))
continue
found = True
break
if not found:
raise Exception('No suitable video driver found!')
Here are the results of my tests :
- from a ssh session : no suitable video driver found
- from a ssh session as root : OK with directfb
- from a tty console (with a keyboard connected to the raspi) : OK with directfb
My question is : why does situation 1 results in a failure. What do I miss and what should I do?
Please note that permissions on /dev/fb0 and all /dev/tty?? are set so that I can read/write without being root. Also note that I don't have the X server running.