ImpulseAdventure / GUIslice-Builder

Cross-platform drag & drop GUI builder for GUIslice
Other
167 stars 35 forks source link

How to calibrate the touch screen with rpi display and esp32? #244

Closed dmyv closed 11 months ago

dmyv commented 1 year ago

Good morning, I am using a rpi displays ILI9486 480x320 touch screen with. xt2096 touch controller I have used the pins

define TOUCH_CS 18

define TFT_MISO 2

define TFT_MOSI 12

define TFT_SCLK 14

define TFT_CS 5

define TFT_DC 15

define TFT_RST 13

and it works, I did the calibration methods, and it works well, the screen displays well, and where I should click there is no problem, the problem happens when I put together the guide, I send it, I have the touch assignment left upside down and there is no way to turn the screen Touch assignment I have tried rotating the screen, but when I rotate it to 6 it stays in mirror mode and the touch has just been configured, but everything remains unchanged, is there any way to rotate the touch? from your code use arduino ide I want to thank you for the wonderful program, thank you very much, sorry for my English, use a translator.

Pconti31 commented 1 year ago

@dmyv Well, this is more of an issue for @ImpulseAdventure Calvin since its a library issue. If you are using PaulStoffregen/XPT2046_Touchscreen I believe ts.setRotation(n) only supports 0-3 not 6. If youu use the Builder inside E_PROJECT_OPTIONS tab at the bottom of the Property View you can set rotation property: Screen Rotation [0-3 or -1 default] Paul--

dmyv commented 1 year ago

@Pconti31 Thank you very much for taking the time to answer, it is greatly appreciated, I use the tft_espi library, in the screen calibration and all the other tft_espi examples, when I generate the gui and pass it the touch does not stay in mirror mode, and it does not Is there a way to move the touch rotation, I can only rotate the screen

Pconti31 commented 1 year ago

@dmyv Try these changes

GUIslice source code GUIslice_drv_tft_espi.cpp

beginning line 1939 comment out nRawX = 4095-p.y; and add nRawX = p.y;

  // ----------------------------------------------------------------
  #elif defined(DRV_TOUCH_XPT2046_PS)
    uint16_t  nRawX,nRawY; //XPT2046 returns values up to 4095
    uint16_t  nRawPress;   //XPT2046 returns values up to 4095

    TS_Point p = m_touch.getPoint();

    if ((p.z > pGui->nTouchCalPressMin) && (p.z < pGui->nTouchCalPressMax)) {
      // PaulStoffregen/XPT2046 appears to use a different orientation
      // than other libraries. Therefore, we will remap it here
      // to match the default portrait orientation.
      //nRawX = 4095-p.y; let XPT2046 library deal with rotation - paul conti
      nRawX = p.y;
      nRawY = p.x;

      nRawPress = p.z;
      m_nLastRawX = nRawX;
      m_nLastRawY = nRawY;
      m_nLastRawPress = nRawPress;
      m_bLastTouched = true;
      bValid = true;
    }
    else {

then change line 1656 from // m_touch.setRotation(0);

  #elif defined(DRV_TOUCH_XPT2046_PS)
    m_touch.begin();
    // Since this XPT2046 library supports "touch rotation", and defaults
    // to landscape orientation, rotate to traditional portrait orientation
    // for consistency with other handlers.
    //
    // Unfortunately, this API (from 2018/01/04) is not available in the
     // latest tagged release of XPT2046 in the Library Manager. Therefore,making 0 whatever rotation you want from 0 to 3
    // we can't use this API and instead need to hardcode the mapping
    // during the DrvGetTouch() function.
     m_touch.setRotation(1); // <== make 1 whatever rotation you want from 0 to 3 paul conti
    return true;

If that doesn't fix things I'm afraid I'm at a lost. Post in the GUIslice issues for Calvin's help (although he doesn't seem to answer very often). Paul--

dmyv commented 1 year ago

Thank you @Pconti31 , when I get home I will try it, thank you very much for the help, it is greatly appreciated

dmyv commented 1 year ago

https://github.com/ImpulseAdventure/GUIslice-Builder/assets/44035162/30a55313-656a-41b2-82e3-968724a112e6

dmyv commented 1 year ago

I sent you a video for you to see

dmyv commented 1 year ago

https://github.com/ImpulseAdventure/GUIslice-Builder/assets/44035162/cf7dbd27-92a1-46f6-87cb-b439dd081690

dmyv commented 1 year ago

With this configuration "gslc_GuiRotate(&m_gui, 5);" this is how the screen looks like

dmyv commented 1 year ago

1696372479022

dmyv commented 1 year ago

In the last photo, the touch works well, but I have the words backwards, I hope the video and photo can help you, thank you very much

dmyv commented 1 year ago

I need to comment @Pconti31 that what you said to do didn't work for me.

Pconti31 commented 12 months ago

@dmyv Sorry, but I have no idea how to fix the mirror text. Does the same thing happen when you use just TFT-eSPI example TFT_eSPI\examples\Smooth Fonts\SPIFFS\Print_Smooth_Font when you modify it to use your font rotate the display using 5? By the way, I think you should only use the values 0,1,2,3 for rotate according to the ILI9486 data sheet. Paul--

dmyv commented 12 months ago

Hello @Pconti31 , thanks for answering . What it showed was first the screen and the touch was in another direction, the second was where it recognizes the touch that the reflected text shows and there is the touch location, that is, it recognizes it in that location only on the touch with respect to the TFT_eSPI\ examples\Smooth Fonts\SPIFFS\Print_Smooth_Font I tried it, the screen was blank and the serial monitor gave me this result "Initialization done.

SPIFFS files found: Listing directory: / TouchCalData2 14 bytes calibrationData 14 bytes

Font file Final-Frontier-28 not found!" It's a shame I wanted to take my screen to 3.5inch, I did all the tests with 2.8" ILI9341 and the truth is that the performance of the screen was of another level, very good and when I switched to this rpi display 3.5 inch screen, I got these problems thanks for the answer @Pconti31 and have a good day

Pconti31 commented 12 months ago

@dmyv Your error is caused by not loading TFT_eSPI\examples\Smooth Fonts\SPIFFS\Print_Smooth_Font\data\Final-Frontier-28.vlw into SPIFFS. It is only finding two files. What font are you using that is creating the mirror images? Paul--

dmyv commented 11 months ago

Hello, @Pconti31 , what I did was start from 0. I first made sure that the tft_espi was correctly configured, then I went to guislice and I went to the configurations, I checked, that everything is fine and then I went to the guislicer examples and just when I took the touch, I was up and running. thank you very much for helping me, for your willingness