For my test I use a Raspberry Pi 2 and a 7inch SainSmart LCD Touch Screen (TS from now on), but with a few changes it is likely that the procedure will work with others RPI models and TS devices (certainly with the slower old RPI Model B).
Components:
- 1 x Raspberry Pi (any version) with power supply and internet connection
- 1 x compatible HDMI Touch Screen with power supply (in my case a 12v DC Resistive AT070TN92 Screen)
- 1 x HDMI cable for the connection between RPI and TS
- 1 x 8Gb microSD card (with adapter for the RPI Model B)
Starting steps:
- Download and unzip the latest Raspian version from the official web-page
- Flash your SD card via dd command in Linux environment or Win32DiskImager in Windows.
- Connect the RPI and the screen through the HDMI cable.
- Power first the RPI and then the screen with proper supplies (5v DC 500mA for the RPI and 12v DC for SainSmart TS)
When the prompt appears on your HDMI screen, login into the Raspian system with username: pi
and password: raspberry
In order to access your device from a remote host (inside your local network), you can use the ssh
service:
ssh pi@your_raspberry_ip_address
password: raspberry
After that, open the /boot/config.txt
file with
sudo nano /boot/config.txt
and paste into it the following lines:
framebuffer_width=600
framebuffer_height=300
hdmi_force_hotplug=1
hdmi_cvt=800 480 60 6 0 0 0
hdmi_group=2
hdmi_mode=87
According to my screen specs the framebuffer values should be different (800x400) but these ones are for the browser’s web page we need to open later.
Save the changes made Ctrl + O and exit Ctrl + X.
sudo apt-get update & sudo apt get upgrade
Wait until the long upgrade is completed and then run the raspi-config
script in order to make some change from its graphical menu (e.g. you can resize the main partition to fill your SD card, enable the boot to desktop, or the automatic loading of SPI kernel module):
sudo raspi-config
In raspi-config
:
- "Expand Filesystem"
- "Enable Boot to Desktop/Scratch"
- "Avanced Option > "A6 SPI" "SPI ENABLE/DISABLE AUTOMATIC LOADING"
- select "Finish" and press Enter
Next update the Raspberry PI firmware:
sudo rpi-update
Then, we can go ahead with the installation of the following packages for the touch functionality:
apt-get install libx11-dev libxext-dev libxi-dev x11proto-input-dev xinput evtest -y
wget http://github.com/downloads/tias/xinput_calibrator/xinput_calibrator-0.7.5.tar.gz
tar xvf xinput_calibrator-0.7.5.tar.gz
cd xinput_calibrator-0.7.5/
sudo ./configure
sudo make
sudo make install
reboot
After the reboot start the xserver
and set the DISPLAY
variable:
su pi
FRAMEBUFFER=/dev/fb1 su -l pi -c startx &
export DISPLAY=:0.0
The touch-function will work upside down, but you can fix this problem running the calibration script:
su pi
DISPLAY=:0.0 xinput_calibrator
You will see a grey active area. Press with a pen (or click with a mouse) on each of the 4 red crosses at the corners of the screen. The terminal will give you an answer like this:
--> Making the calibration permanent
copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf'
Section "InputClass"
Identifier "calibration"
MatchProduct "eGalax Inc. USB TouchController"
Option "Calibration" "0 2042 -5 2051"
EndSection
To make the calibration preferences permanent, you need create a xorg.conf.d
directory (if there isn't already one) and a 01-input.conf
file in which to paste the above values (obviously, your values may be different from mine).
sudo mkdir -p /etc/X11/xorg.conf.d/
sudo chmod -R 775 /etc/X11/xorg.conf.d/
sudo nano /usr/share/X11/xorg.conf.d/01-input.conf
Paste the lines in the 01-input.conf
file:
Section "InputClass"
Identifier "calibration"
MatchProduct "eGalax Inc. USB TouchController"
Option "Calibration" "0 2042 -5 2051"
EndSection
Save Ctrl + O and exit Ctrl + X.
Before rebooting, open the /etc/rc.local
with
sudo nano /etc/rc.local
you need to paste into it the following commands (right above the "exit 0
" line):
su -l root-c startx &
su pi &
export DISPLAY=:0.0
Save Ctrl + O, exit Ctrl + X and reboot:
sudo reboot
After the restart, the system will boot on the desktop and the axis inversion problem will be solved.
Now we need to install an internet browser (I've used iceweasel
) and configure the LXDE
autostart file so that our desired Volumio's WebUI appears at startup in kiosk mode (fullscreen, with the mouse pointer hidden).
sudo apt-get install iceweasel unclutter -y
Open the autostart file with
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
and make sure that it contains the following (commented and uncommented) lines:
#@xscreensaver -no-splash
@xset s off #disable screensaver
@xset -dpm
@xset s noblank #disable screensaver blaking
@unclutter -idle 0 #disable mouse pointing
@iceweasel -private -fullscreen -url http://localhost
Save Ctrl + O, exit Ctrl + X and reboot
If there is any problem with the black screensaver, you can try to change a line in the lightdm.conf
file ([SeatDefaults]
section):
sudo nano /etc/lightdm/lightdm.conf
xserver-command=X -s 0 dpms :0
Save Ctrl + O, exit Ctrl + X and reboot again. If the restart speed is too slow for your liking, you can remove some programs like minecraft or wolfram
sudo apt-get remove --purge minecraft-pi -y
sudo apt-get remove --purge wolfram-engine -y
The next important step is the installation of Music Player Daemon (MPD), with all its dependencies:
sudo apt-get install alsa-utils mpd mpc minidlna usbmount ntfs-3g -y
At the end of the process the output will say:
[....] Starting Music Player Daemon: mpdlisten: bind to '[::1]:6600' failed: Failed to create socket: Address family not supported by protocol (continuing anyway, because binding to '127.0.0.1:6600' succeeded)
Failed to load database: Failed to open database file "/var/lib/mpd/tag_cache": No such file or directory
You may fix this unimportant problem by opening the mpd.conf file with
sudo nano /etc/mpd.conf
and commenting with a # the line
bind_to_address "localhost"
Save Ctrl + O, exit Ctrl + X and restart mpd
with
service mpd restart
Then, install further required packages:
sudo apt-get install nginx sqlite3 php5 php5-fpm php5-curl php5-sqlite php5-cli php5-gd php5-imagick -y
sudo apt-get install samba samba-common-bin -y
sudo apt-get install ntfs-3g minidlna autofs -y
Open the /etc/auto.master
file with
sudo nano /etc/auto.master
and add the following line at the end:
/media/ /etc/auto.ext-usb --timeout=10,defaults,user,exec,uid=1000
Save Ctrl + O and exit Ctrl + X.
At this point, you have to create few directories and links (like these) for our external music drives. In this case we have two disks:
sudo mkdir /var/www
sudo mkdir /mnt/disk1
sudo mkdir /mnt/disk2
sudo mkdir -p /mnt/NAS
sudo mkdir -p /mnt/USB
sudo ln -s /mnt/NAS /var/lib/mpd/music/NAS
sudo ln -s /mnt/USB /var/lib/mpd/music/USB
In order to know the details of these disks you may run
sudo fdisk -l
Assuming that disk1
is fat32 formatted and has /dev/sda2
number (where a2
means the second partition on the first drive) while the disk2
is NTFS formatted and has /dev/sda3
number, you have to open the /etc/fstab
file with
sudo nano /etc/fstab
and add these lines to the existent list
/dev/sda2 /mnt/disk1 vfat defaults 0 0
/dev/sda3 /mnt/disk2 nfts defaults 0 0
This will mount the sda2 disk in the /mnt/disk1
directory and the sda3 disk in the /mnt/disk2
directory.
Now we need to clone Volumio WebUI from git
(an useful tutorial on how to do that is here: http://typingoutloud.org/raspberry-pi-installing-volumio-pibang/:
git clone https://github.com/volumio/Volumio-WebUI.git /var/www
Then, give permissions and copy the required files in the system root
chmod 775 /var/www/_OS_SETTINGS/etc/rc.local
chmod 755 /var/www/_OS_SETTINGS/etc/php5/mods-available/apc.ini
chmod -R 777 /var/www/command/
chmod -R 777 /var/www/db/
chmod -R 777 /var/www/inc/
cp -var /var/www/_OS_SETTINGS/etc /
Add symbolic links for NAS and USB and reboot
cd /var/lib/mpd/music ; ln -s /mnt/disk1/Music
ln -s /mnt/NAS /var/lib/mpd/music/NAS
ln -s /mnt/USB /var/lib/mpd/music/USB
sudo reboot
After rebooting the browser should show-up on the screen showing the Volumio web interface.