ImpulseAdventure / Waveshare_ILI9486

Arduino library for Waveshare ILI9486 supporting the Waveshare 3.5" & 4" TFT Touch Shields for Arduino. Includes GFX-compatible API and touchscreen driver
MIT License
66 stars 8 forks source link

WaveshareTouchScreen::normalizeTsPoint( TSPoint &p, uint8_t rotation) #13

Open tdoan95 opened 2 years ago

tdoan95 commented 2 years ago

The normalizeTsPoint-function is not working properly.

InTouchTest.ino I always wondered why you have to change back to "Waveshield.setRotation(0);" Turns out the coordinates wouldn't fit if left at "Waveshield.setRotation(1);"

So the TouchTest.ino only works if you set your text horizontally at rotation = 1 and to draw you set back rotation = 0

And ONLY then it will work like this. Like you can't set rotation = 0, write vertical and then change to rotation = 1 to draw. The fillCircle-dots will be off-set and mirrored.

After some troubleshooting I found out normalizeTsPoint-function is the culprit. Please correct me if I'm wrong, I'm still learning. I changed the last part of the function to this:

int16_t t; switch (rotation) { case 0: break;

case 1: t = p.y; p.y = LCD_WIDTH - 1 - p.x; p.x = t; break;

case 2: p.y = LCD_HEIGHT - 1 - p.y; p.x = LCD_WIDTH - 1 - p.x; break;

case 3: t = p.y; p.y = p.x; p.x = LCD_HEIGHT - 1 - t; break; }

This solved the problem for me but I'm not sure if it is really solved or just superficial solved.

MikeTosen commented 1 year ago

Fantastic - I can confirm - this solved the problem.

Thanks for posting this, saved me allot of headaches