Skip to content

Instantly share code, notes, and snippets.

@matkarlg
Last active April 29, 2024 01:31
Show Gist options
  • Save matkarlg/a7d8371265e3ee2d75fcda35aa5dea5c to your computer and use it in GitHub Desktop.
Save matkarlg/a7d8371265e3ee2d75fcda35aa5dea5c to your computer and use it in GitHub Desktop.
XPT2046/ADS7846 Touchscreen Android AOSP Raspberry PI RPi

CONFIG_TOUCHSCREEN_ADS7846=y in kernel config

Compile overlay and add: (maybe different per tablet, goodtft/LCD-show)

dtoverlay=ads7846,cs=1,penirq=25,penirq_pull=2,speed=50000,keep_vref_on=0,swapxy=0,pmax=255,xohms=150,xmin=200,xmax=3900,ymin=200,ymax=3900

Add ADS7846_Touchscreen.idc to /system/usr/idc/

ADS7846_Touchscreen.idc:

# This is an internal device, not an external peripheral attached to the USB
# or Bluetooth bus.
device.internal = 1

# The device should behave as a touch screen, which uses the same orientation
# as the built-in display.
touch.deviceType = touchScreen
touch.orientationAware = 1

My touchscreen had swapped xy and inverted x axis. Changed kernel/arpi/drivers/input/touchscreen/ads7846.c

~line 1384
+ ts->core_prop.swap_x_y = true;
+ ts->core_prop.invert_x = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment