Sruthi Dominic :
I have a basic question, I have realtime data. I need to count number of times the data value crosses a threshold.
realtime_data
is a data stream at a rate of 10Hz.
I tried this:
int pCount=0;
if(realtime_data>0.25)
{
++pCount;
ui->lbl_peak->setText(QString::number(pCount));
}
But this does increment only one time. Does not count all the occurrences. Can someone show me the right way to do this?
EDIT
This is how I call realtime_data
:
void Settings::EventHandler(uint8_t index, DATA_T *sample)
{
realtimeDataSlot(sample->sensor_value[0]);
}
void Settings::realtimeDataSlot(double realtime_data)
{
// Here I need to check if the data exceeds a threshold value and count those occurrences
int pCount=0;
if(realtime_data>0.25)
{
++pCount;
ui->lbl_peak->setText(QString::number(pCount));
}
}
Eelke :
You have declared pCount
in your realtimeDataSlot
function which means that everytime the function is called pCount is back to 0. Make pCount a member variable of your class.