UtahJarhead
Posts: 11
Joined: Fri May 15, 2015 2:00 am

PyGame display to framebuffer if execution happens over SSH?

Sun Oct 25, 2015 4:15 pm

I'm currently using 'fbi' to send images to the framebuffer, but I'm redoing it in Python (pygame specifically) because fbi displays lots of error text, is prone to display issues, and offers no customization ability.

I can execute it fine from the console while logged in, but I'd like to be able to execute it remotely via SSH and I'd like to also update the framebuffer if it's executed either by rc.local or by cron.

Basically, any time the application is executed, no matter where it's executed from, I want it to update /dev/fb0.

Is this possible?

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: PyGame display to framebuffer if execution happens over

Sun Oct 25, 2015 4:18 pm

PyGame uses SDL , and SDL respects an environment variable called "SDL_FBDEV" (see code).

http://harizanov.com/2013/02/using-my-1 ... s-display/

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

UtahJarhead
Posts: 11
Joined: Fri May 15, 2015 2:00 am

Re: PyGame display to framebuffer if execution happens over

Sun Oct 25, 2015 4:48 pm

You are an OUTSTANDING individual! I'll give it a shot and come back with results.

UtahJarhead
Posts: 11
Joined: Fri May 15, 2015 2:00 am

Re: PyGame display to framebuffer if execution happens over

Sun Oct 25, 2015 6:26 pm

Sadly, that does not seem to work. :(

pygame still cannot init the driver from a remote session.

Code: Select all

#!/usr/bin/python

import os
import pygame
import sys

#drivers = ('X11', 'dga', 'ggi','vgl','aalib','directfb', 'fbcon', 'svgalib')
drivers = ('directfb', 'fbcon', 'svgalib')

os.putenv('SDL_FBDEV','/dev/fb0')
os.environ["SDL_FBDEV"] = "/dev/fb0"

found = False
for driver in drivers:
	print "Trying \'" + driver + "\'",
	if not os.getenv('SDL_VIDEODRIVER'):
		os.putenv('SDL_VIDEODRIVER',driver)
	try:
		pygame.display.init()
	except pygame.error:
		print 'failed'
		continue
	found = True
	break
if not found:
	raise Exception('No suitable video driver found.')

print "success"
size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
screen = pygame.display.set_mode(size, pygame.FULLSCREEN)

pygame.init()
size = width, height = 320, 240
print pygame.display.get_wm_info()

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: PyGame display to framebuffer if execution happens over

Sun Oct 25, 2015 7:21 pm

UtahJarhead wrote:Basically, any time the application is executed, no matter where it's executed from, I want it to update /dev/fb0.
Is this possible?
If you build your display output as an image and then have your display device, I guess that's the RPi in this case, loop and display on the framebuffer each second or so, you'll get what I think you want. That's near real time updating asynchronously, which means you can just let the pi or whatever the output is run in a loop and then worry about making your changes elsewhere.

I had suggested /tmp because I thought they'd made the default mount tmpfs but I was wrong about that. I would put the image files in /run/shm, which I just checked this time, claims to have about 80meg available. One programmatically created jpg is going to be likely a few hundred K.

Return to “Python”