How to keep Display/Touch coordinates consistent when setting orientation?

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • How to keep Display/Touch coordinates consistent when setting orientation?

      Greetings,

      I am trying to understand how to use emWin's various *_SetOrientation API's. GUI_SetOrientation behaves as expected, however GUI_TOUCH_SetOrientation does not appear to do anything meaningful. Our display is mounted upside down in the product(viewing angle and connections were better this way), and as such we need to not only permanently rotate the graphics, but also reconfigure how the touch coordinates are interpreted by emWin. The manual also appears to contradict itself. In the paragraph, it leads me to believe I should not have to mirror my X and Y coordinates in the hardware layer. In the disclaimer, it mentions it has no effect on GUI_TOUCH_StoreState* or anything else. Well what in the world is this function even good for then? Am I to understand the only way I can get the touch coordinates flipped is to mirror them myself in the driver layer? I don't see how this could even be feasible in dynamic applications where the screen must be able to rotate. See below: (XSIZE_PHYS=800, YSIZE_PHYS=480) What do I need to do to not have to modify the way I pass in X and Y values into GUI_TOUCH_StoreState? Shouldn't GUI_TOUCH interpret those values based on the orientation passed into it?

      I'm using emWin 6.32b from NXP's emWin downloads for the LPC43XX series microcontrollers. Thank you for the help in advance.

      Edit: I had the wrong source code posted. I have updated it.

      C Source Code

      1. void LCD_X_Config(void)
      2. {
      3. #if (NUM_BUFFERS > 1)
      4. GUI_MULTIBUF_Config(NUM_BUFFERS);
      5. #endif
      6. GUI_DEVICE_CreateAndLink(GUIDRV_LIN_16, GUICC_M444_12, 0, 0);
      7. LCD_SetDevFunc(0, LCD_DEVFUNC_COPYBUFFER, (void (*)(void))BSP_LCD_CopyBuffer);
      8. LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS);
      9. LCD_SetVSizeEx(0, XSIZE_PHYS, YSIZE_PHYS);
      10. LCD_SetVRAMAddrEx(0, BSP_LCD_GetActiveBufferAddr());
      11. GUI_SetOrientation(GUI_ROTATION_180); // rotates the display as anticipated
      12. GUI_TOUCH_SetOrientation(GUI_ROTATION_180); // does nothing
      13. }
      Display All
      Images
      • Screenshot 2025-01-31 110218.png

        132.72 kB, 1,841×1,000, viewed 16 times

      The post was edited 1 time, last by brich1024 ().

    • New

      Hello,

      GUI_TOUCH_SetOrientation() is intended to be used with pure analog touchscreen without a controller connected to your MCU. In this case you should just pass some info for the analog touchscreen driver using dedicated APIs so emWin could calculate the conversion factors from ADC data into the touch coordinates.

      But if you are using a touch controller that is providing a digital data using dedicated bus, and you are calculating the coordinates and passing it directly using GUI_PID_StoreState()/GUI_TOUCH_StoreState(), then emWin just doesn’t know about the factors cause you are calculating it by yourself at your driver level. In this case, yes, you should use different factors depending on the screen orientation.
      Regards,

      Anthony

      The post was edited 1 time, last by cilmagemlu ().