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?
Display All
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
- #include "GUI.h"
- #include "GUIDRV_FlexColor.h"
- /* Physical display size */
- #define XSIZE_PHYS 320
- #define YSIZE_PHYS 240
- /*********************************************************************
- *
- * Configuration checking
- *
- **********************************************************************
- */
- #ifndef VXSIZE_PHYS
- #define VXSIZE_PHYS XSIZE_PHYS
- #endif
- #ifndef VYSIZE_PHYS
- #define VYSIZE_PHYS YSIZE_PHYS
- #endif
- #ifndef XSIZE_PHYS
- #error Physical X size of display is not defined!
- #endif
- #ifndef YSIZE_PHYS
- #error Physical Y size of display is not defined!
- #endif
- #ifndef GUICC_M565
- #error Color conversion not defined!
- #endif
- #ifndef GUIDRV_FLEXCOLOR
- #error No display driver defined!
- #endif
- /*********************************************************************
- *
- * Local functions
- *
- **********************************************************************
- */
- static U16 _ReadPixel(int LayerIndex) {
- GUI_USE_PARA(LayerIndex);
- U16 Data = LCD_IO_ReadData();
- return ((Data & 0xFF00) >> 8) | ((Data & 0x00FF) << 8);
- }
- static void _ReadMPixels(int LayerIndex, U16* pBuffer, U32 NumPixels) {
- for (int pixel = 0; pixel < NumPixels; ++pixel) {
- pBuffer[pixel] = _ReadPixel(LayerIndex);
- }
- }
- /*********************************************************************
- *
- * Public functions
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * LCD_X_Config
- *
- * Function description:
- * Called during the initialization process in order to set up the
- * display driver configuration.
- *
- */
- void LCD_X_Config(void)
- {
- GUI_DEVICE * pDevice;
- CONFIG_FLEXCOLOR Config = {0};
- GUI_PORT_API PortAPI = {0};
- /* Set display driver and color conversion */
- pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_M565, 0, 0);
- //make FlexColor orientation match BSP orientation
- Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;
- GUIDRV_FlexColor_Config(pDevice, &Config);
- /* Display driver configuration */
- LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);
- LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
- /* Set controller and operation mode */
- PortAPI.pfWrite16_A0 = LCD_IO_WriteReg;
- PortAPI.pfWrite16_A1 = LCD_IO_WriteData;
- PortAPI.pfWriteM16_A1 = LCD_IO_WriteMultipleData;
- PortAPI.pfReadM16_A1 = LCD_IO_ReadMultipleData;
- GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B16);
- /* Custom reading functions */
- LCD_SetDevFunc(0, LCD_DEVFUNC_READPIXEL, (void(*)(void))_ReadPixel);
- LCD_SetDevFunc(0, LCD_DEVFUNC_READMPIXELS, (void(*)(void))_ReadMPixels);
- }
- /*********************************************************************
- *
- * LCD_X_DisplayDriver
- *
- * Function description:
- * This function is called by the display driver for several purposes.
- * To support the according task the routine needs to be adapted to
- * the display controller. Please note that the commands marked with
- * 'optional' are not cogently required and should only be adapted if
- * the display controller supports these features.
- *
- * Parameter:
- * LayerIndex - Index of layer to be configured
- * Cmd - Please refer to the details in the switch statement below
- * pData - Pointer to a LCD_X_DATA structure
- *
- * Return Value:
- * < -1 - Error
- * -1 - Command not handled
- * 0 - Ok
- */
- int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
- int r;
- (void) LayerIndex;
- (void) pData;
- switch (Cmd) {
- case LCD_X_INITCONTROLLER: {
- BSP_LCD_Init();
- return 0;
- }
- default:
- r = -1;
- }
- return r;
- }
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/