sneakypete
Posts: 2
Joined: Sun Mar 31, 2013 3:44 pm

TSLib + DirectFB

Sun Mar 31, 2013 3:57 pm

Hi All,

I'm struggling to get my 8" Lilliput to work in PyGame via directFB. Any help or pointers would be much appreciated! Note that I'm not using X here at all, just accessing the framebuffer directly.

Thanks to the great work by Bernie at Plugable, the display works fine - I just needed to:
  • Recompile the kernel with the udlfb module enabled.
  • Obtain the mode settings using "fbset --info -fb /dev/fb2", and append them to /etc/fb.modes
  • Create ~/.directfbrc with the following contents:

Code: Select all

  fbdev=/dev/fb1
  no-vt
  no-vt-switch
  mode=800x600-60
  depth=16
Unfortunately the touchscreen is a bit problematic. The x/y axes are swapped, so touches on the right edge of the screen appear as touches on the bottom edge and vice versa. Also, the first "MOUSEDOWN" event at a particular location is erroneous - it takes a second tap to get the correct position recognised.

After a bit of Googling, it seems that TSLib might be a good solution to this. Using ts_calibrate from the stock raspbian libts-bin, I get the following error as directFB initialises:

Code: Select all

    selected device is not a touchscreen I understand
This is apparently because the eGalaxy touchscreen isn't yet supported in the released TSLib. But there is an eGalaxy patch availalbe, so I compiled the latest patched tslib from git://github.com/Vodalys/tslib.git, and modified /usr/local/etc/ts.conf like so:

Code: Select all

  # Comment out the following:
  # module_raw input

  # Add the following
  module_raw galax
Now ts_calibrate and ts_test work flawlessly. When using ts_test, the axis mapping is correct and "first touches" are registered correctly. Great!

The final hurdle is to get TSLib working with directFB. I set the following environment:

Code: Select all

  export LD_LIBRARY_PATH=/usr/local/lib
  export TSLIB_CONSOLEDEVICE=none
  export TSLIB_FBDEVICE=/dev/fb1
  export TSLIB_TSDEVICE=/dev/input/event1
  export TSLIB_CALIBFILE=/home/pi/pointercal
  export TSLIB_CONFFILE=/usr/local/etc/ts.conf
  export TSLIB_PLUGINDIR=/usr/local/lib/ts
I then attempt to use PyGame to initialise directFB as follows:

Code: Select all

  os.putenv("SDL_VIDEODRIVER", "directfb")
  pygame.display.init()
This produces:

Code: Select all

      ~~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.2.10 |~~~~~~~~~~~~~~~~~~~~~~~~~~
        (c) 2001-2008  The world wide DirectFB Open Source Community
        (c) 2000-2004  Convergence (integrated media) GmbH
      ----------------------------------------------------------------

  (*) DirectFB/Core: Single Application Core. (2012-06-01 00:48) 
  (!) DirectFB/Keyboard: Could not open() /dev/tty0!
      --> Permission denied
  (*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...
  (*) DirectFB/Input: eGalax Inc. USB TouchController (1) 0.1 (directfb.org)
  (*) Direct/Thread: Started 'Linux Input' (-1) [INPUT OTHER/OTHER 0/0] <8388608>...
  (*) DirectFB/Input: C-Media USB Headphone Set   (2) 0.1 (directfb.org)
  (!) [ 2258:    0.000] --> Caught signal 11 (at 0x42428210, invalid permissions) <--
  Aborted
The signal 11 is presumably from tslib, since I don't see it if I disable tslib in ~/.directfbrc with "tslib-devices=none".

Permissions on /dev/input are:

Code: Select all

  $ ls -l /dev/input/event*
    crw-rw---T 1 root input 13, 64 Jan  1  1970 /dev/input/event0
    crw-rw---T 1 root input 13, 65 Jan  1  1970 /dev/input/event1
    crw-rw---T 1 root input 13, 66 Jan  1  1970 /dev/input/event2
And my user groups:

Code: Select all

  $ groups
    pi adm dialout cdrom sudo audio video plugdev games users netdev input
I also tried running as root, with the same result.

Any idea what I can do to fix this problem?

sneakypete
Posts: 2
Joined: Sun Mar 31, 2013 3:44 pm

Re: TSLib + DirectFB

Sun Apr 14, 2013 8:43 pm

It turns out that I had a library conflict, since I'd neglected to uninstall the stock raspbian TSLIB before compiling a new one.

For the record, the following steps produced a working TSLib with galax support:

Compile TSLib with the galax patch:

Code: Select all

sudo apt-get install git automake libtool
cd ~/src
git clone git://github.com/kergoth/tslib.git
cd tslib
git pull git://github.com/Vodalys/tslib.git
./autogen.sh
./configure
make
sudo make install
Add the following to /usr/local/etc/ts.conf (ensuring all over module_raw lines are commented out)

Code: Select all

  # Uncomment if you're using an eGalaxy
  module_raw galax
Replace installed libts with the newly compiled one (if someone has a more elegant way of doing this, I'm all ears!)

Code: Select all

sudo mkdir /usr/lib/arm-linux-gnueabihf/libts-disabled
sudo mv /usr/lib/arm-linux-gnueabihf/libts* /usr/lib/arm-linux-gnueabihf/libts-disabled
cd /usr/local/lib
sudo ln -s libts-1.0.so.0 libts-0.0.so.0
Calibrate

Code: Select all

export LD_LIBRARY_PATH=/usr/local/lib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb1
export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_CALIBFILE=/home/pi/pointercal
export TSLIB_CONFFILE=/usr/local/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/local/lib/ts
ts_calibrate
ts_test
That's it! You'll need to adjust the exports above depending on your exact configuration.

Hope this helps someone.
Pete

Return to “Other projects”