我正在尝试让吡咯在raspberry pi上将任何东西发送到运行lite版本的raspbian上的框架缓冲器/dev/fb0。我是通过ssh连接的,图像应该显示在HDMI输出上。
我可以发送一些东西到/dev/fb0,它会显示
sudo fbi -T 1 1.jpg发送一个图像文件,我可以在监视器上看到
while true; do sudo cat /dev/urandom > /dev/fb0; sleep .01; done发出白噪音。
如何将游戏连接到“/dev/fb0 0”?
我试了很多例子,但都没有用。
例如,这段代码给出了一个错误
import os, pygame, time
def setSDLVariables(driver):
print("Setting SDL variables...")
os.environ["SDL_FBDEV"] = "/dev/fb0"
os.environ["SDL_VIDEODRIVER"] = driver
print("...done")
def printSDLVariables():
print("Checking current env variables...")
print("SDL_VIDEODRIVER = {0}".format(os.getenv("SDL_VIDEODRIVER")))
print("SDL_FBDEV = {0}".format(os.getenv("SDL_FBDEV")))
setSDLVariables('fbcon')
printSDLVariables()
try:
pygame.init()
except pygame.error:
print("Driver '{0}' failed!".format(driver))
size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
print("Detected screen size: {0}".format(size))返回
pi@raspberrypi:~/pve_img $ sudo python3 pg.py
pygame 2.1.2 (SDL 2.0.14, Python 3.9.2)
Hello from the pygame community. https://www.pygame.org/contribute.html
Setting SDL variables...
...done
Checking current env variables...
SDL_VIDEODRIVER = fbcon
SDL_FBDEV = /dev/fb0
Traceback (most recent call last):
File "/home/pi/pve_img/pg.py", line 22, in <module>
size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
pygame.error: video system not initialized对于在2021年运行带帧缓冲区的游戏有什么提示吗?
发布于 2022-01-12 17:02:35
解决办法:
我用pip安装了电子游戏。
sudo python3 -m pip install pygame卸载游戏与安装游戏不同
sudo apt-get install python3-pygame然后我可以把东西发送到屏幕上。示例
screen = pygame.display.set_mode(size )
clock = pygame.time.Clock()
for x in range(20):
screen.fill((0, 0, 0))
pygame.display.flip()
clock.tick(1)
screen.fill((200, 200, 0))
pygame.display.flip()
clock.tick(1)安装与上述代码一起工作的版本。
https://stackoverflow.com/questions/70685286
复制相似问题