Rpi 4, 5"touchscreen & Akai mpk mk2. Touchscreen Setup help? [Solved]

Noob here,
Trying to set up Zynthian on my new rPi 4. I have a Longruner 5" touchscreen. The screen displays, but still haven’t been successful with the touch part. I keep ending up at “Cannot connect to X server” error.
Here’s what I did:
Boot up fresh Zynthian download on Rpi 4. Touchscreen is plugged into gpio pins, but I have hdmi “micro to standard” cable (instead of that little adapter).
First boot splash screen shows “error”, but if I let it sit, it goes to UI. Then on separate computer, Zynthian.local and change hardware to kit=custom, rpi headphones, generic hdmi. Then I log into wireless and also update. After reboot, still have a good UI.
Then I install drivers for touchscreen. This is when, after reboot, things get wonky. I no longer have ui, but rather a shell with Zynthians info on top.
But still, moving forward…
I enter commands to change script and calibrate touchscreen. But after I enter
Startx ./calibrate.sh (sorry, I’m doing this from memory) I get error “Cannot connect to X server”

With these sorts of rigs I treid to get the screens working with a default raspi pi desktop, just to prove the hardware was correct.

Doing it that way completely rules zynthian out of the equation, and there are many tutorials for Pi’s.

Hey, thanks for the comeback!
I can confirm it does work with RaspiOS.

Ok so the hardware is good.

Presumably you’ve had a look at this epic …?

You said that you installed driver for touchscreen. How did you do that? Some touchscreens have very intrusive driver installation methods that pretty much frap whatever you have. Add a link to the driver installation instructions.

Link
About halfway down the page. Thanks for looking. I’m at work, driving, for a few more hours. I’ll be able to focus more then. I appreciate it!

Ah yes! The lcd-show driver is notoriously tricky. It can be made to work on RPi3 but not so well with RPi4. Their approach is to smack a closed source blob on the machine which is tied to a specific kernel version. I had fun with this for a while before swearing (a lot) that I wouldn’t touch one again. Luckily for me I was gifted another screen that used the driver by our own @wyleu so the hell began again!

You may struggle to get this working properly. I would suggest removing the driver (maybe you have to reflash the Zynthian image) and look to see if the touch interface can be accessed via another method.

I have looked at the installer LCD5-show and it writes loads of stuff to config.txt which is not required to get this working. It may actually work without too much change. Try this:

  • Flashing zynthian image to sd
  • After booting and allowing it to settle (about 5 mins) perform your previous setup but select Wave Share 5 + HDMI+GPIO
  • Perform a software update
  • Reboot Zynthian
  • Navigate to Admin->Calibrate
  • Attempt screen calibration

Let us know if this doesn’t work but don’t try to run the LCD5-show installer again. We can do some diagnostics…

Beware of wyleu’s bearing gifts … :smiley:

Certainly got a lot further than I had previously. However, after selecting calibrate, I get the “touch the cross hairs” with the 15 second countdown. I touch the cross hair with my stylus. The cross hair turns red, and the timer goes back to 15. Then freezes. No second cross hair… Or anything.

Edit; So the touchscreen does work. I don’t know anything about Zynthian yet, but I played around with different layers just to see what I could do. I definitely need to calibrate though, somehow. Because it seems to make ghost touches. Like if I try to use my stylus to turn up chorus, I can’t do it. It’ll actually jump around the screen and make weird page changes/entries etc. and I’m not able to change any specific parameters.

I also am able to get sounds and play some keys. But A. It’s really quiet! And B. I can’t get Alsa mixer up to raise volume.
Thank you for your help! Please let me know how to move forward.

Good to see a little progress. Let’s concentrate on calibration first…

The calibration screen uses a couple of methods to detect input. When it first displays the crosshair in the centre of the screen it is waiting for some input via evdev, a Linux input device subsystem. This allows Zynthian to detect which device is being calibrated. Upon detection it should turn the crosshairs red , start the countdown and show the name of the touchscreen device at the bottom of the screen. Subsequent calibration steps use the GUI library detection of touch and release. So it sounds like screen detection is failing.

Do you see the name of the touchscreen device displayed after touching the centre crosshairs?

No,
It seems to just freeze after it turns red.

@Aetro are you able to connect via ssh? Post the result of this command (whilst Zynthian is running):

DISPLAY=:0 xinput --list --name-only

Hey, Thanks!
Connecting via SSH, I’m communicating with Zynthian via Zynthian.local from my desktop, in the Terminal. Is that just the same as, say, Putty?
Typing

DISPLAY=:0 xinput --list --name-only

in the terminal, I get:
Virtual core pointer
Virtual core XTEST pointer
MOSART Semi. 2.4G Keyboard Mouse Mouse
MOSART Semi. 2.4G Keyboard Mouse Consumer Control
ADS7846 Touchscreen
Virtual core keyboard
Virtual core XTEST keyboard
MOSART Semi. 2.4G Keyboard Mouse
MOSART Semi. 2.4G Keyboard Mouse System Control
MOSART Semi. 2.4G Keyboard Mouse Consumer Control

So I see, of course, one line regarding Touchscreen. Is that of any help?
If it would be more helpful for me to download from putty.org, let me know. Thanks!

Yes Putty is ssh, under a much more attractive front end…

The zynth don’t know the difference or indeed care.

You can also use the terminal option in webconf but I don’t think it will fly -X displays.

I’ve not looked at how the webconf terminal is implemented.

I forgot we had that in webconf. It is handy for the odd thing but it is rather flawed, e.g. the enviroment isn’t configured correctly so many things don’t work and the display does not scroll so you have to reset every few lines… but it will do for this testing.

  • Within webconf, navigate to Library->Captures
  • Click the “Upload” button and drag this file to upload area
    evdev.py (889 Bytes)
    and click “Upload” button
  • Navigate to the terminal
  • Enter this command: DISPLAY=:0 python3 /zynthian/zynthian-my-data/capture/evdev_test.py
  • Touch your touchscreen and report what is shown in the terminal

This will detect the activity of your touchscreen in the Linux evdev subsystem and give us a clue as to what is being detected. (I don’t think xinput is detecting it so we need to do some diagnostics).

After you have finished you could stop the diagnostics with Ctrl+c then remove the uploaded file with: rm /zynthian/zynthian-my-data/capture/evdev_test.py. (I suggested putting it in the captures folder because that is easy for you to do with the webconf.)

1 Like

Well I’m sorry to say, this is not working. I’ve tried a number of ways. I click and drag the file over, and it clearly appears in the upload window, I upload. But entering the command results No Such File or Directory. I even tried it with taking “_test” out of command, just because I figured I’d try, based on the file labeled as evdev.py.

root@zynthian://zynthian# DISPLAY=:0 python3 /zynthian/zynthian-my-data/capture/evdev_test.py
python3: can’t open file ‘/zynthian/zynthian-my-data/capture/evdev_test.py’: [Errno 2] No such file or directory
root@zynthian://zynthian# rm /zynthian/zynthian-my-data/capture/evdev_test.py
rm: cannot remove ‘/zynthian/zynthian-my-data/capture/evdev_test.py’: No such file or directory
root@zynthian://zynthian# rm /zynthian/zynthian-my-data/capture/evdev.py
Traceback (most recent call last):
File “/zynthian/zynthian-my-data/capture/evdev.py”, line 3, in
from evdev import InputDevice, ecodes
File “/home/pi/zynthian-my-data/capture/evdev.py”, line 3, in
from evdev import InputDevice, ecodes
ImportError: cannot import name ‘InputDevice’ from ‘evdev’ (/home/pi/zynthian-my-data/capture/evdev.py)

I can do this with Putty, or even Ubuntu, but I may need a little hand holding, because I’m not terribly familiar with connecting via SSH.
It seems we might be on opposite sides of the pond, so there may be some time lapse. Thanks!

Sorry! Something odd is happening with Discord where it keeps renaming the file as I upload it!!!

Looks like Discourse being clever! Try this one:

evdev_test.py (983 Bytes)

Well, this is what I get… but after entering command, it doesn’t wait for me to touch the screen. It automatically spits out this error.

root@zynthian://zynthian# DISPLAY=:0 python3 /zynthian/zynthian-my-data/capture/evdev_test.py
Traceback (most recent call last):
File “/zynthian/zynthian-my-data/capture/evdev_test.py”, line 5, in
from evdev import InputDevice, ecodes
File “/home/pi/zynthian-my-data/capture/evdev.py”, line 3, in
from evdev import InputDevice, ecodes
ImportError: cannot import name ‘InputDevice’ from ‘evdev’ (/home/pi/zynthian-my-data/capture/evdev.py)

You need to delete the old evdev.py file.

Ah, Sorry about that.

How’s this?

root@zynthian://zynthian# DISPLAY=:0 python3 /zynthian/zynthian-my-data/capture/evdev_test.py
Found evdev device: ‘ADS7846 Touchscreen’ at /dev/input/event5