Hyperpixel 4 touchscreen rotation in raspberry pi 4

I’ve been stuck for days trying to solve this issue and I just can’t get it to work, and there still doesn’t seem like there this an official solution for this. I can easily rotate the display, without any issue, so that the USB-C and HDMI ports are at the bottom but I can’t in any way make the touchscreen properly calibrated.

Things I’ve tried:

The hyperpixel4-rotate left command. After a few issues, running it through SSH, I’ve managed to run the command without issue. And while it rotates the display, it does nothing for the touchscreen.

dtparams in /boot/config.txt
dtparam=touchscreen-swapped-x-y
dtparam=touchscreen-inverted-x
dtparam=touchscreen-inverted-y

And all possible configurations of these 3 parameters doesn’t fix it:

1 - touchscreen-swapped-x-y
- does nothing

2 - touchscreen-inverted-x
- top left and bottom right work - top right and bottom left are inverted

3 - touchscreen-inverted-y
- does nothing

4 - touchscreen-swapped-x-y
** touchscreen-inverted-x**
- top left and bottom right work - top right and bottom left are inverted

5 - touchscreen-swapped-x-y
** touchscreen-inverted-y**
- does nothing

6 - touchscreen-inverted-x
** touchscreen-inverted-y**
- top left and bottom right work - top right and bottom left are inverted

7 - touchscreen-swapped-x-y
** touchscreen-inverted-x**
** touchscreen-inverted-y**
- top left and bottom right work - top right and bottom left are inverted

This just leads me to believe only the touchscreen-inverted-x actually does anything. I’ve tried calibrating through this process described here: Touch Screen Calibration (Linux) and writing the matrix into the file “/etc/udev/rules.d/98-hyperpixel4-calibration.rules” but it also does nothing, for better or worse.

I’ve tried the process of manually editing the dto overlay file before installing, to replace the 480x800 resolution axis. Nothing changed.

Fun fact: in the boot/config.txt file having dtoverlay=hyperpixel4 or dtoverlay=hyperpixel4:rotate doesn’t do anything. Rotation works perfectly fine with just the display_rotate=3 or display_lcd_rotate=3

Enabling or disabling the dtoverlay=vc4-fkms-v3d in either the pi4 or all sections does nothing either.

I’ve tried both the pi4 and pi4 with experimental touch fix. Same result.

Can anyone help? I’m getting frustrated with this because this display as it is with this issue, it’s just unusable since I need it in this rotation.

Here’s my current config.txt, where the rotation works and top left and bottom right corners work, with the top right and bottom left are inverted.

Enable audio (loads snd_bcm2835)

dtparam=audio=on

[pi4]

Enable DRM VC4 V3D driver on top of the dispmanx display stack

#dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d
start_x=1
gpu_mem=512

dtoverlay=hyperpixel4:rotate
gpio=0-25=a2
#dtparam=touchscreen-swapped-x-y
dtparam=touchscreen-inverted-x
#dtparam=touchscreen-inverted-y
#touchscreen_swapped=1
enable_dpi_lcd=1
dpi_group=2
dpi_mode=87
dpi_output_format=0x7f216
dpi_timings=480 0 10 16 59 800 0 15 113 15 0 0 0 60 0 32000000 6
display_lcd_rotate=3

dtoverlay=hyperpixel4-common
dtoverlay=hyperpixel4-0x14
dtoverlay=hyperpixel4-0x5d

Found a fix. This command properly sets the touchscreen calibration rotation for me:

xinput set-prop ‘Goodix Capacitive TouchScreen’ ‘Coordinate Transformation Matrix’ 0 -1 1 1 0 0 0 0 1

This setting isn’t persisted after rebooting though. For now I put it inside a .desktop file to run on startup and it’s working fine.

Hi - looks likes you have been really putting lots of effort into trying to fix this issue.

Im new to rasp pi ands have the hyperpixel 4 so I can use it for my 3d printer. I am using Repetier Server which works great - just wished the touch screen worked in landscape

Being a newbie to the rasp pi and all the commands do I just modify my /boot/config.txt file with the detail from your posting (above) which I can do without any problems, The bit im stuck in is the screen rotation but - how do I add a .desktop file?
Thanks

So you’ve managed to rotate the display itself, just the touch isn’t calibrated right?

Have you tried running the command I added? And does it work? Make sure you’re running the command not through ssh but ideally while connected directly with mouse and keyboard to the rpi otherwise you’ll get an error saying xserver not found or something similar. You can get around this by adding DISPLAY=:0.0 before the command but I had no luck with that.

For the .desktop file, this is like a service that runs when the user logs in. I created a file with this path:

/home/pi/.config/autostart/hyperpixel4-calibration.desktop

With the content:

[Desktop Entry]
Type=Application
Name=Hyperpixel4 rotation left calibration
Comment=calibrates touchscreen to left rotation
Exec=xinput set-prop 'Goodix Capacitive TouchScreen' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1

Depending on your rotation you might have to change the matrix values.

  • Rotate left 90 = xinput set-prop ‘Goodix Capacitive TouchScreen’ ‘Coordinate Transformation Matrix’ 0 -1 1 1 0 0 0 0 1
  • Rotate 180 = xinput set-prop ‘Goodix Capacitive TouchScreen’ ‘Coordinate Transformation Matrix’ -1 0 1 0 -1 1 0 0 1
  • Rotate right 90 = xinput set-prop ‘Goodix Capacitive TouchScreen’ ‘Coordinate Transformation Matrix’ 0 1 0 -1 0 1 0 0 1
  • Return to upright = xinput set-prop ‘Goodix Capacitive TouchScreen’ ‘Coordinate Transformation Matrix’ 1 0 0 0 1 0 0 0 1

Hi - thanks for getting back to me.
I’ve now sorted it and it works great.
There is a very good video on YouTube which shows you how to do everything with links to the files.
As you rightly say, you need to make changes but following the video I only had to make 2 changes to the config.txt file and one change to libinput file.
From a customer service prospective it’s appalling that the screen manufacturer hasn’t sorted this out so changes are easier to make.

The video is here :

Thanks again.

Glad it’s working for you.

It is a bit disappointing. I spent quite a while digging through github issues related to this, of which there are many, and none of it fixed it. Rotation even had to be done outside of the hyperpixel4-rotate command because even when that worked(always had some kind of error) it never persisted after rebooting.

This fix was even given to me from the support at The PiHut. There should be more documentation and even improvements to the driver would go a long way towards fixing the issues for rpi 4 users because out of the box the Hyperpixel 4 just doesn’t work well with the Raspberry Pi 4, unless the intended use is the default portrait mode.

Thanks again. It was doing my head in ! I’ve just been playing with all the different orientation options and at worked for them all. Despite all the messing around it’s a nice little screen and just what I need for my 3D printer with Repetier Server.