- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I was working with capsense and i require the capsense button to work just as normal push switch.
I am using the buttons to send commands to my serial mp3 player. But if i put my finger on the button, the function is getting executed a number of times and sending the UART data continuously which i require to be sent only once.
I am uploading my workspace bundle. Please let me know a solution for this
Solved! Go to Solution.
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Easiest is to remember the state of the button and react only when its state changes. When the button is pressed for a longer time (a counter will help to detect) you can react differently as fast forward, mute or something else.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Easiest is to remember the state of the button and react only when its state changes. When the button is pressed for a longer time (a counter will help to detect) you can react differently as fast forward, mute or something else.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
oh. okay Bob.Thank you. I will try it out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob, could you please elaborate how to save the button state? I tried it out but still it is not executed only once. I tried varying the debounce settings of capsense too..still not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It has nothing to do with the debouncing of the capsense. Your code shows clearly "As long as the button is pressed execute the prev() function"
You have to define a
static uint8 Button_Pressed = FALSE;
and in code
if(CapSense_CheckIsWidgetActive(CapSense_BUTTON1__BTN) && !Button_Pressed)
{
Prev();
LCD_PrintString("ON ");
Button_Pressed = TRUE;
}
else
{
if(Button_Pressed) LCD_PrintString("OFF ");
Button_Pressed = FALSE;
}
Might be you have to #define FALSE and TRUE as
#define FALSE 0
#define TRUE !FALSE
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot Bob!...It is working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great!
Bob