- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks now it working