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 initialised (slightly different software setup) #4

Closed okpail closed 10 years ago

okpail commented 10 years ago

Hi mister Lorander, Jonas,

I get the following error when trying to start OctoPiPanel

Traceback (most recent call last): File "./OctoPiPanel.py", line 595, in opp = OctoPiPanel(320, 240, "OctoPiPanel!") File "./OctoPiPanel.py", line 135, in init pygame.mouse.set_visible(False) pygame.error: video system not initialised

What is my hardware setup: Raspberry Pi B+ Adafruit 2,8 inch touch screen Raspberry Pi Camera rev 1.3

Software setup: Newest update raspbian Then followed the adafruit setup and got the display working as per their instruction pages: https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/software-installation the detailed installation. I did not do the callibatrion pages, since the touchscreen worked. Then I compiled the latest octoprint 1.1.0-3-gce9c9be That works fine from a remote computer

Then I followed your instructions to install octopipanel with user account Pi. Since the Rest API is activated in the latest octoprint 1.1.0-3-gce9c9be I copied the key from the configuration file in octoprint to the OctoPiPanel.cfg file.

I start the frame buffer for the small screen from a ssh session from my notebook FRAMEBUFFER=/dev/fb1 startx &

Then go to a terminal screen as user on the small screen connected to the raspberry pi and try to start...

cd ./OctoPiPanel/ sudo python ./OctoPiPanel.py &

error message appears:

Traceback (most recent call last): File "./OctoPiPanel.py", line 595, in opp = OctoPiPanel(320, 240, "OctoPiPanel!") File "./OctoPiPanel.py", line 135, in init pygame.mouse.set_visible(False) pygame.error: video system not initialised

I looked at the other issue with the same name and he uses a different panel. So I cannot translate it to my hardware context...

Could you help me solve this problem? kind regards Onno (okpail@gmail.com)

jonaslorander commented 10 years ago

Hi Onno,

Start OctoPiPanel without have X started, you cannot have both running at the same time on the same display. Instead of starting X (FRAMEBUFFER=/dev/fb1 startx &) start OctoPiPanel from the terminal instead, inside a screen session.

okpail commented 10 years ago

Hi Jonas,

So what am I missing?

I reconfigured the startup of the raspberry pi to start a terminal console. login as user pi scene1: cd ./OctoPiPanel/ sudo python ./OctoPiPanel.py & result: Traceback (most recent call last): File "./OctoPiPanel.py", line 595, in opp = OctoPiPanel(320, 240, "OctoPiPanel!") File "./OctoPiPanel.py", line 135, in init pygame.mouse.set_visible(False) pygame.error: video system not initialised

scene2: I am assuming that I have to use the FRAMEBUFFER=/dev/fb1 to switch to the little panel ? I tried this: sudo FRAMEBUFFER=/dev/fb1 python ./OctoPiPanel.py &

same error...

In fact I think I do not understand your frase "inside a screen session" There is an adafruit instruction to start a console on the little screen https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/using-the-console
Is that what you mean?

Kind regards, Onno

jonaslorander commented 10 years ago

Type screen to start the application called screen (you must have it installed from apt). Then you can start OctoPiPanel as you described. Using screen in this manner OctoPiPanel will not be shut down when you exit the terminal (if you started OctoPiPanel from SSH etc.).

Do you have overscan activated in you config.txt file? If so, try disabling it as it could case problems for PyGame.

okpail commented 10 years ago

Hi Jonas,

Appreciate your effort :-) My next scene 3:

logged in as root: installed screen with: sudo apt-get install screen logout and login with user pi: screen bash cd OctoPiPanel sudo FRAMEBUFFER=/dev/fb1 python ./OctoPiPanel.py & result: Traceback (most recent call last): File "./OctoPiPanel.py", line 595, in opp = OctoPiPanel(320, 240, "OctoPiPanel!") File "./OctoPiPanel.py", line 135, in init pygame.mouse.set_visible(False) pygame.error: video system not initialised

detached with ctrl+A D

This is a Nice way to be able to close an ssh session without killing the proces. That works :-) ( http://raspi.tv/2012/using-screen-with-raspberry-pi-to-avoid-leaving-ssh-sessions-open ) Reconnect with screen -r in case of only 1 screen. However no joy :-(

I hope that it might the overscan issue I will try later on and report back...

Kind regards, Onno

jonaslorander commented 10 years ago

Hi again,

You do not need to set the framebuffer before you start OctoPiPanel. It sets the framebuffer it self :)

Report back regarding if overscan is the issue.

regards, Jonas

okpail commented 10 years ago

Hi Jonas Well tried all that, no joy, same error. Tried overscan on and of. Did not solve the issue.

Could you please specify exactly how you use the screen command? That would probably eliminate any errors on my side. Also under which account you are running and if octoprint must be running or not? (maybe you start running octoprint in your configuration?)

I am at a loss at this moment :-( Since the errors are constantly the same I would expect that it is something simple :-)

okpail commented 10 years ago

So I looked in the user interface for the this new version of octopi print under settings. There is an option to enable the API. That was not enabled. Switched it on. No joy either. I saw in your code that you use the API from octoprint. (However I am not a programmer), did probably the API change?

jonaslorander commented 10 years ago

Your problem does not have anything with OctoPrint to do but you must have it running and have API enabled. Also you have to add the correct URL to you OctoPrint server as well as the API-key in OctopiPanel.cfg. For the API to work you have to have at least version 1.1 of OctoPrint.

Screen is very simple. You start it by typing screen (or attach an already running screen session using screen -dr). Then when you have a prompt you simply type sudo python ~/OctoPiPanel/OctoPiPanel.py. You have to be logged in as the user pi.

I can't reallyunderstand what could be wrong with it. Since you can run X on the TFT-screen.

You could try to uncomment line 135 (with the #-sign). And see what happends...

jonaslorander commented 10 years ago

Can you try "Test the setup" under "Stage 1 setup" from this site: http://jeremyblythe.blogspot.se/2014/09/raspberry-pi-pygame-ui-basics.html

okpail commented 10 years ago

Hi Jonas,

Did exacty as you said: screen sudo python ~/OctoPiPanel/OctoPiPanel.py

result:

Traceback (most recent call last): File "/home/pi/OctoPiPanel/OctoPiPanel.py", line 595, in opp = OctoPiPanel(320, 240, "OctoPiPanel!") File "/home/pi/OctoPiPanel/OctoPiPanel.py", line 135, in init pygame.mouse.set_visible(False) pygame.error: video system not initialised

Will try now your last suggestion: Test the setup :)

okpail commented 10 years ago

Hi Jonas,

pi@pyfi ~/OctoPiPanel $ sudo git clone https://github.com/jerbly/tutorials.git Cloning into 'tutorials'... remote: Counting objects: 141, done. remote: Total 141 (delta 0), reused 0 (delta 0) Receiving objects: 100% (141/141), 27.92 KiB, done. Resolving deltas: 100% (83/83), done. pi@pyfi ~/OctoPiPanel $ sudo python Python 2.7.3 (default, Mar 18 2014, 05:13:23) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import pygame import os os.putenv('SDL_FBDEV', '/def/fb1') pygame.init() (5, 1) lcd = pygame.display.set_mode((320,240)) Traceback (most recent call last): File "", line 1, in pygame.error: Unable to open /def/fb1 os.putenv('SDL_FBDEV', '/def/fb1') lcd = pygame.display.set_mode((320,240)) Traceback (most recent call last): File "", line 1, in pygame.error: Unable to open /def/fb1

most curious... ?? Indeed with the FRAMEBUFFER command it works ???

jonaslorander commented 10 years ago

/def/fb1 ahould be /dev/fb1. Change that and try running it again :)

Also I wanted you to type the commands into a Python console your self, not cloning his git ;)

jonaslorander commented 10 years ago

I see not that you did actually type the commands in the console. Bit as I wrote, you have misspelled /dev/fb1.

okpail commented 10 years ago

Hi Jonas, Ok, first part switching of colours display works... :-)

jonaslorander commented 10 years ago

Hi,

If it works I see no reason as to way OctoPiPanel shouldn't work :/

Try commenting out lines 125, 127 and 128 (not 126) in OctoPiPanel.py and see if it helps.

okpail commented 10 years ago

So, sorry for the delay. I am going to close this issue because I solved it! I reinstalled the my whole raspbian system and it works now.

What I think went wrong good be either: I installed OctoPiPrint as root and Octoprint as pi. Or Octoprint not in the Pi home directory but somewhere else. The cue was that I good not use ~/OctoPrint...

So I do not know what then 'breaks'. But now I see in the PI user directory both OctoPrint and the OctoPiPianel dir's.

Maybe make it al little test by checking where the install dir's are?

Anyway I have to test further now if everything works... I want to Thank you for your effort. And 'see' maybe later in another 'issue'

Kind regards,

Onno

jonaslorander commented 9 years ago

Great that it worked out!

If you look ast the insyall instruction you see a cd ~ in the beginning. This is there to make sure it is installed in the home directory of the user.

Also you should never login as root user, it's not necessary. Login as pi user and use sudo when root is needed.

guysoft commented 9 years ago

@okpail Why not use OctoPi? No need to install OctoPrint and get the wrong permissions :)