I’m attempting to set up a Hyperpixel 2.1 with a Raspberry Pi Zero V1.1w, I’ve followed the guides on both setting up the display and the touch drivers, including using the pygame error fix shown on the touch driver github.
When using the RasPi4, example apps display correctly, however on my Pi3b+ and the intended Zero 1.1w, apps are drawn off centre and incorrectly (Pi3b+ pictured, same on the Zero). I’m using the version of Buster provided on the product page to avoid the issues with Bullseye.
Does anyone have any insight as to how to fix this? I was under the impression the Pi4 was the less stable option for HyperPixel displays at the moment.
hel
December 8, 2021, 9:10am
#2
Try updating to a newer version of Pygame!
opened 06:49PM - 28 Jul 21 UTC
notice
In some instances the examples may look like this:

This is due to somewhat old pygame/SDL versions being shipped with Raspberry Pi OS.
### Raspberry Pi 3 etc
On Pi 3B+, Pi Zero and other pre-Pi4 boards you can update pygame from pip to fix glitchiness:
```
sudo python3 -m pip install pygame --upgrade
```
### Raspberry Pi 4
On Pi 4, you should upgrade pygame as above but it will probably result in this error when you try and run an example:
```
* failed to add service - already in use?
```
I believe this, followed by the unhelpful hard `exit(1)` is caused by this code: https://github.com/raspberrypi/userland/blob/97bc8180ad682b004ea224d1db7b8e108eda4397/interface/khronos/common/linux/khrn_client_rpc_linux.c#L214-L216
In any case the only way to work around this seems to be by compiling SDL from source... :grimacing: ... and using your shiny new SDL to replace the system one used by pygame.
You can do that with the following steps:
```
wget https://www.libsdl.org/release/SDL2-2.0.14.zip
unzip SDL2-2.0.14.zip
cd SDL2-2.0.14
./configure --enable-video-rpi --enable-video-kmsdrm --prefix=`pwd`/install
make
make install
```
This will install SDL into an "install" directory within the "SDL2-2.0.14" directory, so don't delete it. (You can change the `--prefix` when configuring to something like `/opt/SDL2-2.0.14` if you're so inclined, it doesn't really matter where you put it.)
Once built the new SDL libraries will be available in `install/lib`, find the full path by typing:
```
cd install/lib
pwd
```
In my case the path is `/home/pi/SDL2-2.0.14/install/lib`.
Now when running an example from this repository, you should prefix the command line with `LD_LIBRARY_PATH=/home/pi/SDL2-2.0.14/install/lib`, for example:
```
sudo LD_LIBRARY_PATH=/home/pi/SDL2-2.0.14/install/lib python3 clock.py
```
If everything is set up correctly on your Pi 4 you should see "Using driver: kmsdrm"
Thanks a lot, that fixed it completely!
1 Like