• Uncategorized

About python : Run-PyGame-program-without-booting-to-Desktop-Raspberry-Pi

Question Detail

I am using the PiTFT display for the Raspberry Pi, and I want to run my PyGame (Python) program without booting to the Desktop.

The reason I want to do this is because it will mean less RAM usage, and that is pretty important on a Raspberry Pi.
This has been asked before, but none of the answers are up to date, or else never worked in the first place.

Question Answer

I’m not exactly clear what problem you’re having, but this should be fairly straightforward.

I add this at the top of my pygame scripts when using the PiTFT screen (none of my Pis use the desktop environment):

import os
# Tell the RPi to use the TFT screen and that it's a touchscreen device
os.putenv('SDL_VIDEODRIVER', 'fbcon')
os.putenv('SDL_FBDEV'      , '/dev/fb1')
os.putenv('SDL_MOUSEDRV'   , 'TSLIB')
os.putenv('SDL_MOUSEDEV'   , '/dev/input/touchscreen')

Then you just need to make sure your pi doesn’t boot into the desktop environment. You can do that by running:

sudo raspi-config

and changing the relevant setting.

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.