Hi, before writing here, i tried and struggled alot by myself, and gived up leaving portrait orientation on a similar aptofun touchscreen but 3.5". It’s a very cheap model on amazon. in portrait mode lcd has a really ugly visibility -_- … tried calibration procedure, tried everything, but when rotating to landscape, touch axes are always wrong (at least one of them) . Is there something i’m missing ? before cutting a Novation Impulse (yes, i’m planning to emulate @Micki 's project, it’s loveable), would prefer to do it in landscape mode…
any suggestions?
cheers
This issue has plagued many of us. There are a bunch of forum posts about it https://discourse.zynthian.org/search?q=x%20axis
And there doesn’t appear to be a single solution. Best advice I can offer is to read through these posts. Perhaps one post may help you solve your issue.
You can also try this: https://raspberrypi.stackexchange.com/questions/61053/tft-lcd-3-5-display-with-inverted-axis
The issue appears to be related to the fact that the tft xy axis is on a different layer than the display. Rotating the display (that’s the easy part) only will not work. The tft layer also has to be rotated. That’s where the TransformMatrix option in the 99-calibration.conf file needs to be set correctly. I’ve seen several different settings, depending on the given setup. I know I’m a few days early, but May the Fourth be with you!
My working notes Joy It 3.2 (Waveshare clone) display not working its messy and I tend to do it with command line parameters.
But since that mess I get it up and going ( admittedly with an inverted left/right
I have a small script touch.sh which sets it up after it’s all going.
It’s about the default settings for X but I’ve never got that fully understood.
Presumably the .99 files are read in order and this is just a sneaky way of installing a default, but presumably the zynths cut that off at the path somewhere back down the pipeline.
Ah ah !! Excellent…!!
Just watch it, there’s no shortage of Battlements you know!
thanks guys, i will let you know soon (i hope)
Is this showing an offset of coordinates? I’m having the same problem with official PiScreen 3.5 V2 and just replied to another (old) post asking for advice.
There is a small offset which seems gain related (particularly prevelant at the edges but I haven’t tried to do anything about it)
It depends on the exact size and position of the veruca at the tip of your finger…
Ok… sorry… I’m ashamed… I swear I am…
(<<liar)
Did you find this comment relevant ? [ ] yes [ ] no
well you can see the effect in the after photo above
Certainly for the new step sequencer the scale mismatch / offset is a bit annoying when setting or removing notes on a small grid with the stylus. It helps to have the cursor displayed though.
The transformation matrix values are floats so you should be able to compensate for a linear response.
Alright, I’ll fiddle around with the values later and come back with a result.
Edit: I think I first need to understand what’s going on under the hood, X11, 99-calibration.conf etc. Simply changing the numbers in the matrix in /zynthian/zynthian-sys/custom/display/PiScreen 3.5 (v2)/config/zynthian_custom_config.sh
didn’t have any effect (not even flipping the axes) so need to look elsewhere.
I just submitted a feature request for that :
In case you want to add some additionnal interesting inputs in the conversation.
If it helps any, this is what I do to get those screens working.
In the Zynthian Menu, add it as a Piscreen 3.5 (V2)
Open this file.
/zynthian/config/zynthian_custom_config.sh
And add this line to fix the screen issue.
DISPLAY=:0 xinput --set-prop ‘ADS7846 Touchscreen’ ‘Coordinate Transformation Matrix’ 1 0 0 0 -1 1 0 0 1
Reboot.
Hi @Tubbritt, thanks for the reference to this second zynthian_custom_config.sh
. Making changes there do actually affect the touch behaviour, as opposed to the file with the same name in /zynthian/zynthian-sys/custom/display/PiScreen 3.5 (v2)/config/
.
At least now we know where to attack .
For me, the matrix to start with is -1 0 1 0 -1 1 0 0 1. (x and y axes have correct orientation). When I do 1 0 0 0 -1 1 0 0 1 it results in a flipped x axis.
It’s just about picking the right values. As @wyleu pointed out these values are floats. According to my gut feeling the result should look something like -a1 0 a3 0 -b2 b3 0 0 1 with the constants around 1 ± something.
BTW, reboot is actually not necessary.
systemctl restart zynthian
is quicker and keeps you logged in via ssh. For all who want to give it a try.
Hi,
it is no so easy to see what is binary structure (exponent, significant field, sign, …) within these matrix values. So, it is not so intuitive to understand that these value are close to 1 ± something.
Could you elaborate ?
Hi, well, it’s just my gut feeling that comes from being a physicist
Let me just briefly explain. It’s about so called affine projections (you can google it) which are used to map a point or rather a vector (which defines that point by two coordinate numbers in space, i.e. in x-y-plane) to a new position.
Now, these 9 numbers which are written in a single row in the config file, actually make up a matrix which connects the output vector (new point, the point where we want the touch point to be) with the input vector (original point, the point where touch is recorded now) by means of matrix multiplication which in turn is composed of matrices for offset (translation), rotation and scaling. We need scaling and offset here.
In our special case, and according to the nomenclature given here https://wiki.archlinux.org/index.php/Calibrating_Touchscreen we can actually assign a meaning to these numbers.
We have the matrix
[ c0 0 c1 ]
[ 0 c2 c3 ]
[ 0 0 1 ]
which is equivalent to c0 0 c1 0 c2 c3 0 0 1
in our config file
where
- c0 defines scale factor along x (horizontal) axis,
- c2 defines scale factor along y (vertical) axis,
- c1 defines x offset
- c3 defines y offset.
All these numbers are defined relative to total width and total height according to the above link and this is why the new numbers should be close to 1. For example, introducing an offset to the right by 10 % of the total width (and c1 = 1) would result in the new c1 being 1.1. The nice thing about these matrix operations is that they do not only affect a single point in the x-y plane but all points that are thrown at it. You have to imagine it like pushing a sheet of paper around on a table (i.e. offset, translation), or like pulling on a stretchy piece of cloth on one end while the other end is fixed (i.e. scaling).
Just one remark about the minus signs - they come from the matrix operations for flipping and rotating the axes. As they appear in steps of 90 degrees these numbers are 1 or -1 or 0. It comes from the sin or cos function of the angle of rotation which yields 1, 0, -1 at multiples of 90 degrees but could also give any number inbetween at other angles. Which we don’t want
Now the only thing I’m uncertain about is, where is actually the corner (0,0).
Is it centered at (screen_witdh / 2, screen_height/2) or is it at screen pixel (0,0) (would that be upper left corner?) or does it have it’s own reference frame…
Thank you, it is very clear and it works.
“bash zynthian_custom_config.sh” allows testing values without restarting the UI.
Then trial and error can be done in the " * 5.7.1 XY-Controller" mode.
My only concern now is that zynthian_custom_config.sh doesn’t seem to be executed during boot sequence. Any clue ? Edit : If I go to webconf/hw-display and save then the change becomes permanent.
hi guys…
After several tryouts and possible solutions, today misteriously worked this combination, mixing some random solutions here reported:
choosing waveshare 4A GPIO only and using this string:
dtoverlay=waveshare35a:rotate=90
display_rotate=1
My chinese display finally got right touch coordinates
For those who ask for lcd type:
actually could be one of thousands clone lcd of whatever kind or type
it’s really a weird condition