Skip to content
notro edited this page Sep 18, 2013 · 42 revisions

People with a github account can edit these pages.
Please help advancing the knowledge on this subject. Add your experience with a particular display under it's own heading.
Remember to add a link to the information source.

Update: ads7846_test is removed. ads7846_device is used instead together with ads7846
It has the same arguments, except for debug which is now verbose.

sudo modprobe ads7846
sudo modprobe ads7846_device (use the same arguments as in the examples, except for debug=>verbose)

touchpanel

xinput and evtest

xinput and evtest is not installed by default

sudo apt-get -y install xinput evtest

ITDB02-2.8

This panel uses the TSC2046 touch controller (supported by ads7846.c).

Using the SPI interface circuit, I have been able to hook up the Touch controller.
This is how I have done initial testing, trying all rotate values:

modprobe fbtft_device name=flexfb gpios=reset:25,dc:24,led:18

modprobe flexfb debug=3 rotate=0 width=240 height=320 regwidth=16 setaddrwin=1 init=-1,0x00E3,0x3008,-1,0x00E7,0x0012,-1,0x00EF,0x1231,-1,0x0001,0x0100,-1,0x0002,0x0700,-1,0x0003,0x1030,-1,0x0004,0x0000,-1,0x0008,0x0207,-1,0x0009,0x0000,-1,0x000A,0x0000,-1,0x000C,0x0000,-1,0x000D,0x0000,-1,0x000F,0x0000,-1,0x0010,0x0000,-1,0x0011,0x0007,-1,0x0012,0x0000,-1,0x0013,0x0000,-2,200,-1,0x0010,0x1690,-1,0x0011,0x0223,-2,50,-1,0x0012,0x000D,-2,50,-1,0x0013,0x1200,-1,0x0029,0x000A,-1,0x002B,0x000C,-2,50,-1,0x0020,0x0000,-1,0x0021,0x0000,-1,0x0030,0x0000,-1,0x0031,0x0506,-1,0x0032,0x0104,-1,0x0035,0x0207,-1,0x0036,0x000F,-1,0x0037,0x0306,-1,0x0038,0x0102,-1,0x0039,0x0707,-1,0x003C,0x0702,-1,0x003D,0x1604,-1,0x0050,0x0000,-1,0x0051,0x00EF,-1,0x0052,0x0000,-1,0x0053,0x013F,-1,0x0060,0xA700,-1,0x0061,0x0001,-1,0x006A,0x0000,-1,0x0080,0x0000,-1,0x0081,0x0000,-1,0x0082,0x0000,-1,0x0083,0x0000,-1,0x0084,0x0000,-1,0x0085,0x0000,-1,0x0090,0x0010,-1,0x0092,0x0600,-1,0x0007,0x0133,-3
modprobe ads7846_test debug=1 cs=1 speed=2000000 model=7846 x_min=230 x_max=3900 y_min=200 y_max=3700 x_plate_ohms=80 pressure_max=255 gpio_pendown=23 keep_vref_on=1
FRAMEBUFFER=/dev/fb1 startx

modprobe flexfb debug=3 rotate=1 width=320 height=240 regwidth=16 setaddrwin=1 init=-1,0x00E3,0x3008,-1,0x00E7,0x0012,-1,0x00EF,0x1231,-1,0x0001,0x0100,-1,0x0002,0x0700,-1,0x0003,0x1028,-1,0x0004,0x0000,-1,0x0008,0x0207,-1,0x0009,0x0000,-1,0x000A,0x0000,-1,0x000C,0x0000,-1,0x000D,0x0000,-1,0x000F,0x0000,-1,0x0010,0x0000,-1,0x0011,0x0007,-1,0x0012,0x0000,-1,0x0013,0x0000,-2,200,-1,0x0010,0x1690,-1,0x0011,0x0223,-2,50,-1,0x0012,0x000D,-2,50,-1,0x0013,0x1200,-1,0x0029,0x000A,-1,0x002B,0x000C,-2,50,-1,0x0020,0x0000,-1,0x0021,0x0000,-1,0x0030,0x0000,-1,0x0031,0x0506,-1,0x0032,0x0104,-1,0x0035,0x0207,-1,0x0036,0x000F,-1,0x0037,0x0306,-1,0x0038,0x0102,-1,0x0039,0x0707,-1,0x003C,0x0702,-1,0x003D,0x1604,-1,0x0050,0x0000,-1,0x0051,0x00EF,-1,0x0052,0x0000,-1,0x0053,0x013F,-1,0x0060,0xA700,-1,0x0061,0x0001,-1,0x006A,0x0000,-1,0x0080,0x0000,-1,0x0081,0x0000,-1,0x0082,0x0000,-1,0x0083,0x0000,-1,0x0084,0x0000,-1,0x0085,0x0000,-1,0x0090,0x0010,-1,0x0092,0x0600,-1,0x0007,0x0133,-3
modprobe ads7846_test swap_xy=1 debug=1 cs=1 speed=2000000 model=7846 x_min=230 x_max=3900 y_min=200 y_max=3700 x_plate_ohms=80 pressure_max=255 gpio_pendown=23 keep_vref_on=1
FRAMEBUFFER=/dev/fb1 startx
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 0 1

modprobe flexfb debug=3 rotate=2 width=240 height=320 regwidth=16 setaddrwin=1 init=-1,0x00E3,0x3008,-1,0x00E7,0x0012,-1,0x00EF,0x1231,-1,0x0001,0x0100,-1,0x0002,0x0700,-1,0x0003,0x1000,-1,0x0004,0x0000,-1,0x0008,0x0207,-1,0x0009,0x0000,-1,0x000A,0x0000,-1,0x000C,0x0000,-1,0x000D,0x0000,-1,0x000F,0x0000,-1,0x0010,0x0000,-1,0x0011,0x0007,-1,0x0012,0x0000,-1,0x0013,0x0000,-2,200,-1,0x0010,0x1690,-1,0x0011,0x0223,-2,50,-1,0x0012,0x000D,-2,50,-1,0x0013,0x1200,-1,0x0029,0x000A,-1,0x002B,0x000C,-2,50,-1,0x0020,0x0000,-1,0x0021,0x0000,-1,0x0030,0x0000,-1,0x0031,0x0506,-1,0x0032,0x0104,-1,0x0035,0x0207,-1,0x0036,0x000F,-1,0x0037,0x0306,-1,0x0038,0x0102,-1,0x0039,0x0707,-1,0x003C,0x0702,-1,0x003D,0x1604,-1,0x0050,0x0000,-1,0x0051,0x00EF,-1,0x0052,0x0000,-1,0x0053,0x013F,-1,0x0060,0xA700,-1,0x0061,0x0001,-1,0x006A,0x0000,-1,0x0080,0x0000,-1,0x0081,0x0000,-1,0x0082,0x0000,-1,0x0083,0x0000,-1,0x0084,0x0000,-1,0x0085,0x0000,-1,0x0090,0x0010,-1,0x0092,0x0600,-1,0x0007,0x0133,-3
modprobe ads7846_test debug=1 cs=1 speed=2000000 model=7846 x_min=230 x_max=3900 y_min=200 y_max=3700 x_plate_ohms=80 pressure_max=255 gpio_pendown=23 keep_vref_on=1
FRAMEBUFFER=/dev/fb1 startx
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 1

modprobe flexfb debug=3 rotate=3 width=320 height=240 regwidth=16 setaddrwin=1 init=-1,0x00E3,0x3008,-1,0x00E7,0x0012,-1,0x00EF,0x1231,-1,0x0001,0x0100,-1,0x0002,0x0700,-1,0x0003,0x1018,-1,0x0004,0x0000,-1,0x0008,0x0207,-1,0x0009,0x0000,-1,0x000A,0x0000,-1,0x000C,0x0000,-1,0x000D,0x0000,-1,0x000F,0x0000,-1,0x0010,0x0000,-1,0x0011,0x0007,-1,0x0012,0x0000,-1,0x0013,0x0000,-2,200,-1,0x0010,0x1690,-1,0x0011,0x0223,-2,50,-1,0x0012,0x000D,-2,50,-1,0x0013,0x1200,-1,0x0029,0x000A,-1,0x002B,0x000C,-2,50,-1,0x0020,0x0000,-1,0x0021,0x0000,-1,0x0030,0x0000,-1,0x0031,0x0506,-1,0x0032,0x0104,-1,0x0035,0x0207,-1,0x0036,0x000F,-1,0x0037,0x0306,-1,0x0038,0x0102,-1,0x0039,0x0707,-1,0x003C,0x0702,-1,0x003D,0x1604,-1,0x0050,0x0000,-1,0x0051,0x00EF,-1,0x0052,0x0000,-1,0x0053,0x013F,-1,0x0060,0xA700,-1,0x0061,0x0001,-1,0x006A,0x0000,-1,0x0080,0x0000,-1,0x0081,0x0000,-1,0x0082,0x0000,-1,0x0083,0x0000,-1,0x0084,0x0000,-1,0x0085,0x0000,-1,0x0090,0x0010,-1,0x0092,0x0600,-1,0x0007,0x0133,-3
modprobe ads7846_test swap_xy=1 debug=1 cs=1 speed=2000000 model=7846 x_min=230 x_max=3900 y_min=200 y_max=3700 x_plate_ohms=80 pressure_max=255 gpio_pendown=23 keep_vref_on=1
FRAMEBUFFER=/dev/fb1 startx
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0

Sainsmart 3.2

These x/y min/max values isn't working very well on my display. The x values changes a lot from top to bottom, as the stylus is moved up and down. The y values behaves more reasonable.
Edit this if you find good values or other info.

modprobe fbtft_device name=sainsmart32spifb


modprobe sainsmart32fb
modprobe ads7846_test debug=1 cs=1 speed=2000000 model=7846 x_min=300 x_max=3800 y_min=700 y_max=3400 x_plate_ohms=60 pressure_max=255 gpio_pendown=23 keep_vref_on=1
FRAMEBUFFER=/dev/fb1 startx
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 0 1

modprobe sainsmart32fb rotate=1
modprobe ads7846_test debug=1 cs=1 speed=2000000 model=7846 swap_xy=1 x_min=300 x_max=3800 y_min=700 y_max=3400 x_plate_ohms=60 pressure_max=255 gpio_pendown=23 keep_vref_on=1
FRAMEBUFFER=/dev/fb1 startx
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 1

modprobe sainsmart32fb rotate=2
modprobe ads7846_test debug=1 cs=1 speed=2000000 model=7846 x_min=300 x_max=3800 y_min=700 y_max=3400 x_plate_ohms=60 pressure_max=255 gpio_pendown=23 keep_vref_on=1
FRAMEBUFFER=/dev/fb1 startx
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0

modprobe sainsmart32fb rotate=3
modprobe ads7846_test debug=1 cs=1 speed=2000000 model=7846 swap_xy=1 x_min=300 x_max=3800 y_min=700 y_max=3400 x_plate_ohms=60 pressure_max=255 gpio_pendown=23 keep_vref_on=1
FRAMEBUFFER=/dev/fb1 startx

Watterott MI0283QT-9A

The LCD speed has to be lowered to 16MHz for the display to work together with the touch controller. The same as lallafa discovered.

modprobe ili9341fb

modprobe fbtft_device name=ili9341fb gpios=reset:25,led:18 rotate=0 speed=16000000
modprobe ads7846_test cs=1 speed=2000000 model=7846 pressure_max=255 x_min=250 x_max=3780 y_min=160 y_max=3930 x_plate_ohms=60 gpio_pendown=17 keep_vref_on=1
FRAMEBUFFER=/dev/fb1 startx

modprobe fbtft_device name=ili9341fb gpios=reset:25,led:18 rotate=1 speed=16000000
modprobe ads7846_test cs=1 speed=2000000 model=7846 swap_xy=1 pressure_max=255 x_min=250 x_max=3780 y_min=160 y_max=3930 x_plate_ohms=60 gpio_pendown=17 keep_vref_on=1
FRAMEBUFFER=/dev/fb1 startx
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 0 1

modprobe fbtft_device name=ili9341fb gpios=reset:25,led:18 rotate=2 speed=16000000
modprobe ads7846_test cs=1 speed=2000000 model=7846 pressure_max=255 x_min=250 x_max=3780 y_min=160 y_max=3930 x_plate_ohms=60 gpio_pendown=17 keep_vref_on=1
FRAMEBUFFER=/dev/fb1 startx
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 1

modprobe fbtft_device name=ili9341fb gpios=reset:25,led:18 rotate=3 speed=16000000
modprobe ads7846_test cs=1 speed=2000000 model=7846 swap_xy=1 pressure_max=255 x_min=250 x_max=3780 y_min=160 y_max=3930 x_plate_ohms=60 gpio_pendown=17 keep_vref_on=1
FRAMEBUFFER=/dev/fb1 startx
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0

HY28A

# Normal
modprobe fbtft_device name=hy28afb rotate=0
modprobe hy28afb
modprobe ads7846_device pressure_max=255 y_min=190 y_max=3850 gpio_pendown=17 x_max=3850 x_min=230 x_plate_ohms=60
modprobe ads7846
FRAMEBUFFER=/dev/fb1 startx

# Rotate Clock Wise
modprobe fbtft_device name=hy28afb rotate=1
modprobe hy28afb
modprobe ads7846_device pressure_max=255 y_min=190 swap_xy=1 y_max=3850 gpio_pendown=17 x_max=3850 x_min=230 x_plate_ohms=60
modprobe ads7846
FRAMEBUFFER=/dev/fb1 startx
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 0 1

# Rotate Upside Down
modprobe fbtft_device name=hy28afb rotate=2
modprobe hy28afb
modprobe ads7846_device pressure_max=255 y_min=190 y_max=3850 gpio_pendown=17 x_max=3850 x_min=230 x_plate_ohms=60
modprobe ads7846
FRAMEBUFFER=/dev/fb1 startx
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 1

# Rotate Counter Clock WIse
modprobe fbtft_device name=hy28afb rotate=3
modprobe hy28afb
modprobe ads7846_device pressure_max=255 y_min=190 swap_xy=1 y_max=3850 gpio_pendown=17 x_max=3850 x_min=230 x_plate_ohms=60
modprobe ads7846
FRAMEBUFFER=/dev/fb1 startx
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0

xinput - make it permanent

To make the axis inversion permanent, add it to /etc/X11/xinit/xinitrc

#!/bin/sh
# /etc/X11/xinit/xinitrc
#
# global xinitrc file, used by all X sessions started by xinit (startx)

# Touchpanel: Invert Y axis
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 0 1

# invoke global X session script
. /etc/X11/Xsession

tslib

Tslib is an abstraction layer for touchscreen panel events, as well as a filter stack for the manipulation of those events. It was created by Russell King, of arm.linux.org.uk. Examples of implemented filters include jitter smoothing and the calibration transform.

Tslib is generally used on embedded devices to provide a common user space interface to touchscreen functionality. It is supported by Kdrive (aka TinyX) and OPIE as well as being used on a number of commercial Linux devices including the Nokia 770.

Tslib downloads and source code are now being hosted at github.

Testing on the Raspberri Py

sudo apt-get install libts-bin

# Moving/Drawing test
sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event3 ts_test

# 5 crosshairs calibration
sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event3 ts_calibrate
xres = 240, yres = 320
Took 38 samples...
Top left : X =  993 Y =  783
Took 29 samples...
Top right : X = 3135 Y =  799
Took 36 samples...
Bot right : X = 3135 Y = 3207
Took 46 samples...
Bot left : X = 1024 Y = 3231
Took 42 samples...
Center : X = 2091 Y = 2015
-15.777374 0.065827 -0.000425
-22.170654 0.000161 0.090601
Calibration constants: -1033986 4314 -27 -1452976 10 5937 65536

For some reason it didn't work when I exported the TSLIB_FBDEVICE and TSLIB_TSDEVICE env. variables.

This seem to be coupling between tslib and pygame. Not tested.

export SDL_MOUSEDRV=TSLIB
export SDL_MOUSEDEV=$TSLIB_TSDEVICE

X calibration

Using the touchscreen within your own programs outside of X

Simple Draw program

To accept input from a touchscreen we have to use the event interface of the Linux input system. We use the ioctl capabilities of the event interface, in addition to the normal read and write calls to get information from the touchscreen. The URL below explains how to use the touchscreen within your own programs using C as well as writing directly to the framebuffer. It also includes example code.

References

piwik

Clone this wiki locally