jonaslorander / OctoPiPanel

OctoPiPanel creates a simple interface on a small screen to control OctoPrint.
Other
80 stars 40 forks source link

pygame.error: video system not initialized #3

Closed guysoft closed 10 years ago

guysoft commented 10 years ago

When starting OctoPiPanel from X using fbcp I get this error:

pi@octopi ~/OctoPiPanel $ python ./OctoPiPanel.py 
Traceback (most recent call last):
  File "./OctoPiPanel.py", line 575, in <module>
    opp = OctoPiPanel(320, 240, "OctoPiPanel!")
  File "./OctoPiPanel.py", line 133, in __init__
    pygame.mouse.set_visible(False)
pygame.error: video system not initialized

I can start an lxterminal with no problem using that shell, so its not an X server setting problem.

jonaslorander commented 10 years ago

It is probably due to that the buffer is used by X. Does it work if you start it from a console, without running X?

guysoft commented 10 years ago

Ah, I think I know why its not working, just took a look at the code.

I am using a pi-display, and their docs show export FRAMEBUFFER=/dev/fb0 And in your code I see: os.putenv('SDL_FBDEV' , '/dev/fb1')

I will try changing that and starting it once I get the time. If this is the case scanning for fb devices might be a good idea.

jonaslorander commented 10 years ago

Ah, they use a different framebuffer then Adafruit does. Yes, scanning for framebuffer would be the way to do it :)

guysoft commented 10 years ago

Ok, i managed to start OctoPiPanel, but I get a blank screen. I had to set the env variables like this:

os.putenv('SDL_FBDEV'      , '/dev/fb0')
os.putenv('SDL_MOUSEDEV'   , '/dev/input/mice')

However all I get now is a blank screen I am using a pi-display

jonaslorander commented 10 years ago

That is odd. BUt looking at the pi-display docs that you link to above it seems that the correct framebuffer actually is /dev/fb1, and /dev/fb0 is the HDMI output. Perhaps chaning the os.putenv('SDL_VIDEODRIVER', 'fbcon') to os.putenv('SDL_VIDEODRIVER', 'fbcp') might help. BUt on the other hand, here is how you use Adafruits PiCamera app on your display, https://github.com/notro/fbtft-spindle/wiki/FBTFT-image#adafruit-camera-app and I use the same screen init code as Adafruit.

Also perhaps you need to do a touch screen calibration; https://github.com/notro/fbtft-spindle/wiki/FBTFT-image#touchpanel-calibration

jonaslorander commented 10 years ago

Or you can just comment out the pygame.mouse.set_visible(False) and see what happends...

jonaslorander commented 10 years ago

Or perhaps the backlight is turned off: https://github.com/watterott/RPi-Display#the-display-stays-black Does the screen show anything if you exits OctoPiPanel using Ctrl + C?

guysoft commented 10 years ago

The backlight is not off, there is a small visible small white cursor at the top of the screen. The screen goes black when i run OctoPiPanel.py, and goes back to the console when I do Ctrl + C

I will try and get a photo here. @awatterott Any chance you know of the differences?

awatterott commented 10 years ago

@guysoft You dont need fbcp. Pygame can directly write via SDL to the framebuffer. The only thing that is different between our RPi-Display and the Adafruit PiTFT is the touch controller and backlight control.

SDL_VIDEODRIVER = fbcon SDL_FBDEV = /dev/fb1

jonaslorander commented 10 years ago

That's what I figured as well since the Adafruit PiCamera Python script seems to be working for @awatterott RPi display.

guysoft commented 10 years ago

Success! The screen is visible, the mouse is not responding.

@awatterott I am getting selected device is not a touchscreen I understand After pointing the mouse device to /dev/input/mouse0 If I do cat /dev/input/mouse0 tapping on the screen produces output.

Note: This has to be run without X, with the shell visible, and with fb1.

awatterott commented 10 years ago

@guysoft The input device is /dev/input/touchscreen.

N1c3 commented 10 years ago

@guysoft @awatterott
this device /dev/input/touchscreen does not exist on my setup (2014-06-20-wheezy-octopi-0.9.0 with builtin version of your driver) what do i have to load or do, to get this inputdevice

N1c3 commented 10 years ago

getting mouse curser to go by setting /dev/input/eventX get the right event nr by watching cat /proc/bus/input/devices

then you have to calibrate the touchscreen sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/eventX ts_calibrate

N1c3 commented 10 years ago

@guysoft i think it would work with your api version this way on mine just the system commands are working....

awatterott commented 10 years ago

@LowVideo /dev/input/touchscreen is a symlink to the right event device. Would be good to have this also on OctoPi... https://github.com/notro/fbtft-spindle/blob/master/fbtft-stage2#L112

guysoft commented 10 years ago

Pushed it to the rpi-display branch, I need to build and test it: https://github.com/guysoft/OctoPi/commit/286ad2237023f38cd101750dd29651d657344ee2

guysoft commented 10 years ago

Tested, that commit solves the problem, however the screen needs to be calibrated first (not sure how to integrate that yet)

jonaslorander commented 10 years ago

Awsome! I'm closing this now.