Hello, I’m trying to configure my new Hyperpixel 4 square to my RPi 4, I already managed to get it to work but I can’t get it to rotate automatic in config.txt.
Here is my config.txt
dtoverlay=vc4-fkms-v3d
dtoverlay=hyperpixel4
dtparam=rotate=90,touchscreen-swapped-x-y,touchscreen-inverted-y
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```
If I put 'DISPLAY=:0.0 sudo hyperpixel4-rotate right' on terminal it rotates the display and the touchscreen works great, but I can't change it on the config.txt.
Hope anybody can help me.
Thanks.
Muts
February 14, 2023, 8:42am
2
Hello,
Do you have the latest OS, Bullseye running on you RPi4?
You say you have the square one, so maybe you need to use
dtoverlay=vc4-kms-dpi-hyperpixel4sq
instead of two dtoverlay’s you use now.
Rotate for the square use, make sure it is right after the dtoverlay line:
dtparam=rotate=90 - Header is on the left (wonky touch, see below)
dtparam=rotate=180 - Header still on the top (doesn't work? Same as default)
dtparam=rotate=270 - Header is on the right (wonky touch, see below)
It is not that I’m a smart boy, I just read this page:
opened 05:25PM - 11 Apr 22 UTC
notice
:warning: PSA: Make sure you disable i2c, SPI and any other interfaces since the… se will cause a conflict in device-tree with HyperPixel :warning:
:warning: A fresh image is recommended, but otherwise make sure you also disable the `hyperpixel4-init` system service! :warning:
Pi 3B and Pi 4 users running the latest and greatest Raspberry Pi OS should forego our installer and use the instructions below.
> :information_source: If you're tied to an older OS and you want to install the legacy drivers, use:
> `curl -sSL get.pimoroni.com/hyperpixel4-legacy | bash`
This new OS can currently be found in Raspberry Pi Imager under "Raspberry Pi OS (Other)"
![image](https://user-images.githubusercontent.com/1746967/162789702-0c95f165-e482-4d47-a179-d841b903985c.png)
Once installed you need only one line in `/boot/config.txt`:
* Rectangular: `dtoverlay=vc4-kms-dpi-hyperpixel4`
* Square: `dtoverlay=vc4-kms-dpi-hyperpixel4sq`
You can rotate these in config.txt by adding the `rotate=` parameter, like so:
```
dtoverlay=vc4-kms-dpi-hyperpixel4sq,rotate=90
```
This supports rotation in console, too, for all you CyberDeck builders!
## HyperPixel 4 Rectangular Rotations
Ensure rotation is set to "Normal" in "Display Configuration"
And that the dtoverlay is in `/boot/config.txt`:
```
dtoverlay=vc4-kms-dpi-hyperpixel4
```
Finally use one of the following `dtparam` lines immediately underneath to set the parameters:
* The default is portrait with header on the right, no extra line needed
* `dtparam=rotate=90,touchscreen-swapped-x-y,touchscreen-inverted-y` - Landscape with header on the bottom
* `dtparam=rotate=180` - Portrait with header on the left
* `dtparam=rotate=270,touchscreen-swapped-x-y,touchscreen-inverted-x` - Landscape with header on the top
## HyperPixel 4 Square Rotations
HyperPixel 4 Square does not correctly swap or invert touch input, so you may want to use the Xorg config method below.
Ensure rotation is set to "Normal" in "Display Configuration"
And that the dtoverlay is in `/boot/config.txt`:
```
dtoverlay=vc4-kms-dpi-hyperpixel4sq
```
Finally use one of the following `dtparam` lines immediately underneath to set the parameters:
* Default is header on the top
* `dtparam=rotate=90` - Header is on the left (wonky touch, see below)
* `dtparam=rotate=180` - Header *still* on the top (doesn't work? Same as default)
* `dtparam=rotate=270` - Header is on the right (wonky touch, see below)
:warning: The `touchscreen-swapped-x-y` parameter does not seem to work with Square. You may need to use the script below for Raspberry Pi OS with Desktop.
## On the fly rotation
Rotating the display via "Screen Configuration" ("arandr") results in inverted touch input and other weirdness- use the dtoverlay params.
If you want to rotate on the fly you can use the below bash script to rotate either display and persist settings into Xorg configuration files.
:warning: Note: You *must* remove the `rotate=` argument from `/boot/config.txt` for these to make sense.
You can remove the rotation config by deleting the `/usr/share/X11/xorg.conf.d/88-hyperpixel4-touch.conf` and `/usr/share/X11/xorg.conf.d/88-dsi-1-rotate.conf` files.
```bash
#!/bin/bash
UTILITY="hyperpixel4-rotate (Rectangular)"
XORG_TOUCH_CONF_FILE="/usr/share/X11/xorg.conf.d/88-hyperpixel4-touch.conf"
XORG_CONF_FILE="/usr/share/X11/xorg.conf.d/88-dsi-1-rotate.conf"
OVERLAY_S="vc4-kms-dpi-hyperpixel4sq"
OVERLAY_R="vc4-kms-dpi-hyperpixel4"
function success() {
echo -e "$(tput setaf 2)$1$(tput sgr0)"
}
function inform() {
echo -e "$(tput setaf 6)$1$(tput sgr0)"
}
function warning() {
echo -e "$(tput setaf 1)$1$(tput sgr0)"
}
function set_xorg_conf {
if [ "$DISPLAY" == "" ]; then
inform "No DISPLAY variable set, trying :0.0"
export DISPLAY=:0.0
fi
inform "Rotating display $1";
xrandr --output DPI-1 --rotate $1
MATRIX="$2 $3 $4 $5 $6 $7 $8 $9 ${10}"
inform "Setting libinput Calibration Matrix: 1 0 0 0 1 0";
xinput set-prop "pointer:$DEVICE" "libinput Calibration Matrix" 1 0 0 0 1 0 0 0 1
inform "Setting Coordinate Transformation Matrix: $MATRIX";
xinput set-prop "pointer:$DEVICE" "Coordinate Transformation Matrix" $MATRIX
inform "Saving xorg touch config to $XORG_TOUCH_CONF_FILE";
sudo tee $XORG_TOUCH_CONF_FILE > /dev/null <<EOF
# Auto generated by $UTILITY, edit with care!
Section "InputClass"
Identifier "HyperPixel4 $DEVICE"
MatchProduct "$DEVICE"
Option "CalibrationMatrix" "1 0 0 0 1 0 0 0 1"
Option "TransformationMatrix" "$MATRIX"
EndSection
EOF
inform "Saving xorg rotate config to $XORG_CONF_FILE";
sudo tee $XORG_CONF_FILE > /dev/null <<EOF
# Auto generated by $UTILITY, edit with care!
Section "Monitor"
Identifier "DPI-1"
Option "Rotate" "$1"
EndSection
EOF
}
printf "HyperPixel 4: Display & Touch Rotation\n"
printf "This utility requires the Raspberry Pi OS desktop or an *Xorg-based* alternative.\n\n"
ORIENTATION=$1
grep -e "^dtoverlay=$OVERLAY_S.*" /boot/config.txt > /dev/null
if [ $? -ne 0 ]; then
grep -e "^dtoverlay=$OVERLAY_R.*" /boot/config.txt > /dev/null
if [ $? -ne 0 ]; then
warning "Rotation requires hardware support on the Pi 4 or Pi 400"
warning "Ensure your HyperPixel4 is enabled in /boot/config.txt"
printf "\nSquare: dtoverlay=$OVERLAY_S\n"
printf "Rectangular: dtoverlay=$OVERLAY_R\n\n"
exit 1
else
inform "Detected HyperPixel 4 Rectangular (found \"$OVERLAY_R\" in config.txt)"
DEVICE="Goodix Capacitive TouchScreen"
fi
else
inform "Detected HyperPixel 4 Square (found \"$OVERLAY_S\" in config.txt)"
DEVICE="EP0110M09"
fi
case $ORIENTATION in
"right")
set_xorg_conf $ORIENTATION 0 1 0 -1 0 1 0 0 1
;;
"left")
set_xorg_conf $ORIENTATION 0 -1 1 1 0 0 0 0 1
;;
"inverted")
set_xorg_conf $ORIENTATION -1 0 1 0 -1 1 0 0 1
;;
"normal")
set_xorg_conf $ORIENTATION 1 0 0 0 1 0 0 0 1
;;
*)
printf "Unsupported orientation: $ORIENTATION\n\n";
printf "Usage:\n"
printf " $0 <orientation>\n\n"
printf "Where orientation is one of: left, right, normal, inverted.\n"
exit 1
esac
```
Let us know if it worked for you.