LCD_DEVFUNC_READPIXEL and LCD_DEVFUNC_READMPIXELS not used

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

    • LCD_DEVFUNC_READPIXEL and LCD_DEVFUNC_READMPIXELS not used

      I'm trying to specify custom functions to read pixels using the LCD_SetDevFunc function, but this does not seem to work.
      I see the PortAPI specified function are always called, not my custom function.

      Relevant part of my LCDConf.c is below, is anything wrong with it?



      C Source Code

      1. #include "GUI.h"
      2. #include "GUIDRV_FlexColor.h"
      3. /* Physical display size */
      4. #define XSIZE_PHYS 320
      5. #define YSIZE_PHYS 240
      6. /*********************************************************************
      7. *
      8. * Configuration checking
      9. *
      10. **********************************************************************
      11. */
      12. #ifndef VXSIZE_PHYS
      13. #define VXSIZE_PHYS XSIZE_PHYS
      14. #endif
      15. #ifndef VYSIZE_PHYS
      16. #define VYSIZE_PHYS YSIZE_PHYS
      17. #endif
      18. #ifndef XSIZE_PHYS
      19. #error Physical X size of display is not defined!
      20. #endif
      21. #ifndef YSIZE_PHYS
      22. #error Physical Y size of display is not defined!
      23. #endif
      24. #ifndef GUICC_M565
      25. #error Color conversion not defined!
      26. #endif
      27. #ifndef GUIDRV_FLEXCOLOR
      28. #error No display driver defined!
      29. #endif
      30. /*********************************************************************
      31. *
      32. * Local functions
      33. *
      34. **********************************************************************
      35. */
      36. static U16 _ReadPixel(int LayerIndex) {
      37. GUI_USE_PARA(LayerIndex);
      38. U16 Data = LCD_IO_ReadData();
      39. return ((Data & 0xFF00) >> 8) | ((Data & 0x00FF) << 8);
      40. }
      41. static void _ReadMPixels(int LayerIndex, U16* pBuffer, U32 NumPixels) {
      42. for (int pixel = 0; pixel < NumPixels; ++pixel) {
      43. pBuffer[pixel] = _ReadPixel(LayerIndex);
      44. }
      45. }
      46. /*********************************************************************
      47. *
      48. * Public functions
      49. *
      50. **********************************************************************
      51. */
      52. /*********************************************************************
      53. *
      54. * LCD_X_Config
      55. *
      56. * Function description:
      57. * Called during the initialization process in order to set up the
      58. * display driver configuration.
      59. *
      60. */
      61. void LCD_X_Config(void)
      62. {
      63. GUI_DEVICE * pDevice;
      64. CONFIG_FLEXCOLOR Config = {0};
      65. GUI_PORT_API PortAPI = {0};
      66. /* Set display driver and color conversion */
      67. pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_M565, 0, 0);
      68. //make FlexColor orientation match BSP orientation
      69. Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;
      70. GUIDRV_FlexColor_Config(pDevice, &Config);
      71. /* Display driver configuration */
      72. LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);
      73. LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
      74. /* Set controller and operation mode */
      75. PortAPI.pfWrite16_A0 = LCD_IO_WriteReg;
      76. PortAPI.pfWrite16_A1 = LCD_IO_WriteData;
      77. PortAPI.pfWriteM16_A1 = LCD_IO_WriteMultipleData;
      78. PortAPI.pfReadM16_A1 = LCD_IO_ReadMultipleData;
      79. GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B16);
      80. /* Custom reading functions */
      81. LCD_SetDevFunc(0, LCD_DEVFUNC_READPIXEL, (void(*)(void))_ReadPixel);
      82. LCD_SetDevFunc(0, LCD_DEVFUNC_READMPIXELS, (void(*)(void))_ReadMPixels);
      83. }
      84. /*********************************************************************
      85. *
      86. * LCD_X_DisplayDriver
      87. *
      88. * Function description:
      89. * This function is called by the display driver for several purposes.
      90. * To support the according task the routine needs to be adapted to
      91. * the display controller. Please note that the commands marked with
      92. * 'optional' are not cogently required and should only be adapted if
      93. * the display controller supports these features.
      94. *
      95. * Parameter:
      96. * LayerIndex - Index of layer to be configured
      97. * Cmd - Please refer to the details in the switch statement below
      98. * pData - Pointer to a LCD_X_DATA structure
      99. *
      100. * Return Value:
      101. * < -1 - Error
      102. * -1 - Command not handled
      103. * 0 - Ok
      104. */
      105. int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
      106. int r;
      107. (void) LayerIndex;
      108. (void) pData;
      109. switch (Cmd) {
      110. case LCD_X_INITCONTROLLER: {
      111. BSP_LCD_Init();
      112. return 0;
      113. }
      114. default:
      115. r = -1;
      116. }
      117. return r;
      118. }
      119. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
      Display All
    • Hi,

      Unfortunately, I can not say why the functions are not getting called. On my end it is working.

      Which version of emWin are you using?
      The exact version can be found in GUI_Version.h.

      The possibility to set custom read functions was introduced with version 5.22 of emWin.
      But, I doubt that someone uses such an old version (at least I hope no one does).

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.