Utouch.cpp LCD issue

I’m using your UTOUCH library and I have some strange probs here.

My actual configuration:
Linux + Eclipse with arduino plugin (works great!).
Ardino DUE + CTE 1.04 compatible free flying copper wiring + CTE 480x272 touch display with XPT2046 touch screen controller.
orientation = LANDSCAPE

The raw datas from the calibration routine:

touch_x_left = (CAL_X>>14) & 0x3FFF;
touch_x_right = CAL_X & 0x3FFF;
touch_y_top = (CAL_Y>>14) & 0x3FFF;
touch_y_bottom = CAL_Y & 0x3FFF;

come up with:
touch_x_left = 3976 decimal
touch_x_right = 82 decimal
touch_y_top = 3689 decimal
touch_y_bottom = 434 decimal

This sounds reasonable, at least the X-values.

  1. Now, wenn I use UTouch_ButtonTest the alignment of the ‘touch-button’ and ‘LCD-button’ pad is completely wrong. It seems not even the landscape vs. portrait orientation is wrong but also the mathematical model which brings the y-values of the y-axis is mirror-inverted.
  2. Also the math machine for the statistical evaluation for valid values seem to be the result of some trial-and-error research:
unsigned long minx=99999, maxx=0;
unsigned long miny=99999, maxy=0;

Why this huge values? we only have 12 bit = 0…4095

  1. There is actually no busy check of the controller at all since there is no copper tracing on the pcb.
    Nor at least a short period of time for updating the touch controller - this device is very slow with only 125kHz clock speed!

void UTouch::read()
I found:

if (!rbi(P_IRQ, B_IRQ))
  touch_WriteData(0x90);        // 1001 0000 ok
  pulse_high(P_CLK, B_CLK);

  if (!rbi(P_IRQ, B_IRQ))  // No IRQ, no update of temp_y. EVIL!
   touch_WriteData(0xD0);  // 1101 0000 ok
   pulse_high(P_CLK, B_CLK);

What if the IRQ comes AFTER the polling??? The SAM3X tears of the runway with warp speed at 84MHz!
All this things puzzle me.
So did anyone had similar probs with UTouch?


I think I have found the prob. Maybe it came from the compiler settings in the IDE wich throw abt 50 warnings like: Member '__p1' was not initialized in this constructor Very strange. Anyway, it works now.

BUT: The touch controller give me a lot of computed outliers. Using the UTouch_QuickDraw example sometimes XY calculations are more then 100pixel away.

I then tested another LCD which resulted in the same poor results. Some coordinates simply splash away.

Any workarounds?