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

PSoC™ 4

wangyuanfan
Level 3
10 replies posted 10 questions asked 10 sign-ins
Level 3

Do I have to use the function "CapSense_GetParam" instead of  the function "CapSense_GetSensorCapacitance".

Or, Do I have to change something setting to be able to use the function "CapSense_GetSensorCapacitance".

0 Likes
1 Solution
MotooTanaka
Level 9
First comment on KBA 1000 replies posted 750 replies posted
Level 9

Hi,

I used "CapSense_GetSensorCapacitance" with CapSense v7.0 in my sample below

https://community.infineon.com/t5/Code-Examples/A-CapSense-sample-using-an-Elephantech-PEDOT-electro...

void measure_caps(void)
{
    CapSense_TST_MEASUREMENT_STATUS_ENUM measurementStatus ;
    char str[64] ;
    
    while(CapSense_NOT_BUSY != CapSense_IsBusy()) {
        /* wait for capsent to be free */
    }

    TFT_BusEnable(1) ;
    TFT_locate(100, 40) ;
    button_cap[0] = CapSense_GetSensorCapacitance(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID,&measurementStatus) ;
    if (measurementStatus == CapSense_TST_MEASUREMENT_SUCCESS) {
        snprintf(str, 64, "Button1: %d", (int)button_cap[0]) ;
        TFT_putstr(str) ;
    } else {
        print_measure_error(measurementStatus) ;
    }

    TFT_locate(100, 60) ;
    button_cap[1] = CapSense_GetSensorCapacitance(CapSense_BUTTON1_WDGT_ID, CapSense_BUTTON1_SNS0_ID,&measurementStatus) ;
    if (measurementStatus == CapSense_TST_MEASUREMENT_SUCCESS) {
        snprintf(str, 64, "Button2: %d", (int)button_cap[1]) ;
        TFT_putstr(str) ;     
    } else {       
        print_measure_error(measurementStatus) ;
    }

    TFT_locate(100, 80) ;
    button_cap[2] = CapSense_GetSensorCapacitance(CapSense_BUTTON2_WDGT_ID, CapSense_BUTTON2_SNS0_ID,&measurementStatus) ;
    if (measurementStatus == CapSense_TST_MEASUREMENT_SUCCESS) {
        snprintf(str, 64, "Button3: %d", (int)button_cap[2]) ;
        TFT_putstr(str) ;        
    } else {       
        print_measure_error(measurementStatus) ;
    }   

    TFT_BusEnable(0) ;   
    
    CapSense_Stop() ;
    CyDelay(100) ;
    CapSense_Start() ;
    CapSense_ScanAllWidgets() ;   
}

May be it depends on the device you are using.

I was using CY8CKIT-044 (CY8C4247AZI-M485).

moto

View solution in original post

0 Likes
2 Replies
MotooTanaka
Level 9
First comment on KBA 1000 replies posted 750 replies posted
Level 9

Hi,

I used "CapSense_GetSensorCapacitance" with CapSense v7.0 in my sample below

https://community.infineon.com/t5/Code-Examples/A-CapSense-sample-using-an-Elephantech-PEDOT-electro...

void measure_caps(void)
{
    CapSense_TST_MEASUREMENT_STATUS_ENUM measurementStatus ;
    char str[64] ;
    
    while(CapSense_NOT_BUSY != CapSense_IsBusy()) {
        /* wait for capsent to be free */
    }

    TFT_BusEnable(1) ;
    TFT_locate(100, 40) ;
    button_cap[0] = CapSense_GetSensorCapacitance(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID,&measurementStatus) ;
    if (measurementStatus == CapSense_TST_MEASUREMENT_SUCCESS) {
        snprintf(str, 64, "Button1: %d", (int)button_cap[0]) ;
        TFT_putstr(str) ;
    } else {
        print_measure_error(measurementStatus) ;
    }

    TFT_locate(100, 60) ;
    button_cap[1] = CapSense_GetSensorCapacitance(CapSense_BUTTON1_WDGT_ID, CapSense_BUTTON1_SNS0_ID,&measurementStatus) ;
    if (measurementStatus == CapSense_TST_MEASUREMENT_SUCCESS) {
        snprintf(str, 64, "Button2: %d", (int)button_cap[1]) ;
        TFT_putstr(str) ;     
    } else {       
        print_measure_error(measurementStatus) ;
    }

    TFT_locate(100, 80) ;
    button_cap[2] = CapSense_GetSensorCapacitance(CapSense_BUTTON2_WDGT_ID, CapSense_BUTTON2_SNS0_ID,&measurementStatus) ;
    if (measurementStatus == CapSense_TST_MEASUREMENT_SUCCESS) {
        snprintf(str, 64, "Button3: %d", (int)button_cap[2]) ;
        TFT_putstr(str) ;        
    } else {       
        print_measure_error(measurementStatus) ;
    }   

    TFT_BusEnable(0) ;   
    
    CapSense_Stop() ;
    CyDelay(100) ;
    CapSense_Start() ;
    CapSense_ScanAllWidgets() ;   
}

May be it depends on the device you are using.

I was using CY8CKIT-044 (CY8C4247AZI-M485).

moto

0 Likes
wangyuanfan
Level 3
10 replies posted 10 questions asked 10 sign-ins
Level 3

Thank you for always helping, moto.

My device is CY8CKIT-149.

I figured out the important thing just now.

There are three selections of 'CSD tuning mode' in Configure CapSense, SmartSense(Full Auto-Tune),  SmartSense(Hardware parameters only), and Manual tuning. 

If I select SmartSense(Full Auto-Tune), it seems that the APIs that can be used are limited. CapSense_GetSensorCapacitance was not available.

On the other hand, If I select SmartSense(Hardware parameters only) and check 'Enable self-test library' in advanced tab I could use it.

I'm still not sure about the difference between 'Full Auto-Tune' and 'Hardware parameters only' but at any rate, CapSense_GetSensorCapacitance is now available.

I'll learn from your code and link you shared. Thank you!