11 Replies Latest reply on Mar 4, 2018 11:09 PM by pramod.kashyap_2812256

    Capsense button press API

    pramod.kashyap_2812256

      Hello,

       

      Iam using PSCO4 CYC4014 Microcontroller for our project,

       

      Iam using below mentioned API's for detecting if finger press on button,

       

      1) CapSense_CheckIsSensorActive()

       

      2) CapSense_CheckIsWidgetActive()

       

       

      Below is function snippet.

       

      uint32 CapSense_CheckIsSensorActive(uint32 sensor)

      {

          uint8 widget;

          uint8 debounce;

          uint8 debounceIndex;

          uint8 fingerThreshold;

          uint8 hysteresis;

         

          /* Prepare to find debounce counter index */

          widget = CapSense_widgetNumber[sensor];

          fingerThreshold = CapSense_fingerThreshold[widget];

          hysteresis = CapSense_hysteresis[widget];

         debounce = CapSense_debounce[widget];

              debounceIndex = widget;

          /* Was on */

          if (0u != CapSense_GetBitValue(CapSense_sensorOnMask, sensor))

          {

              /* Hysteresis minus */

              if (CapSense_sensorSignal[sensor] < (fingerThreshold - hysteresis))

              {

                  CapSense_SetBitValue(CapSense_sensorOnMask, sensor, 0u);

                  /* Sensor inactive - reset Debounce counter */

                  CapSense_debounceCounter[debounceIndex] = debounce;

              }

          }

          else    /* Was off */

          {

              /* Hysteresis plus */

              if (CapSense_sensorSignal[sensor] >= (fingerThreshold + hysteresis))

              {

                  CapSense_debounceCounter[debounceIndex]--;

                  /* Sensor active, decrement debounce counter */

                  if(CapSense_debounceCounter[debounceIndex] == 0u)

                  {

                      CapSense_SetBitValue(CapSense_sensorOnMask, sensor, 1u);

                  }

              }

              else

              {

                  /* Sensor inactive - reset Debounce counter */

                  CapSense_debounceCounter[debounceIndex] = debounce;

              }

          }

          return ((uint32)((0u != CapSense_GetBitValue(CapSense_sensorOnMask, sensor)) ? 1u : 0u));

      }

       

      Iam not able to detect the finger press,Please let me know where the issue is.

       

      Thanks & Regards,

      Pramod