4

Here's the scenario: I've written a gui using the python framework Kivy, and I want to run it on a raspberry pi with this touchscreen. I've done the installation fine, and TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen FRAMEBUFFER=/dev/fb1 nohup startx & gets the xwindow desktop gui running fine. I've been unable to get my kivy gui working, though. I was able to get a test tkinter application working ok, by setting the DISPLAY environment variable.

I tried putting the following at the top of my kivy app, but to no avail:

os.environ['SDL_VIDEODRIVER'] = 'fbcon'
os.environ['SDL_FBDEV'] = '/dev/fb1'
os.environ['SDL_MOUSEDRV'] = 'TSLIB'
os.environ['SDL_MOUSEDEV'] = '/dev/input/touchscreen'

When I run my application, this is the debug output:

[INFO   ] [Logger      ] Record log in /home/pi/.kivy/logs/kivy_14-04-21_10.txt
[INFO   ] Kivy v1.8.1-dev
[INFO   ] [Python      ] v2.7.3 (default, Mar 18 2014, 05:13:23) 
[GCC 4.6.3]
[INFO   ] [Factory     ] 157 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_pygame, img_gif (img_pil ignored)
[INFO   ] [Text        ] Provider: pygame
[INFO   ] [Loader      ] using a thread pool of 2 workers
[INFO   ] [Window      ] Provider: egl_rpi
[INFO   ] [GL          ] OpenGL version <OpenGL ES 2.0>
[INFO   ] [GL          ] OpenGL vendor <Broadcom>
[INFO   ] [GL          ] OpenGL renderer <VideoCore IV HW>
[INFO   ] [GL          ] OpenGL parsed version: 2, 0
[INFO   ] [GL          ] Shading version <OpenGL ES GLSL ES 1.00>
[INFO   ] [GL          ] Texture max size <2048>
[INFO   ] [GL          ] Texture max units <8>
[INFO   ] [Shader      ] fragment shader: <Compiled>
[INFO   ] [Shader      ] vertex shader: <Compiled>
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [GL          ] NPOT texture support is available
[INFO   ] [OSC         ] using <multiprocessing> for socket
[INFO   ] [ProbeSysfs  ] device match: /dev/input/event0
[INFO   ] [HIDInput    ] Read event from </dev/input/event0>
[INFO   ] [Base        ] Start application main loop
[INFO   ] [HIDMotionEvent] using <stmpe-ts>

I don't know much (anything) about framebuffers and such; I'm hoping someone can point me in the right direction. It appears that the above environment variables I mentioned are useful for getting pygame applications to show up, and kivy is built on pygame.

Some links:

  • This is something I'm trying right now, in case both DISPLAY and a FBDEV need to be set. I'm also going to check and see if I have directfb or fbcon actually installed.
  • The relevant kivy google group issue
  • A fork I may try

I've had a hard time finding anything directly on this much later than April of last year.

Any help would be greatly appreciated. Thanks in advance!

jstaab
  • 3,449
  • 1
  • 27
  • 40
  • Kivy support for RPi is incomplete, but the basics do work. I am able to run the examples on my RPi - the window just draws on top of everything else, the mouse cursor does not show (but clicks work), and keyboard input doesn't work (so I have to Alt-Tab to my terminal, then press Ctrl-C to kill the app). – kitti Apr 23 '14 at 17:40
  • 1
    Are you running raspbian? And are you up to date (sudo apt-get update && sudo apt-get dist-upgrade)? BTW - you don't need to set any of those SDL environment variables, they will be ignored anyway. Kivy uses the VideoCore EGL library on RPi. – kitti Apr 23 '14 at 17:44
  • I am on raspbian, and I'm up to date, running kivy-dev v1.8.1. Thanks for the illumination on the SDL stuff. I messed with using different window providers in the kivy source, but they all errored out worse. The window provider that seems best (and is default) is egl_rpi. I don't get any errors with the default configuration, the window just fails to show up. – jstaab Apr 24 '14 at 01:44

2 Answers2

3

This will not works. SPI screen works on SPI which is controlled by your CPU: http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus

Kivy use the GPU of the Raspberry Pi, not the SPI or X11. As my understanding, displaying an accelerated GLES application on SPI will not work.

Ie, you could confirm this behavior by executing any GLES software from command line outside X11

tito
  • 12,990
  • 1
  • 55
  • 75
  • Super helpful answer, thanks. I'll test that no GLES works on Friday, when I get into the office again. In the meantime, I was wondering if you could recommend an alternative to kivy for making a gui on the pi? I've looked in to pygame and tkinter. Both are clunky, but would work. Tkinter was easy to get started, so I may just bite the bullet and go with that. We do need the library to be pretty much unrestricted, so LGPL3 or MIT or BSD licenses would be best. Thanks again, this was a very illuminating answer. – jstaab Apr 24 '14 at 02:06
  • After thinking about this a bit, do you think it would be possible to dump accelerated graphics to a framebuffer (say, /dev/fb1) somehow? This touchscreen has video working. Not sure if that's related. I apologize for my ignorance - just getting started with all this. – jstaab Apr 24 '14 at 02:17
  • 1
    I've not enough technical knowledge to tell you if it's feasible or not. As for doing an UI on the Rpi without GLES, any standard toolkit will do the job (tkinter, qt, gtk, etc.) If it's a game, pygame might be a better/standard choice. Again, this is just from my understanding of SPI, i'm waiting you for the confirmation :) – tito Apr 24 '14 at 10:28
  • 1
    I found this [Raspberry Pi UI development for GSOC 2014](https://groups.google.com/forum/#!topic/open-lighting/aDNLYWrcteI) helpful though still have issue with touch. Basically it's using [`fbcp`](https://github.com/tasanakorn/rpi-fbcp) to dump from `/dev/fb0` to `/dev/fb1` – faulty Jun 16 '14 at 03:26
0

I found this to work by uncommenting the following line in /boot/config.txt

disable_overscan=1

then starting fbcp

fbcp &

and the running for example the showcase demo (I compile it for kivy for python3.4):

python3.4 kivy/examples/demo/showcase/main.py

kivy running on SPI display

Touch works, except that my y-axis is inverted.

sonium
  • 918
  • 1
  • 11
  • 25