0

I have a small touchscreen attached to a Raspberry Pi, and when I start a Python script via an attached keyboard, directly on /dev/tty1, this script is able to execute pygame.display.init() successfully when directfb is set in the environment variable SDL_VIDEODRIVER.

This Raspberry Pi will be mounted somewhere without a keyboard, to control and display some energy consumption statistics. It will be accessible via SSH.

I'm attempting to use PyGame because apparently this will give me full access to the framebuffer, so that I am no longer constrained to the 40x30 character console display.

Initially I auto-started a screen -S main on /dev/tty1, and it was really useful to be able to attach to the screen on my local machine, but the 40x30 character limit is too constraining.

So now I'm SSHing into the device and issuing commands like setsid sh -c './start_game.sh <> /dev/tty1 >&0 2>&1'

where ./start_game.sh contains

cd ~/python/game
date
python3 show.py

and show.py should then be rendering the GUI.

But for some reason on /dev/tty1 I'm being told that using directfb failed.

show.py contains

import os
import pygame
drivers = ['directfb', 'fbcon']
found = False
for driver in drivers:
  if not os.getenv('SDL_VIDEODRIVER'):
    os.putenv('SDL_VIDEODRIVER', driver)
  try:
    pygame.display.init()
    print('Driver: {0}.'.format(driver))
  except pygame.error:
    print('Driver: {0} failed.'.format(driver))
    continue
  found = True
  break
if not found:
 print('No suitable video driver found!')

What do I need to do so that I can use directfb in this fashion (fbcon also doesn't work)?

I've tried stuff like issuing DISPLAY=:0 but I don't really know what it does.

I think that maybe I have to use stty somehow, but I have never used that command.

X is not installed and I want to avoid it. It should run as a headless device with a fancy display.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.