pimoroni / hyperpixel4

Driver for the Pimoroni HyperPixel 4.0" Touchscreen Display
https://shop.pimoroni.com/products/hyperpixel-4?variant=12569485443155
328 stars 47 forks source link

dtoverlay settings in /boot/config.txt sporadically applied depending on i2c address / temperature, solution? #131

Open fhb opened 3 years ago

fhb commented 3 years ago

Bug description and reproduction steps

I'm trying to rotate the display and the touch-overlay from portrait to landscape.

I tried both the one-line-installation for the rpi4 with and without "experimental touch fix".

The command "hyperpixel4-rotate left" led to a correct display rotation with inverted touch-overlay and also the rotation did not persist after reboot, so I rotated back with hyperpixel4-rotate normal.

I then edited /boot/config.txt out-commenting: #dtoverlay=vc4-fkms-v3d and adding display_lcd_rotate=3 and then dtparam=touchscreen-swapped-x-y=1 dtparam=touchscreen-inverted-x=1 after dtoverlay=hyperpixel4 or instead writing dtoverlay=hyperpixel4, touchscreen-swapped-x-y=1, touchscreen-inverted-x=1

complete config.txt: https://gist.github.com/fhb/4f45b8d86cfb7bb011703334c275983f

This led to a temporary solution with both screens and touch-overlay being rotated properly. But after a reboot of the RPI I'm stuck with the touchscreen x-axis being inverted and my settings in /config.txt regarding the dtoverlay don't seem to have an effect. Reading through the documentation and the documented issues I found that the touchscreen driver tries to connect through i2c to the addresses 0x5d and 0x14, one of them failing. The cause of the dtoverlay settings in /boot/config.txt being applied or ignored seems to be related to the temperature dependent address switch. After shutting down and letting the display and rip4 cool down, the touchscreen connects to 0x14 and the dtoverlay settings get applied. After a "hot" reboot and the touchscreen being connected to 0x5d the setting gets ignored. This seems to be a consistent finding.

Your HyperPixel 4 Rectangular, Touch, purchased a week ago, connected via gpio

Your Raspberry Pi RPI4 Revision : b03114 with OctoPi, Raspbian GNU/Linux 10 (buster) 5.10.17-v7l+

Extra debugging information

[ 5.959145] Goodix-TS 11-005d: ID 911, version: 1060 [ 5.983433] Goodix-TS 11-005d: Checking firmware [ 5.985364] input: Goodix Capacitive TouchScreen as /devices/platform/i2c@0/i2c-11/11-005d/input/input1 [ 5.987206] Goodix-TS 11-0014: i2c test failed attempt 1: -6 [ 6.034212] Goodix-TS 11-0014: i2c test failed attempt 2: -6 [ 6.083566] Goodix-TS 11-0014: I2C communication failure: -6

[ 6.241638] Goodix-TS 11-005d: i2c test failed attempt 1: -6 [ 6.274569] Goodix-TS 11-005d: i2c test failed attempt 2: -6 [ 6.323971] Goodix-TS 11-005d: I2C communication failure: -6 [ 6.326096] Goodix-TS 11-0014: ID 911, version: 1060 [ 6.350466] Goodix-TS 11-0014: Checking firmware

/dev/i2c-11

fhb commented 3 years ago

There is also flickering and ghosting when connected to 0x5d as you can see in this short video of the display: https://www.dropbox.com/s/y98anzsv20uu9a4/IMG_3753.MOV?dl=0

Gadgetoid commented 3 years ago

It looks like you've got a mix of old and new settings in your /boot/config.txt-

The non-fix settings are:

dtoverlay=hyperpixel4
dtparam=touchscreen-swapped-x-y=1
dtparam=touchscreen-inverted-x=1

You need to remove these and, instead, add the touchscreen settings under each instance of the touchscreen overlays, like so:

dtoverlay=hyperpixel4-common
dtoverlay=hyperpixel4-0x14
dtparam=touchscreen-swapped-x-y=1
dtparam=touchscreen-inverted-x=1
dtoverlay=hyperpixel4-0x5d
dtparam=touchscreen-swapped-x-y=1
dtparam=touchscreen-inverted-x=1

This should ensure that both 0x14 and 0x5d are configured to match.

I'm a little out of touch with HyperPixel 4 and don't know what's causing the flickering/ghosting. From what I understood with the i2c address switch, it was a race condition during bootup that caused the i2c select pin to be pulled. It shouldn't have any bearing on the display driver at all.

fhb commented 3 years ago

Thank you! Setting it this way I don't have to swap the x/y-axis: https://gist.github.com/fhb/1bf17c090baa2d33301b622b26505b6c

#dtoverlay=vc4-fkms-v3d  
display_lcd_rotate=3  
dtoverlay=hyperpixel4-common  
dtoverlay=hyperpixel4-0x14  
#dtparam=touchscreen-swapped-x-y=1  
dtparam=touchscreen-inverted-x=1  
dtoverlay=hyperpixel4-0x5d  
#dtparam=touchscreen-swapped-x-y=1  
dtparam=touchscreen-inverted-x=1

I'll keep watching but the issue might be resolved with your solution.

The installation of the Hyperpixel 4.0 is far from plug and play and has incomplete instructions.

Gadgetoid commented 3 years ago

There is also flickering and ghosting when connected to 0x5d as you can see in this short video of the display: https://www.dropbox.com/s/y98anzsv20uu9a4/IMG_3753.MOV?dl=0

I've just seen this flickering on a Pi 400 when detected as 0x5d. A cold boot seemed to fix it. And also the i2c. I wonder if there's something weirder going on with the pin state when hot-plugging/rebooting.