Raspberry PI, Raspbian, XBMC and eGalax 7 inch touchscreen

Hello!

I have spent some time lately trying to find a solution to get my 7 inch eGalax touchscreen to work with  Raspbian(Debian Wheezy) in XBMC 12 Frodo and finally got it working as I wanted.

My Setup
  • Raspberry PI model B: ~30$
  • 7 inch display with touchscreen for car rear view camera, from eBay(touchscreen is connected to one USB port): 80$
  • HDMI male to HDMI male connector(from eBay): <2$
  • 4GB SDHC class 4 card
  • 12V(500mA) AC to DC adapter for powering the display
  • 5V(1A) microUSB AC to DC converter for powering the PI
  • USB keyboard


Edit:  I have uploaded my image with XBMC 12 build with eGalax touchscreen support(download it from here, with md5sum c59330154143d9e5e43217322bbd92ce). It seems that you need to request permission and I will give you access. The account is pi and password: a.

Here is what you need to do in order to have a system with Raspberry PI, Raspbian OS and XBMC 12 Frodo stable with eGalax touchscreen working correctly(which means axes calibrated and click working with just one tap&release action):


1. Get latest Raspbian image from here and flash it to an SD card.

2. Build your own kernel with eGalax touchscreen support, like in this post(you will only need to replace kernel.img file and /lib/modules and /lib/firmware folders on the SD card).

3. Build XBMC 12 on Raspberry PI using this tutorial.
Note: After downloading XBMC archive, get this archive and unpack it anywhere.
Apply patches to xbmc files:
cd <patches_folder>
patch -p1 <path_to_xbmc>/xbmc/input/linux/LinuxInputDevices.cpp < LinuxInputDevices_cpp.patch
patch -p1 <path_to_xbmc>/xbmc/input/MouseStat.cpp < MouseStat_cpp.patch
patch -p1 <path_to_xbmc>/xbmc/input/MouseStat.h < MouseStat_h.patch
4. Touchscreen calibration.
Copy the eGalaxCalibration folder from the archive(downloaded above) to /usr/share/ on Raspberry PI. Here, you should have the file touchscreen_axes_calib. It contains four values for the axes calibration and one value for swapping axes.
The simplest way to swap axes is to switch the four wires cable plug's orientation which comes from the touchscreen to the touch controller.

Here is how the calibration was done.

the original behavior(no calibration)

In the picture above, we see that "touch panel values frame" differs from "touch panel physical size frame". When we are pressing the touch we are moving in the "touch panel physical size frame" but when the touch screen is not calibrated the arrow from XBMC is in another place.
  • "touch panel physical size frame" is the screen starting from (0,0) on the left top corner and going to (width, height) in the right bottom corner.
  • "touch panel values frame" is the frame which contains all the number the touch controller is giving.
We see that these frames differs a lot. Our main scope is to overlap the "touch panel values frame" to the "touch panel physical size frame".

In order to do this we need to do three steps(the third one is done in software):
a. Scale the value read from the touch driver x and y) in order to fit 0->width range and respectively 0->height range of the "touch panel physical size frame" the scale value for x axis is:
                       "touch panel physical size frame" width
calib_x_fact = -------------------------------------------------
                            "touch panel values frame" width


                       "touch panel physical size frame" height
calib_y_fact = -------------------------------------------------
                            "touch panel values frame" height

"touch panel values frame" width and height are coming from your XBMC resolution(I have width=1280 and height=720).
"touch panel physical size frame" width and height are a little more trickier to find but nothing hard. In step 2 above, you have calibrated the touchscreen in XFCE. You got some values returned by xinput_calibrator, something like:
Section "InputClass"
    Identifier   "calibration"
    MatchProduct    "eGalax Inc. USB TouchController"
    Option    "Calibration"    "1977 32 1893 131"
EndSection
In my case,
"touch panel physical size frame" width is 1977 - 32 = 1945
"touch panel physical size frame" height is 1893 - 131 = 1762
Now, compute the values and put them in /usr/share/eGalaxCalibration/touchscreen_axes_calib file

b. Translate the "touch panel values frame" to the left and up, to match "touch panel physical size frame".
I didn't find a logical method to do this, because we don't know exactly "where is" the "touch panel values frame", so, in order to find calib_x_d and calib_y_d you have to first set them both to zero and then start XBMC. Now, put some sharp pointer on the screen and observe the distances between the cursor on the screen and your pointer's position. Try to approximate these x and y deviations(measured in pixels) and put them in the /usr/share/eGalaxCalibration/touchscreen_axes_calib file.

c. Revert direction of axes. This is done in the software(from patches).

5. Math behind.
To accomplish these transformations the following formula was implemented in the file
xbmc/input/linux/LinuxInputDevices.cpp
pointer.x = screen_width - value_read.x * calib_x_fact - calib_x_d;
pointer.y = screen_height - value_read.y * calib_y_fact - calib_y_d;

After I have successfully calibrated the touchscreen I have discovered that single click was not possible from the touchscreen, just double click. After digging through the code, I have found that this was caused by drag action which was triggered because the previous values of the touch were far(more than 5 pixels) from a new press. For example, at the start of the program, cursor is set at 0,0 coordinates; if user is trying to press a button, let's say at 100, 300, the program(XBMC) will calculate the distance between these two points and will find out that this is greater than 5.
Pythagorean theory:
(100-0)x(100-0) + (300 - 0)x(300-0) is greater than 5x5 XBMC will treat this as a drag event.
This drag issue is not caused when you double click, because the previous point in the second click action is very close to the second click point. This also works for mouses, because the previous value of the pointer is always very close to the new value of the pointer(because mouse's pointer drags on the screen and it doesn't jump - so each new value is very close to the previous one).

I have developed an algorithm to avoid this issue:
When the user is pressing the screen(x,y), the touch values are being set to (screen_width+1, screen_height+1 -> outside of the visible screen) just at the first event read(which is BTN_TOUCH PRESS).
After this event, the program will receive multiple X and Y absolute values events. The first two events, one for X and one for Y are used to set the previous X value, respectively previous Y value to the current X respective current Y values. And from now on distance is measured and this is preventing no unwanted drag action.
The user's finger/pointer will not stay at a single point, because the touchscreen's lack of precision, so it will move around 5-6 pixels in x and y directions.
I have also set the click distance to 7. You can change this by changing click_confines value in xbmc/input/MouseStat.h. Originally it was set to 5, but this is not very good for touch screens(I had to click with a sharp pointer and with my nail always, but with a value of 7 I can click with my finger with a slight touch -> really nice).

Enjoy!

Build XBMC Frodo from source in Raspbian on Raspberry PI

Hi!

After struggling couple of days in finding the best way to build XBMC on Raspberry PI I have finally got a working solution(haven't discovered how I can cross-compile it, which would be the best choice).
This takes about 15 hours, on my Raspberry PI model B, but the good news is that 'make' takes about 12 hours, so you don't need to watch it, just come from time to time to see if it is working. Besides the build messages displayed on screen you have the whole logs for rbp_depends, configure, make and make install steps. If anything goes wrong you can investigate these files(the last one reached) and search for the first error
log_1_rbp_depends.log
log_2_configure.log
log_3_make.log
log_4_make_install.log
This tutorial is for Linux Host Machine but it can be easily adapted to any other OS.
Let's get this started!

1. Get the latest Raspbian Wheezy image from http://www.raspberrypi.org/downloads and put it on an SD card:
You have couple of possibilities to do this. In Linux you can use:
sudo dd bs=1M if=raspbian_wheezy_image_path of=/dev/sd_card_path
2. Get XBMC 12 source code from http://xbmc.org/download/. On the Source Code section, download the zip file from where it says: "Stable release sources are available here".
If you get the code from git it will probably get an unstable version, which is the latest code. When I have build from source I have got XBMC 13 alpha 1 which worked, but no addon was working.
Transfer xbmc folder to your /home/pi/ directory or wherever you like.
Now you can plug the card in Raspberry PI and follow the next steps.

Note. The easiest way to do this is via ssh(first, enable it using sudo raspi-config menu), from a computer. Just connect in Terminal using:
ssh pi@x.x.x.x
where x.x.x.x is the ip address of your device. You can get the ip address by typing ifconfig. Then you just copy/paste the commands into Terminal.

3. Set minimum amount of video memory and create a swap partition:
sudo raspi-config
Here you should expand_rootfs, disable overscan, configure_keyboard, change_pass, change_timezone and enable ssh. Select memory_split and enter 16 then restart.
Now, to create a swap partition, use the following:
dd if=/dev/zero of=/home/pi/swapfile1 bs=1024 count=204800
sudo mkswap /home/pi/swapfile1
sudo chown root:root /home/pi/swapfile1
sudo chmod 0600 /home/pi/swapfile1
sudo swapon /home/pi/swapfile1
The swap file is needed as extra memory for the compiler. This will prevent you from getting errors like:
gcc: internal compiler error: Killed (program cc1)

4. Update the system and install some dependencies:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install autotools-dev comerr-dev dpkg-dev libalsaplayer-dev libapt-pkg-dev:armhf libasound2-dev libass-dev:armhf libatk1.0-dev libavahi-client-dev libavahi-common-dev libavcodec-dev libavformat-dev libavutil-dev libbison-dev:armhf libbluray-dev:armhf libboost1.49-dev \
    libbz2-dev:armhf libc-dev-bin libc6-dev:armhf libcaca-dev libcairo2-dev libcdio-dev libclalsadrv-dev libcrypto++-dev libcups2-dev libcurl3-gnutls-dev \
    libdbus-1-dev libdbus-glib-1-dev libdirectfb-dev libdrm-dev libegl1-mesa-dev libelf-dev libenca-dev libept-dev libevent-dev libexpat1-dev libflac-dev:armhf \
    libfontconfig1-dev libfreetype6-dev libfribidi-dev libgconf2-dev libgcrypt11-dev libgdk-pixbuf2.0-dev libgl1-mesa-dev libgles2-mesa-dev \
    libglew-dev:armhf libglewmx-dev:armhf libglib2.0-dev libglu1-mesa-dev libgnome-keyring-dev libgnutls-dev libgpg-error-dev libgtk2.0-dev libhal-dev \
    libhunspell-dev:armhf libice-dev:armhf libicu-dev libidn11-dev libiso9660-dev libjasper-dev libjbig-dev:armhf libjconv-dev libjpeg8-dev:armhf libkrb5-dev \
    libldap2-dev:armhf libltdl-dev:armhf liblzo2-dev libmad0-dev libmicrohttpd-dev libmodplug-dev libmp3lame-dev:armhf libmpeg2-4-dev libmysqlclient-dev \
    libncurses5-dev libnspr4-dev libnss3-dev libogg-dev:armhf libopenal-dev:armhf libp11-kit-dev libpam0g-dev:armhf libpango1.0-dev libpcre++-dev libpcre3-dev \
    libpixman-1-dev libpng12-dev libprotobuf-dev libpthread-stubs0-dev:armhf libpulse-dev:armhf librtmp-dev libsamplerate0-dev:armhf \
    libsdl-image1.2-dev:armhf libsdl1.2-dev libslang2-dev:armhf libsm-dev:armhf libsmbclient-dev:armhf libspeex-dev:armhf \
    libsqlite3-dev libssh-dev libssh2-1-dev libssl-dev libstdc++6-4.6-dev libtagcoll2-dev libtasn1-3-dev libtiff4-dev libtinfo-dev:armhf libtinyxml-dev \
    libts-dev:armhf libudev-dev libv8-dev libva-dev:armhf libvdpau-dev:armhf libvorbis-dev:armhf libvpx-dev:armhf libwebp-dev:armhf libwibble-dev \
    libx11-dev:armhf libx11-xcb-dev libxapian-dev libxau-dev:armhf libxcb-glx0-dev:armhf libxcb-render0-dev:armhf libxcb-shm0-dev:armhf \
    libxcb1-dev:armhf libxcomposite-dev libxcursor-dev:armhf libxdamage-dev libxdmcp-dev:armhf libxext-dev:armhf libxfixes-dev libxft-dev libxi-dev \
    libxinerama-dev:armhf libxml2-dev:armhf libxmu-dev:armhf libxrandr-dev libxrender-dev:armhf libxslt1-dev libxss-dev:armhf libxt-dev:armhf \
    libxtst-dev:armhf libxxf86vm-dev libyajl-dev libzip-dev linux-libc-dev:armhf lzma-dev mesa-common-dev python-dev python2.7-dev x11proto-composite-dev \
    x11proto-core-dev x11proto-damage-dev x11proto-dri2-dev x11proto-fixes-dev x11proto-gl-dev x11proto-input-dev x11proto-kb-dev x11proto-randr-dev \
    x11proto-record-dev x11proto-render-dev x11proto-scrnsaver-dev x11proto-xext-dev x11proto-xf86vidmode-dev x11proto-xinerama-dev xtrans-dev \
    libnfs-dev libplist-dev avahi-daemon zlib1g-dev:armhf swig java-package libafpclient-dev liblockdev1-dev autoconf automake libtool gcc udev openjdk-6-jre \
    cmake g++ libudev-dev build-essential autoconf ccache gawk gperf mesa-utils zip unzip curl
This will take some time depending on your internet speed.

5. Copy libraries headers and create some symlinks for libraries:
sudo cp -R /opt/vc/include/* /usr/include
sudo cp /opt/vc/include/interface/vcos/pthreads/* /usr/include/interface/vcos
sudo ln -fs /opt/vc/lib/libEGL.so /usr/lib/libEGL.so
sudo ln -fs /opt/vc/lib/libEGL.so /usr/lib/arm-linux-gnueabihf/libEGL.so
sudo ln -fs /opt/vc/lib/libEGL.so /usr/lib/arm-linux-gnueabihf/libEGL.so.1
sudo ln -fs /opt/vc/lib/libEGL_static.a /usr/lib/libEGL_static.a
sudo ln -fs /opt/vc/lib/libEGL_static.a /usr/lib/arm-linux-gnueabihf/libEGL_static.a
sudo ln -fs /opt/vc/lib/libGLESv2.so /usr/lib/libGLESv2.so
sudo ln -fs /opt/vc/lib/libGLESv2.so /usr/lib/arm-linux-gnueabihf/libGLESv2.so
sudo ln -fs /opt/vc/lib/libGLESv2.so /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2
sudo ln -fs /opt/vc/lib/libGLESv2_static.a /usr/lib/libGLESv2_static.a
sudo ln -fs /opt/vc/lib/libGLESv2_static.a /usr/lib/arm-linux-gnueabihf/libGLESv2_static.a
sudo ln -fs /opt/vc/lib/libbcm_host.so /usr/lib/libbcm_host.so
sudo ln -fs /opt/vc/lib/libbcm_host.so /usr/lib/arm-linux-gnueabihf/libbcm_host.so
sudo ln -fs /opt/vc/lib/libvchiq_arm.a /usr/lib/libvchiq_arm.a
sudo ln -fs /opt/vc/lib/libvchiq_arm.a /usr/lib/arm-linux-gnueabihf/libvchiq_arm.a
sudo ln -fs /opt/vc/lib/libvchiq_arm.so /usr/lib/libvchiq_arm.so
sudo ln -fs /opt/vc/lib/libvchiq_arm.so /usr/lib/arm-linux-gnueabihf/libvchiq_arm.so
sudo ln -fs /opt/vc/lib/libvcos.a /usr/lib/libvcos.a
sudo ln -fs /opt/vc/lib/libvcos.a /usr/lib/arm-linux-gnueabihf/libvcos.a
sudo ln -fs /opt/vc/lib/libvcos.so /usr/lib/libvcos.so
sudo ln -fs /opt/vc/lib/libvcos.so /usr/lib/arm-linux-gnueabihf/libvcos.so
There is a problem when compiling, with the file /usr/include/interface/vmcs_host/vcgencmd.h which includes the wrong vchost_config.h, so I have created a command to put the right inclusion:
sudo sed -i 's/#include "vchost_config.h"/#include "linux\/vchost_config.h"/' /usr/include/interface/vmcs_host/vcgencmd.h
6. Install taglib, libcec and libshairport.
cd <pah_to_xbmc_dir>
make -C lib/taglib
sudo make -C lib/taglib install
cd <any_directory>
git clone --depth 5 https://github.com/Pulse-Eight/libcec.git
cd libcec
./bootstrap
./configure --prefix=/usr/local
make
sudo make install
cd <path_to_xbmc_dir>
make -C lib/libshairport
sudo make -C lib/libshairport install
7. Configure and compile XBMC
cd <path_to_xbmc_dir>
export TARGET_SUBARCH="armv6zk"
export TARGET_CPU="arm1176jzf-s"
export TARGET_FLOAT="hard"
export TARGET_FPU="vfp"
export TARGET_FPU_FLAGS="-mfloat-abi=$TARGET_FLOAT -mfpu=$TARGET_FPU"
export TARGET_EXTRA_FLAGS="-Wno-psabi -Wa,-mno-warn-deprecated"
export TARGET_COPT="-Wall -pipe -fomit-frame-pointer -O3 -fexcess-precision=fast -ffast-math  -fgnu89-inline"
export TARGET_LOPT="-s -Wl,--as-needed"
export CFLAGS="-march=$TARGET_SUBARCH -mcpu=$TARGET_CPU $TARGET_FPU_FLAGS -mabi=aapcs-linux $TARGET_COPT $TARGET_EXTRA_FLAGS"
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-march=$TARGET_SUBARCH -mtune=$TARGET_CPU $TARGET_LOPT"
Fix some errors:
sed -i 's/USE_BUILDROOT=1/USE_BUILDROOT=0/' tools/rbp/setup-sdk.sh
sed -i 's/TOOLCHAIN=\/usr\/local\/bcm-gcc/TOOLCHAIN=\/usr/' tools/rbp/setup-sdk.sh
Run:
sudo sh tools/rbp/setup-sdk.sh
Fix other errors:
sed -i 's/cd $(SOURCE); $(CONFIGURE)/#cd $(SOURCE); $(CONFIGURE)/' tools/rbp/depends/xbmc/Makefile
Run:
make -C tools/rbp/depends/xbmc/ 2>&1 | tee log_1_rbp_depends.log
Configure:
./configure --prefix=/usr/local --build=arm-linux-gnueabihf \
            --host=arm-linux-gnueabihf --localstatedir=/var/lib \
            --with-platform=raspberry-pi --disable-gl --enable-gles \
            --disable-x11 --disable-sdl --enable-ccache --enable-optimizations \
            --disable-external-libraries --disable-goom --disable-hal \
            --disable-pulse --disable-vaapi --disable-vdpau --disable-xrandr \
            --enable-airplay --disable-alsa --enable-avahi --enable-libbluray \
            --enable-dvdcss --disable-debug --disable-joystick --disable-mid \
            --enable-nfs --disable-profiling --disable-projectm --enable-rsxs \
            --enable-rtmp --disable-vaapi --disable-vdadecoder \
            --disable-external-ffmpeg --enable-optical-drive \
            --enable-player=omxplayer 2>&1 | tee log_2_configure.log
After configuration completes, please run he following command:
sed -i 's/ifeq (1,1)/ifeq (0,1)/' tools/TexturePacker/Makefile
Compile(this will take about 12 hours):
make 2>&1 | tee log_3_make.log
8. Install XBMC 12 in Raspbian.
sudo make install 2>&1 | tee log_4_make_install.log
After this step you have to run raspi-config again and to set video memory to 128 and then restart. Now you should be able to run XBMC using
/usr/local/lib/xbmc/xbmc.bin
Note: If you are running via xbmc command, or from XFCE menu->Multimedia->XBMC it will not start. The same command can be used to run XBMC from terminal or from XFCE interface.
In addition you can also install PVR Addons and XVDR addon(but this is not necessary):
cd <any_directory>
git clone --depth 5 git://github.com/opdenkamp/xbmc-pvr-addons.git
cd xbmc-pvr-addons/
./bootstrap
./configure --prefix=/usr/local --enable-addons-with-dependencies
sudo make install
cd <any_directory>
git clone git://github.com/pipelka/xbmc-addon-xvdr.git
cd xbmc-addon-xvdr
sh autogen.sh
./configure --prefix=/usr/local
sudo make install
Note
If you want to modify sources after the compilation is completed, you just have to modify them and then run make again, which will build only the affected parts(couple of minutes), but remember to keep the video memory at maximum 32MB when you are building, and also keep the swap partition.

Many thanks to:
  • XBIAN forums 
  • http://www.raspbian.org/RaspbianXBMC (mpthompson)

Head Unit Kenwood DDX-4033

Head Unit Kenwood Kenwood kembali mengeluarkan line up terbaru head
unit nya Kenwood DDX-4033, dengan berbagai fitur tambahan yang
melengkapi seri sebelumnya membuat head unit ini semakin canggih dan
mampu memutar hampir semua jenis format multimedia yang ada saat ini.
Pada Versi DDX-4033BT terdapat fungsi miror link ready yang berfungsi
untuk mereplika aplikasi yang terdapat pada

Overcome stall car due flooding


Overcome stall car due flooding - maybe at europe rain is not sme with in asia, for big rain can make the land due in flooding, and the higway / road are fulfill with the water. that is big problem for our cars, because our car can be stalled and that is not good for the engine. or we must find other car insurance quote again, just for avoid to overcome stall car .Like this season, It should be

Overcome strikes Car


How to Overcome strikes Car ?

There was Not every driver is a mechanic/ can repair their own car. may be we need cheap auto insurance , The problem is : Strikes car certainly make us very upset. Moreover, if the car broke down at times when things were rough or we are in a hurry. Indeed, the car broke down was not need to happen if you diligently take care of your car engine well. But sometimes

Overcome Stall Car


How to Overcome Overcome Stall Car / Car Crash . a situation that annoying us in the way, how about that happend in the mignight or important momment, to be sure you never feel one of the most unpleasant incident that had experienced a driver's car that is breaking down. Genesis is certainly very annoying, especially when you're pressed for time to get to somewhere soon.

Whatever the brand of

Paket Audio Mobil Gramond Alpha Series

Paket Audio Mobil Gramond Alpha Series Paket audio mobil Gramond Car
Audio perpaduan antara speaker Gramond Alpha 6c dan Power Amplifier
Alpha 1 serta subwoofer S-10 ini sangat cocok untuk anda yang
menggemari aliran SQL. Tingkat kedetilan dan kejernihan suara yang
dihasilkan mampu memuskan telinga anda dengan harga terjangkau.
Spesifikasi : Power Amplifier 4 Channel Gramond Alpha

Power Amplifier 4 Channel Rockford PBR300x4

Power Amplifier 4 Channel Rockford PBR300x4 The PBR300X4 is a
full-range 4-channel amplifier designed for stereo front/rear systems
that requires little space. The BRT (Boosted Rail Technology) is an
ultra efficient design that generates 300 Watts of power! The BRT also
has a variable hi-level DC offset turn-on circuit for easy installation
into any OEM system. Great for motorcycles and

SUBWOOFER SBACOUSTICS SB29SWNRX-S75 10 Inch

SB29WNRX-S75 10' Subwoofer SB Acoustics SB29SWNRX-S75-6 SubWoofer is
specially designed by SB Acoustics as a Ferrite magnet 10" 6ohm
subwoofer, featuring a proprietary composition coated paper cone, and a
4 layer 3" voice coil and shorting ring. Very open cast frame for
minimal reflections. Fs 20Hz, a good solid performer. SB Acoustics
SB29SWNRX-S75 Features : Hard paper cone

Hati-Hati dengan Blog themastersound.blogspot.com Blog Penipu

Blog the master sound palsu / diduga untuk menipu Kemudahan membuat
blog di blogspot.com ternyata disalah gunakan oleh orang yang tidak
bertangung jawab untuk melakukan penipuan, salah satu blog yang diduga
digunakan untuk menipu ini adalah themastesound.blogspot.com. dengan
keterangan didalam blog yang menyatakan pemilik adalah HJ. Hartanto dan
marketing dengan nama Adi Wijaya. Blog ini