9 Replies Latest reply on Mar 21, 2020 12:16 AM by DheerajK_81

    Override Generated Code for emWin LCD Driver GraphicsLCDIntf PDL component

    CaKu_4284131

      I'm using PSoC Creator, and in Build Settings, Peripheral Driver Library, Graphics, emWin, I have selected Core, OSnTS, and LCD Driver, GraphicLCDCtrl. Unfortunately, the automatically generated code in Generated_Source\PSoC6\pdl\middleware\emWin\code\drivers\Control\GUIDRV_Control.c doesn't work for me; I need to implement my own _SetPixelIndex() and _GetPixelIndex(), as described in 33.7.26 GUIDRV_Template - Template for a new driver, "Adapting the template driver," in emWin User Guide & Reference Manual.

       

      My question: how can I keep my version of GUIDRV_Control.c from being overwritten each time I Generate Application? Can I make my own protected copy and tell the compiler to use that instead of the one in Generated_Source when I build my application?

        • 1. Re: Override Generated Code for emWin LCD Driver GraphicLCDCtrl PDL component
          DheerajK_81

          Please note that the section "GUIDRV_Template - Template for a new driver" has already been implemented for you. The file "GUIDRV_Control.c" is a Cypress custom driver for GraphicLCDCtrl Component. All the functions shown below which are required have already been defined.

          const GUI_DEVICE_API GUIDRV_Template_API = {
            //
            // Data
            //
            DEVICE_CLASS_DRIVER,
            //
            // Drawing functions
            //
            _DrawBitmap,
            _DrawHLine,
            _DrawVLine,
            _FillRect,
            _GetPixelIndex,
            _SetPixelIndex,
            _XorPixel,
            //
            // Set origin
            //
            _SetOrg,
            //
            // Request information
            //
            _GetDevFunc,
            _GetDevProp,
            _GetDevData,
            _GetRect,
          };
          

           

          No modifications are required to this file. In "LCDConf.c", you can perform some operations specific to your display additionally for different callbacks inside the function "LCD_X_DisplayDriver()". For example, in the callback LCD_X_INITCONTROLLER you can perform the initialization sequence required for your LCD.

           

          For different callbacks, please refer the section "33.6.1 Commands passed to the callback function".

           

          PS: Note that you can skip code generation using Build Settings > Code Generation > Skip Code Generation > True

           

          Regards,

          Dheeraj

          • 2. Re: Override Generated Code for emWin LCD Driver GraphicLCDCtrl PDL component
            CaKu_4284131

            DheerajK_81 wrote:

             

            Please note that the section "GUIDRV_Template - Template for a new driver" has already been implemented for you. The file "GUIDRV_Control.c" is a Cypress custom driver for GraphicLCDCtrl Component. All the functions shown below which are required have already been defined.

            Yes, but GUIDRV_Template is a "Driver template" that "Can be used as a starting point for writing a new driver." The starting point is not sufficient for my needs. I'm following these directions: "To adapt the driver to a currently not supported display controller you only have to adapt the routines _SetPixelIndex() and _GetPixelIndex()." [1] I'm trying to adapt those routines in a way that doesn't get wiped out every time I Generate Application.

             

            No modifications are required to this file.

            How can I "adapt the routines _SetPixelIndex() and _GetPixelIndex()" without modifying this file?

             

            In "LCDConf.c", you can perform some operations specific to your display additionally for different callbacks inside the function "LCD_X_DisplayDriver()". For example, in the callback LCD_X_INITCONTROLLER you can perform the initialization sequence required for your LCD.

            Yes, I am doing that for initialization.

            For different callbacks, please refer the section "33.6.1 Commands passed to the callback function".

            PS: Note that you can skip code generation using Build Settings > Code Generation > Skip Code Generation > True.

            Yes, but my TopDesign is not yet frozen and I do need to generate code from time to time.

            Regards,

            Dheeraj

            Thanks, Dheeraj.

             

            [1] UM03001 User Guide & Reference Manual for emWin V5.48, https://www.segger.com/downloads/emwin/UM03001

            • 3. Re: Override Generated Code for emWin LCD Driver GraphicLCDCtrl PDL component
              DheerajK_81

              The GUIDRV_Template is something we provide to be work with GraphicsLCDCtrl component. If you want to implement your own custom template which doesn't use the component, then you can add the EmWin library files manually without making use of the PDL and then write your own custom code. You can find the EmWin package here.

               

              Follow the instructions mentioned in the user guide inside the package to add the files.

               

              Regards,

              Dheeraj

              • 4. Re: Override Generated Code for emWin LCD Driver GraphicLCDCtrl PDL component
                CaKu_4284131

                We are using the GraphicsLCDCtrl component to drive a Newhaven LCD Graphic Display with a T6963C controller, but we still need to customize the _SetPixelIndex() and _GetPixelIndex() routines. (Incidentally, we were disappointed to find no equivalent of the GraphicsLCDCtrl component in ModusToolbox.)

                • 5. Re: Override Generated Code for emWin LCD Driver GraphicLCDCtrl PDL component
                  DheerajK_81

                  Then yes, you can add EmWin library files manually without using the PDL and then edit the files. I will check if there is any easier way to do this.

                   

                  Regarding ModusToolbox, please note that it doesn't follow a schematic based design flow and hence you won't find the GraphicsLCDCtrl component. But there is support for EmWin as part of the middleware. You can invoke the Library Manager > Libraries and enable "emwin".

                  libmang1.png

                   

                  Based on your requirement, please configure emwin and you can find how to do so here.

                   

                  Regards,

                  Dheeraj

                  • 6. Re: Override Generated Code for emWin LCD Driver GraphicLCDCtrl PDL component
                    CaKu_4284131
                    Then yes, you can add EmWin library files manually without using the PDL and then edit the files. I will check if there is any easier way to do this.

                    The generated integration of the emWin and the GraphicsLCDCtrl component is convenient for us. It's just that the generated _SetPixelIndex() tries to write a byte directly to the controller, which doesn't work with the T6963C controller, as far as I know. Are we missing something, and making this harder than it needs to be?

                     

                    Regarding ModusToolbox, please note that it doesn't follow a schematic based design flow and hence you won't find the GraphicsLCDCtrl component. But there is support for EmWin as part of the middleware.

                    emWin is great, but it is of little help in actually talking to a T6963C controller from the PSoC.

                     

                    Is there a easy way to recreate this in ModusToolbox + emWin?

                    • 7. Re: Override Generated Code for emWin LCD Driver GraphicLCDCtrl PDL component
                      DheerajK_81

                      T6963C is an LCD Controller and hence you will need to make use of the GraphicsLCDIntf component rather than the GraphicsLCDCtrl component. This is because GraphicsLCDCtrl component is used to provide interface to a LCD panel that has a LCD driver but no LCD Controller.

                       

                      If you refer to the section "Run Time Configurable Drivers" and "Compile-time configurable drivers" for the list of supported drivers/controllers, you will find out that your controller is supported as part of GUIDRV_SLin. Since we don't have this as part of the EmWin package, you will need to implement it yourself.

                       

                      I would suggest you edit the "GUIDRV_Control.c" file while maintaining the backup in a separate file in case if the generated source files get overwritten and continue development.

                       

                      Regarding recreating the GraphicsLCDIntf component in ModusToolbox, note that UDBs are not currently supported and hence cannot be implemented.

                       

                      Regards,

                      Dheeraj

                      • 8. Re: Override Generated Code for emWin LCD Driver GraphicLCDCtrl PDL component
                        CaKu_4284131

                        DheerajK_81 wrote:

                         

                        T6963C is an LCD Controller and hence you will need to make use of the GraphicsLCDIntf component rather than the GraphicsLCDCtrl component. This is because GraphicsLCDCtrl component is used to provide interface to a LCD panel that has a LCD driver but no LCD Controller.

                         

                        Sorry, my mistake, we are indeed using the GraphicLCDIntf Component (not the GraphicsLCDCtrl ).

                         

                        If you refer to the section "Run Time Configurable Drivers" and "Compile-time configurable drivers" for the list of supported drivers/controllers, you will find out that your controller is supported as part of GUIDRV_SLin. Since we don't have this as part of the EmWin package, you will need to implement it yourself.

                         

                        Right, we have done that by customizing the _SetPixelIndex() and _GetPixelIndex() routines in "GUIDRV_Control.c."

                         

                        I would suggest you edit the "GUIDRV_Control.c" file while maintaining the backup in a separate file in case if the generated source files get overwritten and continue development.

                         

                        We have found a work-around, but it is inelegant.

                         

                        Regarding recreating the GraphicsLCDIntf component in ModusToolbox, note that UDBs are not currently supported and hence cannot be implemented.

                         

                        That is disappointing, since ModusToolbox seems to be more "strategic" than PSoC Creator.

                         

                        Regards,

                        Dheeraj

                         

                        Thanks,

                         

                              Carl

                        • 9. Re: Override Generated Code for emWin LCD Driver GraphicsLCDIntf PDL component
                          DheerajK_81

                          Hello Carl,

                           

                          Glad to hear that you are able to proceed with your project. We appreciate your feedback on UDB support in ModusToolbox and I will forward it to the software development team who will evaluate your query.

                           

                          Thank you for your interest in Cypress products.

                           

                          Regards,

                          Dheeraj