touch screen X Y axis inverted ?!?

3,375 views
Skip to first unread message

Georges

unread,
Nov 14, 2009, 10:29:48 PM11/14/09
to Beagle Board
Hi everybody,

working on a flash application interface, loaded by gnash-fb, on a LCD
panel of 800x480 in framebuffer mode, I have something strane with the
touchscreen :

after calibrating the TSLib with ts_calibrate, I have something good
with ts_test :

-------------------------------------------------------------------------
| 20,28 780,28 |
|
|
|
|
|
|
|
|
|
|
|
|
| 18,467 777,462 |
--------------------------------------------------------------------------

then I made a small swf flash file in 800x480 resolution with 2 black
squares, one in the top left corner at one fifth in X and Y (like
Gnash doc explain : http://gnashdev.org/doc/html/fb_calibration.html
), and another black square in the opposit corner (down right).
In this flash application, I print in the middle the coordinate of a
onMouseDown.

So I launch this appli with gnash and DUMP_RAW=1 to calibrate the
gnash touch screen.
Clicking on the 2 squares, I note the calibration value :
TSCALIB=450,1620,1678,440

Then I export this new variable : TSCALIB and load again my flash
appli to check the text in the middle (coordinate of the mouse on a
onMouseDown) by pressing on the 4 corners (like above with ts_test).

the result is strange :

-------------------------------------------------------------------------
| 40,11 42,468 |
|
|
|
|
|
|
|
|
|
|
|
|
| 731,24 712,466 |
--------------------------------------------------------------------------

I thinks the X and Y axis are inverted somewhere, but where ?

Looking at the TSCALIB variable :
- pressing in the top/left corner and have a value of 450,1620
- pressing in the down/right corner and have value of 1678,440
make me things that
- the origin for gnash is in the top/right corner
- the X axis is vertical going down
- the Y axis is horizontal going left

but in the TSLIB (ts_test) it is :
- the origin is in the top/left corner
- the X axis is horizontal going right
- the Y axis is vertical going down

and then in the gnash application the coordinate of the mouse is
something between :
- origin is top/left corner (like TSLIB)
- the X axis is vertical and going down (like TSCALIB)
- the Y axis is horizontal and going right (like itself !!!)


What a mess !!!

Does somebody have an idea ?

Georges

Georges

unread,
Nov 17, 2009, 12:15:27 AM11/17/09
to Beagle Board
Hello,

nobody has idea about this tricky issue ?

I am still searching for the problem, but get stuck...

Please help,

Georges

PJE

unread,
Nov 17, 2009, 6:38:04 AM11/17/09
to Beagle Board
Hi Georges,

Have you tried flipping the touchscreen connection over?

A lot of touch screen connectors can take the flexible cable in both
orientations - It may put a twist in the cable, but may fix the X/Y
switching issue.

Regards,

PJE

Georges

unread,
Nov 29, 2009, 7:12:16 AM11/29/09
to Beagle Board
Hi PJE,

thanks for your help.

To answer your proposal, the flat cable as contact only on one side,
so impossible to invert it.

And the point is that the TS work great under TSLIB (with ts_test for
exemple)...

I think it is a bug of gnash on certain calibrations of the TS.

So I decided to add the TSLIB patch to Gnash that Nico Coesel did for
gnash-0.8.2 : http://savannah.gnu.org/patch/?6490

So I managed to modify the 2 patch files so they fit with gnash-0.8.5
source as I compile gnash-fb in OE.

Then I modified recipes/gnash/gnash-fb_0.8.5.bb to add tslib in the
dependencies.

During the compile of gnash-fb (bitbake):
- the depency to tslib compile tslib_1.0.bb as wanted
- the do_patch works great
- the do_compile fail after the compilation of fb.cpp when the linker
don't find functions such as ts_close() (specific functions of
tslib) : "undefined reference of ts_close()"

When looking at the linker command line in the log (tmp/work/armv7a-
angstrom-linux-gnueabi/gnash-fb-0.8.5-r6/temp/log.do_compile.2625)
link all needed libraries like tmp/staging/armv7a-angstrom-linux-
gnueabi/usr/lib/libXau.so and many other but not libts.so !!!

I tried many many times to add it, but cannot find the solution.

Does somebody know how to force the link of this library ?

It seems adding "tslib" to the DEPEND += "lib1 lib2" of the .bb file
is not enough, but I cannot find where to fix this issue.

Thanks for any help on this bitbake tricks.

Georges

Kees Jongenburger

unread,
Nov 29, 2009, 2:32:43 PM11/29/09
to beagl...@googlegroups.com
Hi,


On Sun, Nov 15, 2009 at 4:29 AM, Georges <moque...@gmail.com> wrote:
Hi everybody,

working on a flash application interface, loaded by gnash-fb, on a LCD
panel of 800x480 in framebuffer mode, I have something strane with the
touchscreen :

after calibrating the TSLib with ts_calibrate, I have something good
with ts_test :

then I made a small swf flash file in 800x480 resolution with 2 black
squares, one in the top left corner at one fifth in X and Y (like
Gnash doc explain : http://gnashdev.org/doc/html/fb_calibration.html
), and another black square in the opposit corner (down right).
In this flash application, I print in the middle the coordinate of a
onMouseDown.

From the link on that page it looks like gnash simply doesn't have support for tslib. Therefore it's not that strange
that the tslib callibration doesn't apply on your fbdev enabled gnash so gnash is most probably just opening /dev/input/something
and need it's own calibration

Greetings.
 

Georges

unread,
Nov 30, 2009, 2:52:35 AM11/30/09
to Beagle Board
Hi Kees,

you are right, Gnash calibration is just different as TSLIB
calibration :
Gnash use 2 points
and
TSLIB use 5 points

The problem is that using 2 points is not enough :
http://www.embedded.com/story/OEG20020529S0046
3 points is a minimum...

I didn't managed to add TSLIB to gnash (linker problem see below), so
I modified the built in TS calibration in Gnash to use the 3 points
methode decribed above.

Here is the patch if somebody else need it (work fine for me) :

---------------begin fb.cpp.ts3points.patch----------------------
--- gnash-0.8.5/gui/fb.cpp.orig 2008-02-19 20:20:49.000000000 +0100
+++ gnash-0.8.5/gui/fb.cpp 2008-04-11 09:58:08.000000000 +0200
@@ -1045,24 +1045,24 @@
void FBGui::apply_ts_calibration(float* cx, float* cy, int rawx, int
rawy) {

/*
- <UdoG>:
- This is a *very* simple method to translate raw touchscreen
coordinates to
- the screen coordinates. We simply to linear interpolation between
two points.
- Note this won't work well when the touchscreen is not perfectly
aligned to
- the screen (ie. slightly rotated). Standard touchscreen calibration
uses
- 5 calibration points (or even 25). If someone can give me the
formula, tell
- me! I'm too lazy right now to do the math myself... ;)
-
- And sorry for the quick-and-dirty implementation! I'm in a hurry...
+ <GeorgesP>:
+ This method use 3 points calibration
+ it is described in http://www.embedded.com/story/OEG20020529S0046
*/
-
- float ref1x = m_stage_width / 5 * 1;
+
+ float k,a,b,c,d,e,f;
+
+ float ref0x = m_stage_width / 5 * 1;
+ float ref0y = m_stage_height / 5 * 1;
+ float ref1x = m_stage_width / 5 * 4;
float ref1y = m_stage_height / 5 * 1;
float ref2x = m_stage_width / 5 * 4;
float ref2y = m_stage_height / 5 * 4;

- static float cal1x = 2048/5*1; // very approximative default
values
- static float cal1y = 2048/5*4;
+ static float cal0x = 2048/5*1; // very approximative default
values
+ static float cal0y = 2048/5*4;
+ static float cal1x = 2048/5*1;
+ static float cal1y = 2048/5*1;
static float cal2x = 2048/5*4;
static float cal2y = 2048/5*1;

@@ -1075,7 +1075,7 @@
if (settings) {

// expected format:
- // 491,1635,1581,646 (cal1x,cal1y,cal2x,cal2y; all
integers)
+ // 491,1635,451,537,1581,646
(cal0x,cal0y,cal1x,cal1y,cal2x,cal2y; all integers)

char buffer[1024];
char* p1;
@@ -1086,6 +1086,20 @@
p1 = buffer;

do {
+ // cal0x
+ p2 = strchr(p1, ',');
+ if (!p2) continue; // stop here
+ *p2 = 0;
+ cal0x = atoi(p1);
+ p1=p2+1;
+
+ // cal0y
+ p2 = strchr(p1, ',');
+ if (!p2) continue; // stop here
+ *p2 = 0;
+ cal0y = atoi(p1);
+ p1=p2+1;
+
// cal1x
p2 = strchr(p1, ',');
if (!p2) continue; // stop here
@@ -1117,8 +1131,8 @@
if (!ok)
log_debug(_("WARNING: Error parsing calibration data!"));

- log_debug(_("Using touchscreen calibration data: %.0f / %.0f /
%.0f / %.0f"),
- cal1x, cal1y, cal2x, cal2y);
+ log_debug(_("Using touchscreen calibration data: %.0f / %.0f /
%.0f / %.0f / %.0f / %.0f"),
+ cal0x, cal0y, cal1x, cal1y, cal2x, cal2y);

} else {
log_debug(_("WARNING: No touchscreen calibration settings
found. "
@@ -1128,10 +1142,18 @@

} //!initialized

+ // calcul of K, A, B, C, D, E and F
+ k = (cal0x - cal2x) * (cal1y - cal2y) - (cal1x - cal2x) * (cal0y -
cal2y);
+ a = ((ref0x - ref2x) * (cal1y - cal2y) - (ref1x - ref2x) * (cal0y -
cal2y)) / k;
+ b = ((ref1x - ref2x) * (cal0x - cal2x) - (ref0x - ref2x) * (cal1x -
cal2x)) / k;
+ c = (cal0y * (cal2x * ref1x - cal1x * ref2x) + cal1y * (cal0x *
ref2x - cal2x * ref0x) + cal2y * (cal1x * ref0x - cal0x * ref1x)) / k;
+ d = ((ref0y - ref2y) * (cal1y - cal2y) - (ref1y - ref2y) * (cal0y -
cal2y)) / k;
+ e = ((ref1y - ref2y) * (cal0x - cal2x) - (ref0y - ref2y) * (cal1x -
cal2x)) / k;
+ f = (cal0y * (cal2x * ref1y - cal1x * ref2y) + cal1y * (cal0x *
ref2y - cal2x * ref0y) + cal2y * (cal1x * ref0y - cal0x * ref1y)) / k;

// real duty:
- *cx = (rawx-cal1x) / (cal2x-cal1x) * (ref2x-ref1x) + ref1x;
- *cy = (rawy-cal1y) / (cal2y-cal1y) * (ref2y-ref1y) + ref1y;
+ *cx = a * rawx + b * rawy + c;
+ *cy = d * rawx + e * rawy + f;
}

void FBGui::check_mouse()
---------------end fb.cpp.ts3points.patch----------------------

Georges

On 30 nov, 03:32, Kees Jongenburger <kees.jongenbur...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages