Moode Audio on Raspberry Pi with SainSmart 7inch Touch-Screen LCD

Tutorial on how to configure Moode for the SainSmart 7inch Touch-Screen LCD Screen

Posted on July 27, 2015 by @MaurizioDimonte

After our short tutorials on how to tweak a Raspbian distribution in order to use a Raspberry Pi with a resistive HDMI LCD Touch Screen, here we are again with a new modest proposal on how to customize two well-known Debian based music players: Volumio and Moode Audio. Our purpose is to turn Raspberry Pi and Touch Screen into a more complete and integrated audiophile system, gifted with a graphical webui environment. Moode Audio Player exploits a much more lightweight and minimalistic configuration compared to Volumio, so the work ahead with it will be a little bit harder. Let's start with Moode anyway.

Moode Audio

I have used a old Raspberry Pi Model B and a 7inch SainSmart LCD Touch Screen (TS from now on), but it is likely that the guide will prove to be good enough for others RPI models and TS devices (perhaps with a few changes).


  • 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
  • 1 x 8Gb microSD card (with adapter for the RPI Model B)

First of all, you need to download and uncompress the latest Moode version from the official website (former Flash your SD card via dd command (in a Linux environment) or something like a Win32DiskImager application (in Windows). Put the SD card in the RPI slot, connect the RPI with the TS through the HDMI cable and power both devices with proper voltage and current (5v DC 500mA for the RPI) and wait a while until the prompt appears on your monitor console (the screen have to be in HDMI mode). If you have an USB keyboard, plug it in the RPI in order to login into the Debian system and launch the appropriate commands. If you don't have a USB keyboard, you'll have to find out your RPI's IP local address through your router or some other devices within your LAN (e.g. using some application programs for network analysis, like Fing). Once the IP address has been obtained, you can use a SSH client (like PuTTY, in Windows) to remotely access and control the system. Log into it with username root and password moode.

Then, if you want, change the password for root with the command:

sudo passwd root

and enter twice the password you like.

After updated the system with the command

sudo apt-get update

Remember not to make any upgrade. This customized system doesn't like strong changes and after the first reboot it may seize up. Open the /boot/config.txt configuration file with a text editor (the default text editor in Debian is nano)

sudo nano /boot/config.txt

and paste into it the following lines (the framebuffer values should be 800x400 but these ones are measured on the browser's web page you have to open later)

hdmi_cvt=800 480 60 6 0 0 0

Save the changes made (Ctrl + O) and exit (Ctrl + X).

Well, since Moode modded distro is devoid of all the software needed for a graphical environment, you have to enlarge the SD partition in order to install the many packages required for a TS web interface. Probably, with another distro, the easiest thing to do would be to run

sudo raspi-config

and select the menu option 'Expand Filesystem'. Unfortunately, in our case, the answer would be: "Your partition layout is not currently supported by this tool. You are probably using NOOBS, in which case your root filesystem is already expanded anyway". Be careful, the root filesystem is NOT already expanded! So you need to find another solution. This is mine. Check the partition size with

sudo df -h

The output:

Filesystem      Size  Used Avail Use% Mounted on
rootfs          1.5G  1.1G  367M  75% /
/dev/root       1.5G  1.1G  367M  75% /
devtmpfs        238M     0  238M   0% /dev
tmpfs            49M  504K   48M   2% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            97M     0   97M   0% /run/shm
/dev/mmcblk0p1   75M   21M   54M  28% /boot

You have already used 75% of your 1.5G

After the command

sudo fdisk /dev/mmcblk0

being the output "Command (m for help): ", type and enter the following letters:

  • p: check the partitions
  • d: (delete your Linux partition)
  • 3: (your Linux partition is no. 3 - mmcblkp3)
  • n: (make a new Linux partition)
  • p: (like 'primary' partition)
  • 3: (your new Linux partition is still no. 3 - mmcblkp3) (enter twice, leaving the default start/end values)
  • w: (save changes and exit the FDISK)

then run

sudo reboot

After the rebooting, if you check again the partition size (with sudo df -h) you will see that nothing is changed, but now you can run

sudo resize2fs /dev/mmcblk0p3

resize partition no. 3 --wait for the resize

sudo e2fsck -f /dev/mmcblk0p3

(ignore errors)

If you run sudo df -h once again, this time you will see you're using 4% of 29G

Filesystem      Size  Used Avail Use% Mounted on
rootfs           29G  1.1G   27G   4% /
/dev/root        29G  1.1G   27G   4% /
devtmpfs        238M     0  238M   0% /dev
tmpfs            49M  504K   48M   2% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            97M     0   97M   0% /run/shm
/dev/mmcblk0p1   75M   21M   54M  28% /boot

Because Moode distro lacks even the /home/pi directory, you must create it along with its .Xauthority file, making sure giving them the appropriate permissions and a password for the user pi:

sudo mkdir -p /home/pi
sudo touch /home/pi/.Xauthority
sudo chmod -R 775 /home/pi
sudo passwd pi

enter twice the password you like

Now, you can install the following packages:

sudo apt-get install xorg xserver-xorg xserver-xorg-core xinit libx11-dev libxext-dev libxi-dev x11proto-input-dev xinput evtest autoconf -y

Remember to reconfigure the Xwrapper.config file in order to allow all users to start the X server. Try first this:

sudo dpkg-reconfigure x11-common

Select Anybody from the graphical menu. Another way to make the same thing is to paste the permission string allowed-users=anybody in the file with

sudo sed -i \

and then

's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config

At this stage, in order to enable the touch screen function you need install and configure few other packages (one of which is not included in the official repositories):

sudo apt-get install xinput-calibrator -y
sudo apt-get install g++ -y
sudo apt-get install wget -y
sudo tar xvf xinput_calibrator-0.7.5.tar.gz
cd xinput_calibrator-0.7.5/
sudo ./configure
sudo make
sudo make install

After that, run the commands:

su pi

You will see a black window with a blinking cursor at the center. Probably The touch-function will work upside down, but you may fix this problem by calibrating the monitor. Open another terminal via SSH and, after the login, run these strings:

    su pi
    DISPLAY=:0.0 xinput_calibrator

Now, press with a pen or click with a mouse on each of the 4 corners in the active area (on the red crosses). 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"

Make your calibration permanent by creating a xorg.conf.d directory (if there isn't one) and two files in which to paste the above section (the values may be different).

    sudo mkdir -p /etc/X11/xorg.conf.d/
    sudo chmod -R 775 /etc/X11/xorg.conf.d/
    sudo nano /etc/X11/xorg.conf.d/99-calibration.conf

and enter:

Section "InputClass"
    Identifier      "calibration"
    MatchProduct    "eGalax Inc. USB TouchController"
    Option  "Calibration"   "0 2042 -5 2051"

Save (Ctrl + O), exit (Ctrl + X) and run

Do the same thing with the 01-input.conf file:

sudo nano /usr/share/X11/xorg.conf.d/01-input.conf

and enter:

Section "InputClass"
    Identifier      "calibration"
    MatchProduct    "eGalax Inc. USB TouchController"
    Option  "Calibration"   "0 2042 -5 2051"

Save (Ctrl + O), exit (Ctrl + X) and

Now, it's time to select two other raspi-config menu options: Enable SPI and Enable boot to desktop option. Before that, you need to install a display manager:

sudo apt-get install lightdm -y (q to quit)
sudo raspi-config

> Advanced Option > A5 SPI Enable/Disable automatic loading > Yes > Ok
> Enable Boot to Desktop > Desktop Log as user 'pi' at the graphical desktop > Ok
> Finish
> Would you like to reboot now? > Yes

After the reboot, you will see the same black window with the blinking cursor, but this time the touch function will work properly (I hope). Let's proceed with the last important step: the web browser installation. In my opinion, Debian distros work fine with the firefox based browser iceweasel.

sudo apt-get install iceweasel -y

In Moode minimalist distro we haven't a Lightweight X11 Desktop Environment (LXDE), so we haven't even an autostart file (like /etc/xdg/lxsession/LXDE-pi/autostart) in which to paste the command

@iceweasel -private -fullscreen -url

Therefore, if we wish that the graphical interface starts as the system boots, we have to operate in a different way. Be careful! A lxde installation, as well as a gnome-shell or a build-essential installation, will be fatal for the integrity of Moode customized system.

Much like Volumio, Moode web UI allows you to set up the MPD server, configure the audio output and choose the digital analog converter (DAC) from a long list of compatible devices (if you have one). Before this, we have to make few other changes. Above all, we have to add some lines in the xinitrc file:

sudo nano /etc/X11/xinit/xinitrc

Just below the line # global xinitrc file, used by all X sessions started by xinit (startx), paste the following string

exec iceweasel -fullscreen -url http://localhost

Save (Ctrl + O), exit (Ctrl + X) and copy the iceweasel.desktop file in the /etc/xdg/autostart/ directory with the command:

sudo cp /usr/share/applications/iceweasel.desktop /etc/xdg/autostart/

Open the /etc/rc.local file

sudo nano /etc/rc.local

and paste the following lines just before the last command exit 0:

su -l root -c startx &
su pi &
export DISPLAY=:0.0

Save (Ctrl + O), exit (Ctrl + X) and reboot:

sudo reboot

When the web page appears, probably the Option Menu button to the upper right will not work, so, if you want a 'fullscreen' kiosk-mode displaying, you have to install some extension like xul-ext-fullscreen and unclutter (which will hide your mouse after few seconds of inactivity):

sudo apt-get install xul-ext-fullscreen -y
sudo apt-get install unclutter -y

If you have an USB mouse plugged in the RPI (this might be a little problem with the old model B, which has only two USB ports), flag the Add this Installation message to allow the full-screen add-on, click on Continue and then on Restart Iceweasel. After the restart, you'll have your Moode Web UI page. Due to the screen I have used, colours and resolution are not the best I've seen so far, but this is another issue.