Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Enabling/disabling CAPSENSE™ widgets in PSoC™ Creator - KBA233948

Enabling/disabling CAPSENSE™ widgets in PSoC™ Creator - KBA233948

IFX_Publisher1
Community Manager
Community Manager
Community Manager
250 sign-ins First comment on KBA 250 replies posted

Enabling/disabling CAPSENSE™ widgets in PSoC™ Creator - KBA233948

Community Translation: PSoC™ CreatorのCAPSENSE™ ウィジェットを有効化/無効化する - KBA233948

Version: **

You can use the following API functions and structure for the CAPSENSE™ component in PSoC™ Creator to enable/disable widgets. See the CAPSENSE™ component datasheet available as part of PSoC™ Creator installation for details.

Method 1: Using CapSense_SetParam() API

CapSense_SetParam(uint32 paramId, uint32 value);

where

  • paramId = CapSense_WDGT_ENABLE<RegisterNumber>_PARAM_ID is the required register (see CapSense_RegisterMap.h)
  • value = ‘0’: disable
    value =
    ‘1’: enable

Bit masking is used to enable/disable a widget.

The following example has five CSD buttons configured:

MohammedA_41_0-1639663169072.png
 

Value takes a 5-bit value in the following format:

<Button4><Button3><Button2><Button1><Button0>   (MSB = left-most bit, LSB = right-most bit)

Call the following function to enable only Button3 using value = 01000 (in binary) or 8 (in decimal):

CapSense_SetParam(CapSense_WDGT_ENABLE0_PARAM_ID, 8);

Call the following function to disable only Button2 using value = 11011 (in binary) or 27 (in decimal):

CapSense_SetParam(CapSense_WDGT_ENABLE0_PARAM_ID, 27);

Method 2: Using CapSense_SetupWidgetExt() API

CapSense_SetupWidgetExt (uint32 widgetId, uint32 sensorId);

where

  • widgetId : ID of the widget (CapSense_<name>_WDGT_ID)
  • sensorId : ID of the sensor present within the widget

After enabling the sensors using this API, CapSense_ScanExt() is used to scan the sensor. For example, to enable sensor0 of the Button0 widget, call the following function:

CapSense_SetupWidgetExt(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID);

Method 3: Using the CAPSENSE™ RAM structure

The CapSense_dsRam structure is of CapSense_RAM_STRUCT struct type, and maintains various CAPSENSE™ parameters. To enable Button0 widget, use the following structure:

CapSense_dsRam.wdgtEnable[CapSense_BUTTON0_WDGT_ID] = 1;

To disable this widget, write ‘0’ to the wdgtEnable array.

313 Views