#Experiments with X

<abstract>
In this page we are collecting our first experiments with the graphical 
environment X.org
</abstract>

## Test the framebuffer

To simply test the framebuffer before install anything try this command:

	sudo sh -c "cat /dev/urandom > /dev/fb0"

You should see a random pattern of colors on the display. 

##Installation of X.org

To install X.org on your Acme board simply type:

	sudo apt update
	sudo apt -y install xorg

Now you can run it from the DPI port or a SSH session by typing:

	FRAMEBUFFER=/dev/fb0 startx &

The console prompt on the display will change and the mouse point will
appear. If you connect an USB port and a mouse you can proceede like a
small Linux PC (without the windows manager).

I don't suggest to install any windows manager like KDE or GNOME because
you don't have enough power to manage it and the user experience is the 
poor.

The first thind to do during the test is to disable the screen saver
by typing:

<pre class="minicom">
~# <b>DISPLAY=":0" xset s off</b>
</pre>

Now lets try some simple program just to see something on the scree.

A simple calculator:

<pre class="minicom">
~# <b>DISPLAY=":0" xcalc</b>
~# <b>xeyes</b>
</pre>

Type __CTRL-C__ to exit.

Now plug a mouse and try:

<pre class="minicom">
~# <b>DISPLAY=":0" xeyes</b>
</pre>

Type __CTRL-C__ to exit.

If you want to kill X type:

<pre class="minicom">
~# <b>pkill X</b>
</pre>

##Screen rotation

Create the file <b>/etc/X11/xorg.conf</b> with this content:

<pre class="minicom">
Section "Device"
    Identifier     "Frame Buffer"
    Driver         "fbdev"
    Option         "fbdev"     "/dev/fb0"
    Option         "Rotate"    "CW"
EndSection
</pre>

or 

<pre class="minicom">
    Option         "Rotate"    "CCW"
</pre>

then restart X

##Keyboard configuration

If you are using a Keyboard plugged in one of the board USB probably
you need to set the keyboard layout. To do that type:

<pre class="minicom">
~# <b>dpkg-reconfigure keyboard-configuration</b>
~# <b>invoke-rc.d keyboard-setup start</b>
</pre>

Another way is:

<pre class="minicom">
~# <b>setxbmap -layout it</b>
</pre>

##Touch screen calibration

If you are using a Debian Wheezy download <b>xinput-calibrator</b> from the Debian Sid repository
and install in in that way:

<pre class="minicom">
~# <b>wget http://ftp.lt.debian.org/debian/pool/main/x/xinput-calibrator/xinput-calibrator_0.7.5+git20140201-1_armhf.deb</b>
~# <b>dpkg -i xinput-calibrator_0.7.5+git20140201-1_armhf.deb</b>
</pre>

If you are using Debian Jessy install with apt-get:

<pre class="minicom">
~# <b>apt-get update</b>
~# <b>apt-get install xinput-calibrator</b>
</pre>

Run it:

4.3 inch LCD display:

<pre class="minicom">
~# <b>DISPLAY=":0" xinput_calibrator --geometry 480x272</b>
</pre>

5 or 7 LCD display:

<pre class="minicom">
~# <b>DISPLAY=":0" xinput_calibrator --geometry 800x480</b>
</pre>


##Create a photo frame

Create a directory for your photos:

<pre class="minicom">
~# <b>mkdir myphoto</b>
~# <b>cd myphoto</b>
</pre>

and save on it these sample images:

###800x480 images for 5 and 7 inch display:

<pre class="minicom">
~/myphoto# <b>wget http://terzo.acmesystems.it/download/images-800x480.tar.gz</b>
~/myphoto# <b>tar -xvzf images-800x480.tar.gz</b>
</pre>

###480x272 images for 4.3 inch display:

<pre class="minicom">
~/myphoto# <b>wget http://terzo.acmesystems.it/download/images-480x272.tar.gz</b>
~/myphoto# <b>tar -xvzf images-480x272.tar.gz</b>
</pre>

Run the photo gallery using mplayer:

<pre class="minicom">
~/myphoto# <b>mplayer mf://*.jpg -mf fps=0.1 -loop 0</b>
</pre>

##Play a movie

Install __Mplayer__ from the Debian repository:

<pre class="minicom">
~# <b>apt-get install mplayer</b>
</pre>

##Play with the Doom Arcade game

Install __Chocolate Doom__ from the Debian repository:

<pre class="minicom">
~# <b>apt-get install chocolate-doom</b>
</pre>

plug an USB PC keyboard and launch it:

<pre class="minicom">
~# <b>DISPLAY=":0" /usr/games/chocolate-doom -width 320 -height 240</b>
</pre>

* [Chocolate Doom WiKi](http://www.chocolate-doom.org/wiki/index.php/Command_line_arguments)

## Disable the blank screen

<pre class="minicom">
export DISPLAY=:0.0
xset s off
xset s noblank
xset -dpms
</pre>

## View images without X

<pre class="minicom">
~# <b>apt-get install fbi</b>
</pre>

<pre class="minicom">
~# <b>fbi -T 1 -noverbose photo.jpg</b>
</pre>

## Framebuffer info

The /sys virtual filesystem contains all information about a framebuffer 
device in /sys/class/graphics/<devicename>.

In order to get the size, use

<pre class="minicom">
cat /sys/class/graphics/fb0/virtual_size
</pre>