2 Replies Latest reply on Mar 3, 2020 10:23 PM by yiar_4652736

    CapSense One Button code with multiple buttons

    yiar_4652736

      Hi,

       

      I currently have CY8CKIT-046 and trying example codes that I found on the Internet. In TopDesign section, I added a second button which has exactly same Widget Details as the first. Also ports are configured and main.c file has been edited just like the first button that is in the example code. I built the code and programmed. In CapSense Tuner, device is connected and everything looks OK. But when I try to press the buttons, one of them isn't working at all. Example code works by itself.

       

      What should I do?

       

      Thanks.

       

      P.S: The attached file below is the example code.

        • 1. Re: CapSense One Button code with multiple buttons
          BragadeeshV_41

          Hi yiar_4652736,

           

          I see that you have added the example code to the attachments and not your project. Please share your project so that we can see the issue.

           

          In the meantime, please note the following which could solve your issue.

          CapSense_SetWidgetExt() only configures a particular to be scanned. This API needs to be followed by CapSense_Scan() to initiate a scan. In case you want to scan the second button, wait for the scan of first button to complete and then configure the second button using CapSense_SetWidgetExt()  and perform the scan using CapSense_Scan() .

           

          Snippet:

           

          uint8 i =0 ;

          CapSense_Start();

          CapSense_SetupWidgetExt(i,0);

          CapSense_ScanExt();

           

          for(;;)

          {

          if(CapSense_IsBusy() == 0)

          {

               CapSense_ProcessWidget(i);

               i++;

               if(i > 1)

                    i = 0;

               CapSense_SetupWidgetExt(i,0); // Assuming there is only one sensor per widget.

               CapSense_ScanExt();

          }

           

          Calling CapSense_SetupWidgetExt() one after the other will scan only the last widget that was setup using  CapSense_SetupWidgetExt().

           

          Reference: CE210291_CapSense_P4_One_Button01 modify to multiple Buttons / Sense?

           

          Regards,

          Bragadeesh

          1 of 1 people found this helpful
          • 2. Re: CapSense One Button code with multiple buttons
            yiar_4652736

            Hi BragadeeshV_41,

             

            Thanks for both your answer and your reference, they do work!