CapSense CSD[v2.60] to CapSense [v5.0]

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

cross mob
lock attach
Attachments are accessible only for community members.
nkin_2927171
Level 1
Level 1
5 replies posted 5 likes given First reply posted

IC : CY8C4245AXI-483

for testing i take 2 capsense and 4 led,

toggle LED when I touch.

if i use CapSence CSD [v2.60] then all work fine.

#include "project.h"

unsigned char status=0,flag[10];

int main(void)

{

    CyGlobalIntEnable;  

    OF_01_Write(1);OF_02_Write(1);                                                 //white led on  

    CapSense_Start();

    CapSense_InitializeAllBaselines();  

    for(;;)

    {

        CapSense_UpdateEnabledBaselines();

        CapSense_ScanEnabledWidgets();

        while(CapSense_IsBusy());      

        status=CapSense_CheckIsWidgetActive(CapSense_SENSOR_BUTTON01__BTN);

        if(status==1)

        {

            if(flag[1]==0)  {flag[1]=1;ON_01_Write(1);OF_01_Write(0);CyDelay(2);}

            else            {flag[1]=0;ON_01_Write(0);OF_01_Write(1);CyDelay(2);}

            while(status==1)

            {

                CapSense_UpdateEnabledBaselines();

                CapSense_ScanEnabledWidgets();

                while(CapSense_IsBusy());   

                status = CapSense_CheckIsWidgetActive(CapSense_SENSOR_BUTTON01__BTN);

            }

        }

        status=CapSense_CheckIsWidgetActive(CapSense_SENSOR_BUTTON02__BTN);

        if(status==1)

        {

            if(flag[2]==0)  {flag[2]=1;ON_02_Write(1);OF_02_Write(0);CyDelay(2);}

            else            {flag[2]=0;ON_02_Write(0);OF_02_Write(1);CyDelay(2);}

            while(status==1)

            {

                CapSense_UpdateEnabledBaselines();

                CapSense_ScanEnabledWidgets();

                while(CapSense_IsBusy());

                status = CapSense_CheckIsWidgetActive(CapSense_SENSOR_BUTTON02__BTN);

            }

        }      

    }

}

all work fine in above code (both touch button work )

now i replace CapSense CSD[v2.60] to CapSense [v5.0]

and i change API as per migration guide.

#include "project.h"

unsigned char status=0,flag[10];

int main(void)

{

    CyGlobalIntEnable;

  

    OF_01_Write(1);OF_02_Write(1);

  

    CapSense_Start();

    CapSense_InitializeAllBaselines();

  

    for(;;)

    {

        //CapSense_ClearSensors();

        CapSense_ProcessAllWidgets();

        CapSense_ScanAllWidgets();

        while(CapSense_IsBusy());

      

        status=CapSense_IsWidgetActive(CapSense_BUTTON01_WDGT_ID);

        if(status==1)

        {

            if(flag[1]==0)  {flag[1]=1;ON_01_Write(1);OF_01_Write(0);CyDelay(2);}

            else            {flag[1]=0;ON_01_Write(0);OF_01_Write(1);CyDelay(2);}

            while(status==1)

            {

                CapSense_ProcessAllWidgets();

                CapSense_ScanAllWidgets();

                while(CapSense_IsBusy());   

                status = CapSense_IsWidgetActive(CapSense_BUTTON01_WDGT_ID);

            }

        }

      

        status=CapSense_IsWidgetActive(CapSense_BUTTON02_WDGT_ID);

        if(status==1)

        {

            if(flag[2]==0)  {flag[2]=1;ON_01_Write(1);OF_01_Write(0);CyDelay(2);}

            else            {flag[2]=0;ON_01_Write(0);OF_01_Write(1);CyDelay(2);}

            while(status==1)

            {

                CapSense_ProcessAllWidgets();

                CapSense_ScanAllWidgets();

                while(CapSense_IsBusy());   

                status = CapSense_IsWidgetActive(CapSense_BUTTON02_WDGT_ID);

            }

        }

      

    }

}

In both code same pins are take for capsnese and leds.

but Only 1st button working,2nd not working.(in CapSense [v5.0])

what's i am doing wrong ?any one help me ?

both code is attached.

0 Likes
1 Solution
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi

The reply above is correct. The order needs to be changed.

Additionally, it must be noted that the function CapSense_IsWidgetActive returns 0 if no activity is found on the widget and returns a non-zero element (need not be 1 always) if at least one sensor of the specified widget is active, i.e. a touch is detected. Please change line 34 and 38 to if(status){..} and while(status){..}  respectively.

You can also just set the condition like

if(CapSense_IsWidgetActive(CapSense_BUTTON02_WDGT_ID))

{

}

Do let us know in case you have any further query.

Thanks and regards

Harigovind

View solution in original post

7 Replies
BrandonP_16
Employee
Employee
5 sign-ins First question asked 10 solutions authored

Hi,

I recommend to change the order of function call from

                CapSense_ProcessAllWidgets();

                CapSense_ScanAllWidgets();

                while(CapSense_IsBusy()); 

to

                CapSense_ScanAllWidgets();

                while(CapSense_IsBusy()); 

                CapSense_ProcessAllWidgets();

In CapSense v2.6, function "CapSense_CheckIsWidgetActive(WIDGET_ID)" calculates touch detection.

BUT, in CapSense v5.0, function "CapSense_ProcessAllWidgets()" calculates and saves touch detection with baseline update and function "CapSense_IsWidgetActive(WIDGET_ID)" just check the saved touch detection data which is calculated with function "CapSense_ProcessAllWidgets()".

I found 3-point needs to change the order.

Please try this and let me know the effect.

Thanks,

Brandon

lock attach
Attachments are accessible only for community members.

still not working.

I change order as you suggest.

video attached.

0 Likes

Hi,

I checked the video as you shared.

As your comments, just one sensor is not working.

To verify for this issue is caused by tuning, would you please enable other sensors (Button03~06) with LED operation?

If others are working normally, then you should check tuning parameters (SmartSense).

Thanks,

Brandon

lock attach
Attachments are accessible only for community members.

video is attached with 6 button , with LED.

same problem,CapSense CSD[v2.60 is working ,CapSense [v5.0]is not working

code is also attached.

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hey

Have you tried my suggestion regarding the CapSense_IsWidgetActive API?

Please accommodate the changes in the code and let us know if that works...

Regards

Harigovind

Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi

The reply above is correct. The order needs to be changed.

Additionally, it must be noted that the function CapSense_IsWidgetActive returns 0 if no activity is found on the widget and returns a non-zero element (need not be 1 always) if at least one sensor of the specified widget is active, i.e. a touch is detected. Please change line 34 and 38 to if(status){..} and while(status){..}  respectively.

You can also just set the condition like

if(CapSense_IsWidgetActive(CapSense_BUTTON02_WDGT_ID))

{

}

Do let us know in case you have any further query.

Thanks and regards

Harigovind

nkin_2927171
Level 1
Level 1
5 replies posted 5 likes given First reply posted

Thanks now it working

0 Likes