Nicholas Harris
Nicholas Harris

Reputation: 103

Run PyGame program without booting to Desktop Raspberry Pi

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.

Upvotes: 1

Views: 3254

Answers (1)

elParaguayo
elParaguayo

Reputation: 1318

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.

Upvotes: 3

Related Questions