aselectroworks / Arduino-FT6336U

FocalTech FT6336U (Self-Capacitive Touch Panel Controller) library for Arduino.
MIT License
38 stars 10 forks source link

How to Rotate the touch input? #3

Closed MikeyMoMo closed 2 years ago

MikeyMoMo commented 2 years ago

I am using a WT32-SC01 board. I have this working with TFT_eSPI library for display and your library for touch. I need to rotate the touch input to match the screen rotation. How may I do that? Still seems to be some minor issues but none that affect me at the moment. I just need X and Y of the touch. The current rotation is where the power connector is on the left of the WT32. I don't see any routine for rotation.

Thanks for the library!!

Mike

aselectroworks commented 2 years ago

Hi @MikeyMoMo Currently, this library does not support screen rotation. So you need to convert coordinates by yourself.

MikeyMoMo commented 2 years ago

I have been looking for a routine to do that instead of reinventing it myself. Do you know of any. I don't mind doing it but perfecting it seems a little difficult.

aselectroworks commented 2 years ago

I don't have a routine for you. I think you can refer to Rotation of axes article of wikipedia.

MikeyMoMo commented 2 years ago

Will read that. Thanks. I had searched a lot but not including axes. I really wish Bodmer to include this in his great library.

On Sun, Jun 19, 2022, 10:16 AM aselectroworks @.***> wrote:

I don't have a routine for you. I think you can refer to Rotation of axes https://en.wikipedia.org/wiki/Rotation_of_axes article of wikipedia.

— Reply to this email directly, view it on GitHub https://github.com/aselectroworks/Arduino-FT6336U/issues/3#issuecomment-1159601663, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYPSIMEFIMBVYEKZU5X66DVPZ7GHANCNFSM5ZE4TRXQ . You are receiving this because you were mentioned.Message ID: @.***>

MarcelRobitaille commented 1 year ago

@MikeyMoMo You can check out how the Adafruit GFX library does it: https://github.com/adafruit/Adafruit-GFX-Library/blob/master/Adafruit_GFX.cpp

switch (rotation) {
    case 1:
      t = x;
      x = WIDTH - 1 - y;
      y = t;
      break;
    case 2:
      x = WIDTH - 1 - x;
      y = HEIGHT - 1 - y;
      break;
    case 3:
      t = x;
      x = y;
      y = HEIGHT - 1 - t;
      break;
    }
MikeyMoMo commented 1 year ago

Sadly, the touch controller has quit working on the unit I wanted to rotate but this is good information to keep on hand. Thank you for this. It might come in handy in the future.

The articles I had read on this went into some complex math explanations but it seems to be so easy with this code. I appreciate your response.

On Wed, Mar 1, 2023, 12:40 AM Marcel Robitaille @.***> wrote:

@MikeyMoMo https://github.com/MikeyMoMo You can check out how the Adafruit GFX library does it: https://github.com/adafruit/Adafruit-GFX-Library/blob/master/Adafruit_GFX.cpp

switch (rotation) { case 1: t = x; x = WIDTH - 1 - y; y = t; break; case 2: x = WIDTH - 1 - x; y = HEIGHT - 1 - y; break; case 3: t = x; x = y; y = HEIGHT - 1 - t; break; }

— Reply to this email directly, view it on GitHub https://github.com/aselectroworks/Arduino-FT6336U/issues/3#issuecomment-1448499821, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYPSIMAGNHODGWD6KRVGFLWZYTAPANCNFSM5ZE4TRXQ . You are receiving this because you were mentioned.Message ID: @.***>