The time now is Wed 22 May 2013, 15:19
All times are UTC - 4 |
| Author |
Message |
geoff.l
Joined: 28 Feb 2008 Posts: 11
|
Posted: Fri 04 Apr 2008, 01:20 Post subject:
howto: get a LG L1730SF touchscreen working on puppy |
|
Some time back I built a little silent puppy box to act as a sort of kiosk device with the only real application being a web browser. The main requirements were
- silent (no fans or HDD)
- wireless LAN
- no KB/mouse, just a touchscreen
- bulletproof (or at lease boot-hang proof ... so it will come up clean from a power failure)
I had lots of grief with both the wireless and the touchscreen along the way, and picked up lots of tips from these forums, so in the spirit of giving something back I thought I'd describe how I eventually got the touchscreen sorted out. It does now work perfectly for me!
Screen = LG 17" L1730SF touchscreen
Motherboard = D201GLY2
First attempt was with puppy 3.01, I never got this to work, so fell back to 2.17.
Starting with a clean install of 2.17 and selecting xorg as opposed to xvesa the first problem is that puppy's supplied driver for the SIS display adapter is rubbish, especially at high resolutions it leaves stripes and marks all over the screen. So if you happen to have the same motherboard or display adapter then you might want to ...
(1) Replace the video driver (this works for puppy 3.01 too)
Video driver is:
/usr/X11R7/lib/xorg/modules/drivers/sis_drv.so
I first got a new one from intel website but couldn't get this to work at all.
Found a good one at http://cs.haifa.ac.il/~skiselev/
Just copy the new driver file over the top of the old one .
Ctrl-Alt-Backspace and rerun xorgwizard (this builds a new xorg.conf file to suit new driver)
Run xwin
Now all should look lovely!
(2) Install the touchscreen driver package
Find and install package: evtouch-usbtouchscreen-k2.6.21.5.pet
Load the 2 modules
modprobe usbtouchscreen
modprobe evdev
(3) Restart xserver
Ctrl-Alt-Bksp then xwin
Now the screen should be sensitive to finger (albeit uncalibrated and the mouse pointer will fly around all over the place). Moving your finger around you'll see that the X/Y axes are reversed.
(4) Make sure that the modules load at every boot up,
edit /etc/rc.d/rc.local and add these lines -
modprobe usbtouchscreen
modprobe evdev
(5) Get a some data to build a first cut xorg.conf
cat /proc/bus/input/devices
look for the touchscreen device, in my case it shows keyboard (event0), real-mouse (event1) and touchscreen (event2)
then look at the handler line, it should be something like
H: Handlers=mouse1 event2
The number (in this case event2) is important. A problem (fixed later) is that the numbers change depending on what KB/mouse devices happen to be plugged in at boot time.
Puppy already contains the necessary device nodes for four events, they are in
/dev/input/event0
/dev/input/event1
etc
But if we have a lot of devices plugged in we might need more than this so add a few more up to event 6 (which seems to be the highest I’ve seen)
mknod /dev/input/event4 c 13 68
mknod /dev/input/event5 c 13 69
mknod /dev/input/event6 c 13 70
(6) Build an first-cut xorg.conf
Create a backup of original puppy-built xorg.conf (I called it xorg0.conf)
Edit /etc/X11/xorg.conf
Add a new InputDevice section (check the event2 number in the "Device" statement)
# device definition for touch LG L1750SF touchscreen in "landscape" layout
# note "rotate" statement interchanges X/Y co-ordinates
# note SwapY statement reverses the direction for Y coordinate
# before xinit
Section "InputDevice"
Identifier "touchscreen0"
Driver "evtouch"
Option "DeviceName" "touchscreen"
Option "Device" "/dev/input/event2"
Option "SwapX" "false" ## default false
Option "SwapY" "true"
Option "Rotate" "CW" ## CW or CCW
Option "MinX" "200"
Option "MaxX" "3850"
Option "MinY" "180"
Option "MaxY" "3980"
Option "ReportingMode" "Raw"
Option "SendCoreEvents" "On"
Option "TapTimer" "300" # default 200ms
Option "LongTouchTimer" "4000" # default 400ms
Option "Emulate3Buttons" "false" # default true
Option "Emulate3Timeout" "50" # default 50ms
Option "MoveLimit" "30" # default 30 pixels
#maybetapped/longtouch actions: click, down, up
#maybetapped/longtouch buttons: 1(left), 2(middle),3(right)
Option "maybetapped_action" "click" # default click
Option "maybetapped_button" "1" # default 1 (left)
Option "longtouch_action" "up" # default down
Option "longtouch_button" "2" # default 1 (left)
EndSection
And in Section "ServerLayout" add the line:
InputDevice "touchscreen0" "SendCoreEvents"
Set up like this BOTH the touchscreen and the real mouse will be working. This is okay for now but eventually we need to tidy this up because there are lots of strange conflicts which show up as "double clicks" and other odd effects if both the touchscreen and the real mouse are defined.
If you want to do this in "portrait" mode then play with the Swap/Rotate options.
(7) Restart X
(Ctrl-Alt-Bksp) then xwin .
But DO NOT change the keyboard / mouse setup. Plugging or unplugging will change the event numbers and may break xserver completely!
( Calibrate
With luck calibration will not now be an issue since the numbers above work fine for me. But your setup might be different, or you might be trying this with a different monitor.
To do this I used a fine stylus. If things are working right touch the stylus to the screen and the mouse pointer should jump to exactly the right spot. I found that fiddling with MinX MaxX etc I could set this very precisely and quite easily.
The TapTimer, LongTouchTimer etc lines above are described at http://www.conan.de/touchscreen/evtouch.html
In my case I only wanted to emulate a left click event since my only application was a web browser. I've changed some from the defaults. This works for me but you might want to do other things to get middle/right button emulations happening.
(9) Create another xorg.conf file with any real mice disabled and touchscreen active
Save xorg.conf somewhere in case you break it...
edit xorg.conf to get rid of the real mice. Change the touchscreen to be the corepointer:
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "touchscreen0" "CorePointer"
EndSection
Section "InputDevice"
Identifier "touchscreen0"
Driver "evtouch"
Option "DeviceName" "touchscreen"
Option "Device" "/dev/input/event2"
Option "SwapX" "false" ## default false
Option "SwapY" "true"
Option "Rotate" "CW" ## CW or CCW
Option "MinX" "200"
Option "MaxX" "3850"
Option "MinY" "180"
Option "MaxY" "3980"
Option "ReportingMode" "Raw"
Option "SendCoreEvents" "On"
Option "TapTimer" "300" # default 200ms
Option "LongTouchTimer" "4000" # default 400ms
Option "Emulate3Buttons" "false" # default true
Option "Emulate3Timeout" "50" # default 50ms
Option "MoveLimit" "30" # default 30 pixels
#maybetapped/longtouch actions: click, down, up
#maybetapped/longtouch buttons: 1(left), 2(middle),3(right)
Option "maybetapped_action" "click" # default click
Option "maybetapped_button" "1" # default 1 (left)
Option "longtouch_action" "up" # default down
Option "longtouch_button" "2" # default 1 (left)
EndSection
If you boot with this file then you have to have the touchscreen active or x will complain that it has no corepointer.
(10)Fix it so that it can cope with varying device attachments
Unfortunately "event2" used above is problematic. Depending on what KB/mice are plugged in, or whether the touchscreen is powered on at the key times, this number can change.
To fix this problem, and also to solve the issue of having both the real mouse and the touchscreen interacting with each other the best solution I could come up with was as follows. I'm sure there are other ways ... but this worked for me.
I set up multiple xorg.conf files.
/etc/X11/xorg.conf
is the one that xwin uses by default. It is also the one that gets overwritten whenever we run the xorgwizard.
This is one should be used if the touch screen is NOT plugged in or powered on ( this was saved earlier as xorg0.conf)
/etc/X11/xorg0.conf
is a backup of xorg.conf [the original un-corrupted]
/etc/X11/xorg1.conf
is created by hand. it is the touchscreen only file created in step (9) but with the the line below changed:
change Option "Device" "/dev/input/event2"
to: Option "Device" "/dev/input/@@@TOUCH_EVENT@@@"
this file does not actually get used by xwin but instead, I create a script which is run at the time xwin is started and which edits xorg1.conf to create xorg2.conf changing the @@@TOUCH_EVENT@@@ flag into the correct event number along the way.
/etc.X11/xorg2.conf
is automatically created by the script and this is the file to be used when the touchscreen is active.
(11) Create a script in /root/touch-setup as follows:
(okay so I'm new to this scripting and to sed, so there are probably no points for elegance here)
#!/bin/sh
# tests to see if the LG touch panel is plugged in and powered on
# then generates a suitable xorg.conf to match
grep -e "Touch Panel" -e "event" /proc/bus/input/devices > /tmp/event1
grep -n ":" /tmp/event1 > /tmp/event2
# does the Touch panel exist ?
EXISTS=`grep "Touch Panel" /tmp/event2 | wc -l`
# if the panel exists what is the event number ?
if [ $EXISTS = 1 ]
then
# the line number for the Touch statement
TOUCH=`grep "Touch" /tmp/event2 | cut -c 1`
# the next line is the one we want
LINE=`expr $TOUCH + 1`
# add a colon so we know what we're looking for
LINE=$LINE":"
# we want the 3rd field in the identified line
EVENT=`grep $LINE /tmp/event2 | cut -d " " -f 3`
else
EVENT="mice"
fi
## now we mess around with the xorg.conf files
# xorg.conf is the "real" file as generated by Puppy and xorgwizard
# xorg1.conf is hand crafted based on xorg.conf but with the touch
# screen stuff added
# xorg2.conf is created here by editing xorg1.conf to
# include the correct event device node
sed s/@@@TOUCH_EVENT@@@/$EVENT/ /etc/X11/xorg1.conf > /etc/X11/xorg2.conf
# next output the name of the config file to use
# xwin gets its config file from here
if [ $EXISTS = 1 ]
then
echo "/etc/X11/xorg2.conf"
else
echo "/etc/X11/xorg.conf"
fi
(12) chmod to make sure above it is executable
Then modify the xwin startup script in /usr/X11R7/bin/xwin as follows:
Look just before "finally, start X"
XEXTRAOPTIONS="`cat /etc/xextraoptions`"
fi
############################################################
############################################################
TOUCHCONFIG=`/root/touch_setup`
export XORGCONFIG=$TOUCHCONFIG
echo "xorg config file to be used is = " $XORGCONFIG
sleep 3
############################################################
############################################################
#finally, start X...
#J_Rey had a good idea,
# .....
What this does is set the environment variable XORGCONFIG to point to the correct config file, and xinit, when it starts at the bottom of xwin will use this config file in preference to the default /ect/X11/xorg.conf
(13) Whilst fiddling with xwin now is the time to do this little tweak ...
To prevent xwin startup prompt after power fail
Boot will stop with a console prompt after a “crash” such as a power failure.
To prevent this insert short section in /usr/X11R7/bin/xwin script the line “rm -f /etc/.XLOADED” is added.
Normally if the file exists it means that x was not shut down properly.
# tweak
# delete XLOADED so never stop at this trap
# if really need to reconfigure X then boot with nox and run xorgwizard
rm -f /etc/.XLOADED
#
if [ -f /etc/.XLOADED ];then
if [ "`cat /etc/.XLOADED`" = "true" ];then
#last time X ran, PC hung and had to be rebooted...
echo -en "\\033[1;31m" #34=blue, 33=yellow, 32=green, 31=red, 35=purple, 36=aquablue, 38=black.
echo '
It seems that last time X ran, the computer hung and you had to reboot.
Have now dropped down to the commandline. If you want to run the Xorg
(14) Now test it !
If everything is right xwin should start correctly whatever combination of keyboard / mice are connected. If the touchscreen is connected and powered on when xwin is started then it will be activated and any "real" mice will be disabled.
(15) Fine tuning
Any further tweaks can be done in xorg1.conf. For me I basically had to prevent anything being interpreted as a right click and prevent spurious “doubleclicks”. The best combination I found is shown in the various driver parameters above.
|
|
Back to top
|
|
 |
ScottD
Joined: 04 Jul 2007 Posts: 39
|
Posted: Tue 06 May 2008, 13:33 Post subject:
|
|
Geoff,
Much thanks for the posting, I had got my touchscreen an ELO model working but was changing the values by hand which was error prone at the least. This put it all together.
For those using an ELO touchscreen here is my touch_setup and xorg.conf file. I had to tweek a few of Geoff's itmes to get the scripts to work
of course your xorg file will be different depending on what other items you have hooked up to your pc... and your calibration vaues for teh touch screen will most likely be different.
touch_setup follows
##########################################
#!/bin/bash
# test to see if the touch panel is plugged in
grep -e "EloTouch" -e "event" /proc/bus/input/devices > /tmp/event1
grep -n ":" /tmp/event1 > /tmp/event2
# does it exist?
EXISTS=`grep "EloTouch" /tmp/event2 | wc -l`
#if the panle exists what is teh event number?
if [ $EXISTS = 1 ]
then
#the line number for the touch statement
TOUCH=`grep "EloTouch" /tmp/event2 | cut -c 1`
#echo $TOUCH
#3rd line after is the one we want
LINE=`expr $TOUCH + 1`
#echo $LINE
# add a colon
LINE=$LINE":"
#we want the 2nd field using "=" as the seperator
EVENT=`grep $LINE /tmp/event2 | cut -d "=" -f 2 | cut -d " " -f 1`
#echo found Elo Touchscreen at /dev/input/$EVENT
else
#no touch screen default to mouse
EVENT="mice"
fi
#modify custom touch screen .conf file
sed s/@@@TOUCH_EVENT@@@/$EVENT/g /etc/X11/xorg.conf.elo > /etc/X11/xorg.elo
#output name of conf file to use
if [ $EXISTS = 1 ]
then
echo "/etc/X11/xorg.elo"
else
echo "/etc/X11/xorg.conf"
fi
###################################
xorg.conf.elo follows
###################################
#Special base config file used in Puppy Linux.
# **********************************************************************
# Module section -- this section is used to specify
# which dynamically loadable modules to load.
# **********************************************************************
#
Section "Module"
# This loads the DBE extension module.
Load "dbe" # Double buffer extension
# This loads the miscellaneous extensions module, and disables
# initialisation of the XFree86-DGA extension within that module.
SubSection "extmod"
Option "omit xfree86-dga" # don't initialise the DGA extension
EndSubSection
# This loads the font modules
Load "type1"
Load "freetype"
# This loads the GLX module
Load "glx"
# This loads xtrap extension, used by xrandr
Load "xtrap"
EndSection
# **********************************************************************
# Files section. This allows default font and rgb paths to be set
# **********************************************************************
Section "Files"
# The location of the RGB database. Note, this is the name of the
# file minus the extension (like ".txt" or ".db"). There is normally
# no need to change the default.
RgbPath "/usr/X11R7/lib/X11/rgb"
# Multiple FontPath entries are allowed (which are concatenated together),
# as well as specifying multiple comma-separated entries in one FontPath
# command (or a combination of both methods)
FontPath "/usr/X11R7/lib/X11/fonts/misc/"
FontPath "/usr/X11R7/lib/X11/fonts/Type1/"
FontPath "/usr/X11R7/lib/X11/fonts/TTF/"
EndSection
# **********************************************************************
# Server flags section.
# **********************************************************************
Section "ServerFlags"
# Uncomment this to disable the <Crtl><Alt><Fn> VT switch sequence
# (where n is 1 through 12). This allows clients to receive these key
# events.
# Option "DontVTSwitch"
# Enables mode switching with xrandr
# There is a report that this can cause Xorg not to work on some
# video hardware, so default is commented-out...
# but i want to use it in xorgwizard so leave on...
Option "RandR" "on"
EndSection
Section "InputDevice"
Identifier "touchscreen"
Driver "evtouch"
Option "Device" "/dev/input/@@@TOUCH_EVENT@@@"
Option "DeviceName" "touchscreen"
Option "MinX" "492"
Option "MinY" "614"
Option "MaxX" "3531"
Option "MaxY" "3504"
Option "ReportingMode" "Raw"
Option "Emulate3Buttons"
Option "Emulate3Timeout" "50"
Option "SendCoreEvents" "On"
Option "SwapY" "1"
# Option "Calibrate" "1"
EndSection
Section "InputDevice"
Identifier "Dummy"
Driver "void"
Option "Device" "/dev/mouse"
EndSection
#everything past here is auto-generated by Puppy's Xorg Wizard...
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
# InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "touchscreen" "CorePointer"
InputDevice "Dummy"
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
Option "XkbRules" "xorg"
Option "XkbModel" "pc102"
Option "XkbLayout" "us" #xkeymap0
EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto" #mouse0protocol
Option "Device" "/dev/mouse"
#Option "Emulate3Buttons"
#Option "Emulate3Timeout" "50"
Option "ZAxisMapping" "4 5" #scrollwheel
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
HorizSync 31-60
VertRefresh 55-71
#UseModes "Modes0" #monitor0usemodes
EndSection
Section "Modes"
Identifier "Modes0"
#modes0modeline0
EndSection
Section "Device"
### Available Driver options are:-
### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
### [arg]: arg optional
#Option "ShadowFB" # [<bool>]
#Option "DefaultRefresh" # [<bool>]
#Option "ModeSetClearScreen" # [<bool>]
Identifier "Card0"
Driver "vesa" #card0driver
VendorName "Unknown Vendor"
BoardName "Unknown Board"
BusID "PCI:1:0:0"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
DefaultDepth 16
Subsection "Display"
Depth 16
Modes "1024x768"
EndSubsection
EndSection
#PuppyHardwareProfile=VIA_P4N800_PROELO0922
##################################
Scott
|
|
Back to top
|
|
 |
Riley6683
Joined: 21 Nov 2007 Posts: 6
|
Posted: Sat 17 May 2008, 22:47 Post subject:
|
|
Thanks! These instructions worked great as is....
|
|
Back to top
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|