[SOLVED] Touchscreen x and y swapped over

Hi. I purchased a 3.6" touchscreen from eBay which came with no support and the vendor has nothing what so ever that will help.

Link to item here.

I have installed the UTFT library and works fine. UTFT here

I have now installed the UTOUCH library and example sketches which work to an extent, but for one strange problem. UTOUCH here

The controller for the screen (through the process of elimination I have worked out) is ILI9327.

The problem is that the x and y seem to be jumbled up. In landscape position, starting from the centre, moving left draws a line upwards and right downwards then up draws a line left and down goes right??

I have tried swapping some of the x and y values in the libraries and sketches but can't seem to get them to swap over. Any ideas anyone?

Many thanks, Steve.

Ok, so that answers that one I guess, but it would have been helpful to include the controller on your OTHER post related to this display!

Regarding your touch problem, first of all, have you ran the calibration sketch and edited your UTouchCD.h file? Subsequently, have you checked your calibration figures with Henning's checker? touch cal check

Did you read the manual which comes with UTouch? It clearly explains the distinction between LANDSCAPE and PORTRAIT based touch orientations.

Regards,

Graham

Edit: That's so funny! I just looked at the Ebay link for that display, even the demonstration video shows inverted colour......

Hi graham. I'm sorry, I was using a different controller number and when the x and y weren't working I went through the rest one by one and found one that came up with RGB rather than CMY.

I have tried changing the landscape and portrait strings in the sketch and it still don't change it.

I ran the calibration tool, changed the UTouchCD.h file and reloaded the draw sketch and it wouldn't sense the touch at all. :-/

Gonna do a few more landscape/portrait trials and I'll post results.

Cheers.

So... as standard configuration:

(direction drawn=direction displayed on screen)
down=right
up=left
left=up
right=down

With the following setup:

void setup()
{
  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.clrScr();

  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_MEDIUM);
}

Gives the same results as the first one

void setup()
{
  myGLCD.InitLCD(PORTRAIT);
  myGLCD.clrScr();

  myTouch.InitTouch(PORTRAIT);
  myTouch.setPrecision(PREC_MEDIUM);
}

The same again.

{
  myGLCD.InitLCD(PORTRAIT);
  myGLCD.clrScr();

  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_MEDIUM);
}

Same again but as expected off centre

Am about to try something....

Some of the cheaper 'foreign' displays which are not EXACTLY supported by Henning's libraries do exhibit stubborn issues which cannot be resolved easily, but you really should try to exhaust all of the 'easy' options first.

You say drawing left goes up and right goes down, this is definitely a 'LANDSCAPE/PORTRAIT' issue. Be aware, the 'Cal_S' figure contains an encoded version of X size, Y size and default touch orientation! Further more, between each change that YOU make, you need to close and restart the IDE to ensure the changes take effect.

Let me know if you are still struggling.

Regards,

Graham

All of these are looking at the display sideways (landscape)

void setup()
{
  myGLCD.InitLCD(PORTRAIT);
  myGLCD.clrScr();

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM);
}

Left=right
Right=left
up=up :smiley:
down=down :smiley:

void setup()
{
  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.clrScr();

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM);
}

left=up
right=down
up=left
down=right

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();

  myTouch.InitTouch(PORTRAIT);
  myTouch.setPrecision(PREC_MEDIUM);
}

left=left :smiley:
right=right :smiley:
up=down
down=up

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();

  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_MEDIUM);
}

left=up
right=down
up=left
down=right

NO…

Don’t explicitly set orientation of both, actually to start with, don’t explicitly set either.

What does this do?

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM);
}

Then what does this do?

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();

  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_MEDIUM);
}

Finally, what does this do?

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();

  myTouch.InitTouch(PORTRAIT);
  myTouch.setPrecision(PREC_MEDIUM);
}

Initialising BOTH as landscape and then BOTH as portrait should NOT come as any surprise the symptoms were identical ???

Top tip… Change only ONE thing at a time. :wink:

Regards,

Graham

Ok, so the best you can do then, is stick with PORTRAIT touch orientation, and software manage, the Y axis flip.

Let me get back to you on how best to do that.......

Regards,

Graham

Graham... DA DA DA... solved it. (I didn't expect that whilst watching Dickinsons Real Deal)

Firstly sorry I did try changing only one to portrait and then landscape of each but all with the same erroneous results.

I have just run the calibration sketch again and noticed that there is an orientation in that too (which I didn't see before). I flipped that to LANDSCAPE and ran the test. I put the results into the CAL checker that you linked too and I checked it on most of the screens that he has on there (as mine isn't exactly listed) and ALL of them said 'error, wrong orientation', etc.

Imagine my surprise as I upload it and glance away from the TV and prod the screen to find it it sport on perfect!!!!

Thanks for your pointers Graham... another 'solved' going in the title. :slight_smile:

On to trying to make more than one page now. Do you have any good tutorials or sites that come to your expert mind?

Steve

Well done!!

I know there are SOME screens that really do not work properly with UTFT, but most can be dealt with. Pleased you got it sorted :smiley: .

Am i right in thinking you want to control a fish tank or some other similar sort of project? :wink: :stuck_out_tongue:

Regards,

Graham

Yes Graham, its a marine reef tank and although I have already learned how to control my LED dimmers by means of PWM, I have seen people do amazing things with the touch screens and have full controls over pretty much all of it. I plan on making several pages including one for the lighting with some sort of display for how bright each array of LEDs are along with adjustability for each, a page for control of pumps and other electrical appliances (I have the four way mains voltage relay board for this) and plan on getting some sensors to trigger these. I plan on having temperature controlled fans for the LEDs too and to adapt an automatic feeder that I have.

I was going to try and control my power heads with it too but they already come with a nifty little controller so will probably leave it alone.

A lot of work and learning ahead but for what I need, I think the tricky stuff is almost sorted. Most will just be analogRead() and analogWrite() stuff.

Thanks for all your help. :smiley: