I have a realtime signal from a sensor. I need logic to implement a masking time once the signal is above a threshold. As shown below:
Here the signal (in blue) crosses a threshold. And I need to mask for any checks for the threshold for a period (masking time). (In this way I can detect only the positive pulse, similarly, I have another check for negative pulse)
See the code below:
static QTime time(QTime::currentTime());
// calculate two new data points:
double key = time.elapsed()/1000.0; // time elapsed since start of demo, in seconds
static double lastKey;
if(a_vertical> onThreshold && key-lastKey >0.2) // is this check correct for masking time?
{
ui->rdo_btn_vertical->show();
ui->rdo_btn_vertical->setStyleSheet(StyleSheetOn1);
lastKey = key;
}
else
{
ui->rdo_btn_vertical->setStyleSheet(StyleSheetOff1);
}
I'm not sure if the expression inside IF statement is a correct way for implementing a masking time. Any thoughts/suggestions are welcome.
EDIT
Masking time: it's a time period masked for any threshold checking. This to differentiate positive and negative pulse. See below, during a postive pulse there is a negative-going side but it should not detect as a "negative pulse". That's why I implemented a masking time.