6 Replies Latest reply on Sep 16, 2019 5:16 AM by KeAu_2443021

    Modify CapSense component source code

    KeAu_2443021

      Is there a way to modify an imported CapSense component to include new variables within the CapSense_Structure.h CapSense_RAM_SNS_STRUCT?  The imported CapSense component has a `$RamWidgetStruct` macro I cannot find.  I also browsed the CapSense component before exporting it without success.  I am relatively new to PSoC, and I have no experience with component authoring.

      I have a single CapSensor application running on a CY8C4014LQI-421. I would like to make changes to the component code.  I have already exported & imported the CapSense_P5_v5 _0 component into my project (V6.0 is not in CyComponentLibary). When modifications are needed, I alter the code within the Workspace Explorer Components tab.  This is per http://www.cypress.com/knowledge-base-article/avoiding-changes-source-file-get-overwritten-psoc-creator

        • 1. Re: Modify CapSense component source code
          AH_96

          Hello KeAu_2443021

           

          If you only wish to add elements to the CapSense_RAM_SNS_STRUCT, you may do so by the method mentioned in the KBA. $RamWidgetStruct is auto populated when the program is built. This should not affect your requirement as elements can be added directly without modifying the $RamWidgetStruct.

           

          Thanks and regards

          Hari

          • 2. Re: Modify CapSense component source code
            KeAu_2443021

            Hari,

            Thank you for your very prompt reply.  I already tried that.  A project build seems to work.  If I run "clean and build", all of my modification are discarded.  This lead me to believe that I was modifying the code incorrectly.

             

            The only solution I found was to create global variables (header file with extern variablename), not tied to CapSense_RAM_SNS_STRUCT.  It works, but seems awkward.  I suspect part of the problem may be these RAM structures are tweaked by component configuration after the imported component APIs are created..

             

            Is there a recommended solution/practice that is not volatile?

             

            Thank you,

            Ken

            • 3. Re: Modify CapSense component source code
              AH_96

              Hello KeAu_2443021

               

              When a component is modified by following the steps provided in the KBA, the component sources are permanently modified and running a clean and build will not modify the data structure again.

               

              Please make sure that you are selecting the correct component (modified component) in your design.

              The modified component will be highlighted in yellow in the components catalog tab.

              The changes are applicable only to this component and this is the one that has to be used.

               

              Thanks and regards

              Hari

              • 4. Re: Modify CapSense component source code
                KeAu_2443021

                Hari,

                We are getting close.

                 

                I believe I imported the component correctly.  Version 5.0 shows up yellow in the component catalog as shown on your picture.  A right click on the placed component shows component major version 5. 

                 

                If I open the file in the Workspace Explorer, -Component- tab, the file is C:\....myproject.cydsn\CapSense_P4_v5_0\PSoC4\API\CapSense_Structure.h.  This contains the macro `$RamWidgetStruct`.

                 

                If I open the file in the Workspace Explorer, - Source- tab, the file is C:\....myproject.cydsn\Generated_Source\PSoC4\CapSense_Structure.h.  This contains the expanded code containing CapSense_RAM_SNS_STRUCT.  A build will leave file modifications.  A clean and build will remove any changes. 

                ---This is the issue. The component is using a macro that I cannot find/alter.  I do not have visibility to CapSense_RAM_SNS_STRUCT---.

                 

                Maybe I have a project or workspace setting that is causing this.  Any suggestions?

                Thanks again,

                Ken

                • 5. Re: Modify CapSense component source code
                  AH_96

                  Hi KeAu_2443021

                   

                  Any additions made to the file in components tab will not be modified even on a clean and build. But when the CapSense_Structure.h is modified in the source tab (the expanded version), it will be replaced every time the project is built.

                   

                  If you need to alter the expanded contents, you need to enable skip code generation option.

                  Right Click on the project->Build settings->Code Generation and change "Skip Code Generation" option to TRUE.

                  After this, any changes made to the generated source will remain unaffected after a build.

                   

                  Best regards

                  Hari

                  • 6. Re: Modify CapSense component source code
                    KeAu_2443021

                    Hari,

                         I think we can wrap up this issue. The original question was not answered. The imported COMPONENT is using a macro that I cannot find/alter.  The CapSense_RAM_SNS_STRUCT expansion only exists in the generated source..  Your last reply about skipping code generation is the only way to I have to add variables to CapSense_RAM_SNS_STRUCT..

                     

                    Thanks for all of your prompt replies.

                    Ken