3 Replies Latest reply on Jan 17, 2017 5:34 AM by YuvaM_36

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

      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

        • 1. Re: How is CapSense "release motion" detected? (Based on widget state)

          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.







          • 2. Re: How is CapSense "release motion" detected? (Based on widget state)

            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,



            • 3. Re: How is CapSense "release motion" detected? (Based on widget state)





              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.







              1 of 1 people found this helpful