Enable X windows on PiScreen

Enable X windows on PiScreen

There are two things that need to be done before we can use X on PiScreen.

  1. Remove the hard coding to /dev/fb0 in one of the framebuffer driver config  file
  2. Calibrate the touchscreen for X.

We will install a xinput_calibrator and a script to load the calibration data each time X starts.

The first time you run X, you will be presented with a calibration screen. This will only run once, and you will be asked to touch the touchscreen a few times.

The calibration program will create a file which stores the calibration data( /etc/pointercal.xinput.)

To perform calibration again, just delete /etc/pointercal.xinput and restart X. You will be presented again with the calibration program once X starts.

1. Disable framebuffer driver option for /dev/fb0
Open up the framebuffer conf file;

pi@raspberrypi ~ $ sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.conf

Comment out the line of text below;
Option "fbdev" "/dev/fb0"
This can be done by adding a hash (#) at the beginning of line.
#Option "fbdev" "/dev/fb0"

If the above file is empty, copy in the text below;

Section "Device"
        Identifier      "PiSCreen"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb1"

2. Install all the prerequisites required for calibration

pi@raspberrypi ~ $ sudo apt-get install libtool libx11-dev xinput autoconf libx11-dev libxi-dev x11proto-input-dev -y

3. Download and install xinput_calibrator

pi@raspberrypi ~ $ git clone https://github.com/tias/xinput_calibrator
pi@raspberrypi ~ $ cd xinput_calibrator/
pi@raspberrypi ~ $ ./autogen.sh
pi@raspberrypi ~ $ make
pi@raspberrypi ~ $ sudo make install

4. Download and setup the calibration script

pi@raspberrypi ~ $ cd ~
pi@raspberrypi ~ $ wget https://ozzmaker.com/piscreen/xinput_calibrator_pointercal.sh
pi@raspberrypi ~ $ sudo cp ~/xinput_calibrator_pointercal.sh /etc/X11/Xsession.d/xinput_calibrator_pointercal.sh
pi@raspberrypi ~ $ sudo chmod +x /etc/X11/Xsession.d/xinput_calibrator_pointercal.sh

We now want the script to run everytime X starts. This can be done by opening X autostart ;

pi@raspberrypi ~ $ nano /home/pi/.config/lxsession/LXDE-pi/autostart

Add the text below to the bottom of the file;

sudo /bin/sh /etc/X11/Xsession.d/xinput_calibrator_pointercal.sh

5. Reboot

With the latest Raspbian Jessie images, X is configured to start automatically on boot.

pi@raspberrypi ~ $ sudo reboot

Disable Screen Blanking

By default, X will blank out the screen after 10 minutes of no activity. Once you start using it again, the display will come back on.
If you want to disable this or increase the timeout, you will need to create a small script to disable power saving and disable screensaver which then gets loaded when X starts.


Disable X blanking
1. Install X server utilities, they will most likely already be installed.

pi@raspberrypi ~ $ sudo apt-get install x11-xserver-utils

2. Create a small script which is used to change the screen saver settings.

pi@raspberrypi ~ $ sudo nano /etc/X11/Xsession.d/disableblank.sh

3. Add these three lines.

xset s off      # don't activate screensaver
xset -dpms      # disable DPMS (Energy Star) features.
xset s noblank  # don't blank the video device

4. Change the permissions on the file.

pi@raspberrypi ~ $sudo chmod +x /etc/X11/Xsession.d/disableblank.sh

5. Force the file to run when X starts

pi@raspberrypi ~ $sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

Or /etc/xdg/lxsession/LXDE/autostart on older version of Raspbian

And add this line to the bottom;



Blip, blop, bloop…