运行 PyGame 没有启动到桌面的程序 Raspberry Pi
Run PyGame program without booting to Desktop Raspberry Pi
我正在为 Raspberry Pi 使用 PiTFT 显示器,我想 运行 我的 PyGame (Python) 程序而不启动到桌面。
我想这样做的原因是因为这意味着更少的 RAM 使用,这在 Raspberry Pi 上非常重要。
之前有人问过这个问题,但是 none 的答案是最新的,否则一开始就没有用。
我不太清楚你遇到了什么问题,但这应该很简单。
我在使用 PiTFT 屏幕时将其添加到 pygame 脚本的顶部(none 我的 Pis 使用桌面环境):
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')
然后你只需要确保你的 pi 不会启动到桌面环境。您可以通过 运行:
sudo raspi-config
并更改相关设置。
我正在为 Raspberry Pi 使用 PiTFT 显示器,我想 运行 我的 PyGame (Python) 程序而不启动到桌面。
我想这样做的原因是因为这意味着更少的 RAM 使用,这在 Raspberry Pi 上非常重要。 之前有人问过这个问题,但是 none 的答案是最新的,否则一开始就没有用。
我不太清楚你遇到了什么问题,但这应该很简单。
我在使用 PiTFT 屏幕时将其添加到 pygame 脚本的顶部(none 我的 Pis 使用桌面环境):
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')
然后你只需要确保你的 pi 不会启动到桌面环境。您可以通过 运行:
sudo raspi-config
并更改相关设置。