7 Replies Latest reply on Jan 19, 2020 8:17 PM by BragadeeshV_41

    CapSense question

    ChHs_4614611

      Hi

       

      I use CapSense function and create 23 CSD button.

      When I press a button.  Which API function can let me know which key is pressed ?

        • 1. Re: CapSense question
          MoTa_728816

          Hi,

           

          I think that you need check each widget after CapSense_IsBusy() goes to 0.

          (Note: I may be wrong)

           

          I made a test sample with CY8CKIT-044 with schematic

          000-schematic.JPG

          the main loop is

          ===================

          int main(void)

          {

              init_hardware() ;

             

              for(;;) {

                  if (!CapSense_IsBusy()) {

                      check_push_button() ;

                     

          #if USE_TUNER

                      CapSense_TunerComm()  ;

          #endif

                     

                      CapSense_UpdateEnabledBaselines() ;

                      CapSense_ScanEnabledWidgets() ;

                  }

           

           

                  if (sec_flag) {

          #if USE_UART           

                      dump_push_button() ;

          #endif

                      sec_flag = 0 ;

                  }

                 

              }

          }

          ===================

           

          define of push_button_ids

          ===================

          #define NUM_PUSH_BUTTON   23

           

          uint8_t push_button_id[NUM_PUSH_BUTTON] = {

            CapSense_BUTTON01__BTN,

            CapSense_BUTTON02__BTN,

            CapSense_BUTTON03__BTN,

            CapSense_BUTTON04__BTN,

            CapSense_BUTTON05__BTN,

            CapSense_BUTTON06__BTN,

            CapSense_BUTTON07__BTN,

            CapSense_BUTTON08__BTN,   

            CapSense_BUTTON09__BTN,

            CapSense_BUTTON10__BTN,

            CapSense_BUTTON11__BTN,

            CapSense_BUTTON12__BTN,

            CapSense_BUTTON13__BTN,

            CapSense_BUTTON14__BTN,

            CapSense_BUTTON15__BTN,

            CapSense_BUTTON16__BTN,      

            CapSense_BUTTON17__BTN,

            CapSense_BUTTON18__BTN,

            CapSense_BUTTON19__BTN,

            CapSense_BUTTON20__BTN,

            CapSense_BUTTON21__BTN,

            CapSense_BUTTON22__BTN,

            CapSense_BUTTON23__BTN    

          } ;

          ===================

           

          check_push_button() is

          ===================

          uint16_t check_push_button(void)

          {

              uint16_t num_pushed = 0 ;

              int i ;

              for (i = 0 ; i < NUM_PUSH_BUTTON ; i++ ) {

                  if (CapSense_CheckIsWidgetActive(push_button_id[i])) { // <--- checking each widget here

                      push_button[i] = 1 ;

                      num_pushed++ ;

                  } else {

                      push_button[i] = 0 ;

                  }

              }

              return(num_pushed) ;

          }

          ===================

           

          Tera Term Log

          (Note: I have not assigned widget button seriously... only auto assigned...)

          001-teraterm-log.JPG

           

          I hope that this can be a little hint for you.

           

          moto

          1 of 1 people found this helpful
          • 2. Re: CapSense question
            ChHs_4614611

            Dear Motoo Tanaka,

             

            Your sample is very useful for me.

            Thank you for your help. 

             

            • 3. Re: CapSense question
              BragadeeshV_41

              Hi ChHs_4614611,

               

              MoTa_728816-san, thanks for your input. i would like to add the following points.

               

              1. We recommend using the latest version of CapSense v6.0 or higher for newer applications since it has better calibration routines and firmware fixes.

              2. While checking the widget status if active or not, it is always recommended to do it after processing the widgets. Therefore the flow would be :

               

              CapSense_Start();

              CapSense_ScanAllWidgets();

               

              for(;;)

              {

                      if (!CapSense_IsBusy())

                      {

                        CapSense_ProcessAllWidgets(); // Same as CapSense_UpdateEnabledBaselines() in older component

                        check_push_button() ; //Your application to check button status using CapSense_IsWidgetActive(Widget_ID).

              #if USE_TUNER

                          CapSense_RunTuner()  ;    // Same as  CapSense_TunerComm() in older component

              #endif

                        CapSense_ScanAllWidgets(); //Same as  CapSense_ScanEnabledWidgets in older component

                      }

              }

               

              It is also possible to assign all the buttons to a single widget (if the parasitic capacitance of all the buttons are similar, since you will be able to set only one hardware parameters for all the sensors in a widget). In that case you can use CapSense_IsSensorActive(WidgetID, SensorID) to check if the sensor in that widget is on or off.

               

              Please go through the capsense component datasheet for detailed information on these APIs.

              https://www.cypress.com/documentation/component-datasheets/psoc-4-capacitive-sensing-capsense

              Hope this helps!

               

              Regards,

              Bragadeesh

              2 of 2 people found this helpful
              • 4. Re: CapSense question
                MoTa_728816

                Hi,

                 

                Thanks for the Bragadeesh-san's suggestion,

                I could manage to utilize CapSense (V7.0) for my previous sample!

                 

                One thing I noticed was, the Tuner.

                With CapSense CSD (v2.60) The tuner showed all buttons

                001-2_60_tuner.JPG

                But with CapSense (v7.0) I needed to scroll to see all 23 buttons.

                (May be I'm missing something again...)

                003-7_00_tuner.JPG

                 

                moto

                1 of 1 people found this helpful
                • 5. Re: CapSense question
                  BragadeeshV_41

                  Hi MoTa_728816,

                   

                  It is just the GUI that is developed like that for the newer components. We will create an enhancement request for this and will be updated based on priority.

                   

                  Thanks for your continued interest with Cypress products

                   

                  Regards,

                  Bragadeesh

                  • 6. Re: CapSense question
                    ChHs_4614611

                    Hi BragadeeshV_41,

                     

                        Cypress MCU is used for the first time in our company. So, I have some question~^^

                        The below photo is our new desgin HMI for vehicle.

                        I have a question for Touch Key sensitivity.

                        Now I no touch ,my finger just near touch key it already trigger.

                        How to adjust Touch Key sensitivity?

                    Touch.png

                    2020-01-20_090657.jpg

                    • 7. Re: CapSense question
                      BragadeeshV_41

                      Hi ChHs_4614611,

                       

                      Reduce the resolution of the widget to reduce the sensitivity of the button. But make sure the SNR > 5 :1

                       

                      Regards,

                      Bragadeesh