How is CapSense "release motion" detected? (Based on widget state)

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.
Anonymous
Not applicable

I've somehow managed to code up the "Challenge" from tutorial 13 from PSOC 101.  I read a button sensor on the CapSense and report if the state is high or low (only once per state/state change).

   


I understand how the initial press-down state is processed.  Variable "buttonOne" != the address "0xFFFFFFFF" and != it's previous state (which initially is the same high address).  This confirms the if statement condition and I then display the "Button Pressed" message to my terminal.

   

However, when I release the button, it should resume the inactive 0xFFFFFFFF state...which should not trigger the if statement body.  However, it always gets triggered (which is ironically exactly what I want but I have no idea why this situation occurs).

   

I'm providing my project bundle with the code...let me know what you think, and if you have an explanation for this occurrence I'd be grateful to know.  

   

 

   

- Anthony

0 Likes
1 Solution
Yuva
Moderator
Moderator
Moderator
250 replies posted 250 sign-ins 100 solutions authored

Hi Anthony,

   

 

   

CapSense_CheckIsWidgetActive() API will either return 1 or 0 when the button is pressed or not respectively. In your case when you release the button the 'buttonOne' will be 0 which is != "0xFFFFFFFF" && != it's previous state (0x01) so this causes entry to the 'if ' condition and display 'button release' message in the terminal.

   

 

   

Thanks,

   

Yuva.

View solution in original post

0 Likes
3 Replies
Yuva
Moderator
Moderator
Moderator
250 replies posted 250 sign-ins 100 solutions authored

Hi Anthony,

   

 

   

CapSense_CheckIsWidgetActive() API will either return 1 or 0 when the button is pressed or not respectively. In your case when you release the button the 'buttonOne' will be 0 which is != "0xFFFFFFFF" && != it's previous state (0x01) so this causes entry to the 'if ' condition and display 'button release' message in the terminal.

   

 

   

Thanks,

   

Yuva.

0 Likes
Anonymous
Not applicable

The instructor in the video mentions that 0xFFFF is considered the original state of the CapSense (when no interaction has occurred).  That to me makes sense since, for operations with the switch SW2 and the LEDs, they get triggered on a falling edge, which says their original state is HIGH.  Correct me if I'm wrong but does the return value of "CapSense_CheckIsWidgetActive(CapSense_Button0__BTN)" only dictate the perception of on or off (1 or 0), while disguising the actual value of 1 and 0?  

   

Also, given my idea of 0xFFFFFFFF being the initial off state, when the transition from (whatever the bit state is based on touch position) to the "off" state 0xFFFFFFFF, does the 32-bit registry still contain bits left over from the "touch state" by the time the "for(;;)" loop repeats itself?  If so then again that makes sense why my "if" statement body ends up executing.

   

Thanks for reading this, Yuva,

   

Anthony

0 Likes
Yuva
Moderator
Moderator
Moderator
250 replies posted 250 sign-ins 100 solutions authored

Anthony,

   

 

   

The video was related to capsense slider and the GetCentroidPosition() API would return 0xFF when there is no touch. But incase of CapSense_CheckIsWidgetActive() API the return value is either 0 or 1. Also this get updated after every scan. In your case since the value always ot equal to 0xFF the 'if' condition executes whenever there is change in touch status.

   

 

   

Thanks,

   

Yuva.