Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide touchscreen calibration instructions. #22

Open
0x0f0f0f opened this issue Apr 14, 2019 · 15 comments

Comments

Projects
None yet
6 participants
@0x0f0f0f
Copy link

commented Apr 14, 2019

I'm having an hard time calibrating the touchscreen with xinput_calibrator.
The touchscreen is really miscalibrated. When I touch the right part of the screen the cursor never gets further than 3/4 of the display width.

Xorg does not load the calibration settings I've put in /etc/X11/xorg.conf.d/99-calibration.conf

xinput list-props [hyperpixel's id] tells me that the Hyperpixel supports a libinput Calibration Matrix. I have also enabled xorg's 40-libinput.conf config file to load libinput but no luck yet.

@0x0f0f0f

This comment has been minimized.

Copy link
Author

commented Apr 14, 2019

I have calibrated the touchscreen successfully by installing evdev

Here are the steps needed to calibrate the touchscreen on Void Linux. May differ slightly on raspbian (uses apt)

# install evdev driver and xinput_calibrator
sudo xbps-install -S xf86-input-evdev xinput_calibrator xinput
# create xorg config folder
sudo mkdir /etc/X11/xorg.conf.d/
# enable 10-evdev.conf
sudo cp /usr/share/X11/xorg.conf.d/10-evdev.conf /etc/X11/xorg.conf.d/
# list input devices and remember the id number next to "Goodix Capacitive Touchscreen"
xinput list
# now calibrate the touchscreen and save the config to a file.
# replace HYPERPIXEL_ID with the number you found in the previous step
xinput_calibrator --misclick 0 --device HYPERPIXEL_ID > 99-calibration.conf.temp
# if the display was calibrated correctly, open the config file
# in a text editor and remove the leading lines until the one beginning with "Section"
# and remember to save the file
nano 99-calibration.conf.temp
# move the configuration file under its correct directory
sudo mv 99-calibration.conf.temp /etc/X11/xorg.conf.d/99-calibration.conf
@t0b3

This comment has been minimized.

Copy link

commented May 19, 2019

Your steps didn't work for me on raspbian, Xorg wasn't happy with these options.

However I was lucky to calibrate my hyperpixel4 successful with these steps

It works fine now with /etc/X11/xorg.conf.d/99-calibration.conf

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "Goodix Capacitive TouchScreen"
        Option  "TransformationMatrix"  "1.69 0 -0.68 0 0.63 0.38 0 0 1"
EndSection

NB: Seems like the default calibration confuses 800px vs 480px:
5/5th of the touching width address only the rightmost 3/5th of the screen,
while the lower 3/5th of the touch cover the full height.

@mikekscholz

This comment has been minimized.

Copy link

commented May 20, 2019

On raspbian you wanna make sure you install xserver-xorg-input-evdev then you want to edit your 40- file inside of xorg.conf.d and find the goodix and change the driver line from evdev to xinput. It should then obey your 99-calibration. Also even though xinputcalibrator gives an output to use swapXY, change that to say swapAxes.

@mikekscholz

This comment has been minimized.

Copy link

commented May 20, 2019

I can be way more specific later when I get off work, I’m nowhere near a pi right now to give exact code:

@t0b3

This comment has been minimized.

Copy link

commented May 21, 2019

I can be way more specific later when I get off work, I’m nowhere near a pi right now to give exact code:

That would help to clarify and understand your configuration, cause I feel more confused as I didn't have any 40-evdev file, only 10-evdev or 40-libinput, neither I've seen xinput driver, only evdev or libinput.

@mikekscholz

This comment has been minimized.

Copy link

commented May 21, 2019

Yea I couldn’t remember the name offhand, in your 40-libinput under the entry for goodix, change the driver line from libinput to evdev. That one change allowed me to use swapAxes and invertx/y to fix my hyperpixel without using any matrix transforms

@mikekscholz

This comment has been minimized.

Copy link

commented May 23, 2019

https://www.raspberrypi.org/forums/viewtopic.php?t=179477 Here is the full write up I found as to what’s actually going on here, final solution is about the 4th post down I think.

@blumberg

This comment has been minimized.

Copy link

commented May 23, 2019

@0x0f0f0f I have the same issue with my HyperPixel. After a lot of calibration and testing, the best, and easiest, solution for me was to modify a little the driver.

After you clone the driver from GitHub, go to file src/hyperpixel4.dts and modify the following lines:

             touchscreen-size-x = <800>;
             touchscreen-size-y = <480>;

to

            touchscreen-size-x = <480>;
            touchscreen-size-y = <800>;

then just run ./install.sh and everything should work nicely.

@t0b3

This comment has been minimized.

Copy link

commented May 23, 2019

@blumberg hey works great here!!! please make a pull request to get this nasty issue fixed by smart default values.

@mikekscholz

This comment has been minimized.

Copy link

commented May 23, 2019

This got me wondering, as to why the actual display is configured as 480x800 then rotated to position 3, as if it’s natively a portrait display. This causes issues playing video in vlc with the same sort of 2/3 of the screen cutoff/offset. I might have to try changing the video timing to 800x480 and then the screen rotation to 0.

@blumberg

This comment has been minimized.

Copy link

commented May 23, 2019

@blumberg hey works great here!!! please make a pull request to get this nasty issue fixed by smart default values.

I believe it's a manufacturing issue, a few screens are assembled in one way and others in another way. If that is the case, make no sense to modify this as you will create an issue for those that don't have it now.

What could be done is to recognize this issue and offer an easy way to switch between those two drivers.

those are the commands that I've been using:

git clone https://github.com/pimoroni/hyperpixel4.git
cd hyperpixel4
sed -i 's/touchscreen-size-x\ =\ <800>/touchscreen-size-x\ =\ <480>/g' src/hyperpixel4.dts
sed -i 's/touchscreen-size-y\ =\ <480>/touchscreen-size-y\ =\ <800>/g' src/hyperpixel4.dts
./install.sh

It could be suggested on the main page: If you are experiencing calibration issues, try procedure below:

@TeCoEd

This comment has been minimized.

Copy link

commented Jun 10, 2019

I was having an issue with the calibration and then I got Garrus (Mass Effect) on board! Basically I used a clean OS install and then used the Pi preferences from the main menu and set the 'OVER SCAN to off. Then I installed the HyperPixel 4 software / drivers. Works now, touch is calibration is accurate.

Also rotated the screen and works fine too. Only needed to changed the rotation to 1

ZEijVxG

@Gadgetoid

This comment has been minimized.

Copy link
Member

commented Jun 14, 2019

First of, all, I've been in a black hole of 32blit development work along with trying to keep up with my longtail of software maintenance, so this had largely slipped me by. Sorry for the delay!

@mikekscholz because it's a 480x800 pixel portrait display (presumably intended for some kind of handheld computer)
@blumberg as near as I can tell, it's related to something having changed with recent Raspbian updates. I don't know what yet, but I've taken a perfectly-functional HyperPixel 4 off a shelf, updated, tested it and run into this same problem.

Right now the swapping 800/480 touchscreen sizes fix is not working for me and I need to get to the bottom of why.

If I can find an approach that works, then it should be possible to include both the flipped and non-flipped coordinates in the dtoverlay and give the user a parameter to switch to the one that works for them.

I'm somewhat relieved that our touchscreen is not the only one having issues.

Thank you everyone for your input here.

@Gadgetoid

This comment has been minimized.

Copy link
Member

commented Jun 14, 2019

I've been working on some tweaks to the dtoverlay which get us half of the way there, but calibration is still an absolute nightmare. The best approach I've found thus far is the manual calculation one linked by @t0b3 which gives me a line like:

DISPLAY=:0.0 xinput set-prop "pointer:Goodix Capacitive TouchScreen" "libinput Calibration Matrix" 0.946372239748, 0.0, 0.125, 0.0, 1.64383561644, -0.676369863014, 0.0, 0.0, 1.0

Which I then refined manually by trial and error, and a little use of evtest to get the min/max X coordinates to get:

DISPLAY=:0.0 xinput set-prop "pointer:Goodix Capacitive TouchScreen" "libinput Calibration Matrix" 0.779220779221, 0.0, 0.424025974026, 0.0, 1.69, -0.69, 0.0, 0.0, 1.0

This still isn't perfect, the horizontal acceleration of the cursor is off such that it speeds ahead of my finger as I approach the right. But it's better than the half-a-screen problem I had before.

@Gadgetoid

This comment has been minimized.

Copy link
Member

commented Jun 14, 2019

I've created a new branch to track the libinput tweaks- https://github.com/pimoroni/hyperpixel4/tree/libinput

Notably it includes changes to the dts file and a udev rule to persist the transformation matrix settings: 56b0ad4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.