You can do this by simply calling the CapSense_InitializeSensorBaseline API. This API resets the baseline of the sensor that is specified as parameter. You can refer CE229140 - PSoC 4 CapSense Custom Baseline Reset for an example of time based and sample based implementation of custom baseline reset.
It appears that the CE229140 document describes a hard baseline reset to the raw count based on a metric. That function appears to be somewhat different from what I'm looking for.
In the CapSense configuration dialog, on the Advanced tab, there is a single checkbox for "Enable sensor auto-reset." The description of that setting is as follows:
When enabled, the baseline is always updated and when disabled, the baseline is updated only when the difference between the baseline and the raw count is less than the noise threshold. The sensor auto-reset prevents the sensor from permanently turning on when the raw count accidentally rises because of a large power-supply voltage fluctuation or due to other spurious conditions.
The first sentence states that when the setting is enabled, the baseline is always updated. This sounds more like what I'm after. I interpret that to mean that the baseline IIR continues to filter the raw count, producing the baseline, regardless of the difference between the baseline and the raw count. I'd like to try that for just the proximity widget, and not the regular widget. The problem is that the config setting appears to be a global setting that applies to both widgets simultaneously.
This appears to perform a different function from that found in CE229140, which describes two approaches, time-based baseline reset and sample-based baseline reset. The description of time-based baseline reset from the document states that "A baseline reset is executed if the sensor is stuck for a user defined period." The description of the sample-based baseline reset states that "A baseline reset is executed if the sensor is stuck for a user defined number of samples (i.e., number of CapSense scans)." These descriptions appear to use the term "reset" in the same sense as it is used in the term "low baseline reset," which is a hard reset of the baseline to the raw count. That's not quite what I'm after; instead, I'd like to let the baseline IIR continue to operate at all times.
I suppose that I could run my own IIR filter on manually-read raw counts, calculating a baseline on-the-fly, and calling the CapSense_InitializeSensorBaseline function for every sample. But that would seem to be rather inefficient, considering there's already an IIR filter residing on the widget.
But I'm still curious as to whether the CapSense "enable sensor auto-reset" function found on the Advanced tab of the CapSense configuration dialog can be enabled somehow, perhaps through a function call, for the proximity widget only, without affecting the regular widget.
I have attached a sample project demonstrates baseline auto reset for proximity sensor. Please have a look and let us know if it meets your requirement.
Please note however that this has not been tested and verified by Cypress and is just an example for the use case mentioned. This function was derived from CapSense_FtUpdateBaseline with slight modifications to make sure that the proximity sensor works as required.
I'll take a look. Thank you.