small fix. added getter and setter!

This commit is contained in:
toni
2016-11-16 12:40:16 +01:00
parent c083aae476
commit 41c1d90c54
5 changed files with 34 additions and 171 deletions

View File

@@ -18,8 +18,6 @@ public:
enum Activity {DOWN, STAY, UP};
struct History {
Timestamp ts;
BarometerData data;
@@ -27,14 +25,8 @@ public:
};
private:
//just for debugging and plotting
std::vector<History> input;
std::vector<History> inputInterp;
std::vector<History> output;
std::vector<float> sumHist;
std::vector<float> mvAvgHist;
std::vector<History> actHist;
std::vector<History> output;
Activity currentActivity;
MovingAVG<float> mvAvg = MovingAVG<float>(20);
@@ -47,8 +39,8 @@ public:
* FixedFrequencyInterpolator<float> ffi = FixedFrequencyInterpolator<float>(Timestamp::fromMS(100));
*/
const bool additionalLowpassFilter = false;
const int diffSize = 20; //the number values used for finding the activity.
const float threshold = 0.025; // if diffSize is getting smaller, treshold needs to be adjusted in the same direction!
const unsigned long diffSize = 20; //the number values used for finding the activity.
const float threshold = 0.025f; // if diffSize is getting smaller, treshold needs to be adjusted in the same direction!
Filter::ButterworthLP<float> butter = Filter::ButterworthLP<float>(10,0.05f,2);
Filter::ButterworthLP<float> butter2 = Filter::ButterworthLP<float>(10,0.05f,2);
@@ -76,14 +68,11 @@ public:
return STAY;
}
//input.push_back(History(ts, baro));
bool newInterpolatedValues = false;
//interpolate & butter
auto callback = [&] (const Timestamp ts, const float val) {
float interpValue = val;
//inputInterp.push_back(History(ts, BarometerData(interpValue)));
//butter
float butterValue = butter.process(interpValue);
@@ -97,10 +86,10 @@ public:
if(newInterpolatedValues == true){
//getActivity
if((int)output.size() > diffSize){
if(output.size() > diffSize){
//diff
std::vector<float> diff;
for(int i = output.size() - diffSize; i < output.size() - 1; ++i){
for(unsigned long i = output.size() - diffSize; i < output.size() - 1; ++i){
float diffVal = output[i+1].data.hPa - output[i].data.hPa;
@@ -121,7 +110,6 @@ public:
}else{
actValue = sum;
}
//sumHist.push_back(actValue);
if(actValue > threshold){
currentActivity = DOWN;
@@ -135,8 +123,6 @@ public:
}
}
//actHist.push_back(History(ts, BarometerData(currentActivity)));
return currentActivity;
}
@@ -145,49 +131,6 @@ public:
Activity getCurrentActivity() {
return currentActivity;
}
std::vector<float> getSensorHistory(){
std::vector<float> tmp;
for(History val : input){
tmp.push_back(val.data.hPa);
}
return tmp;
}
std::vector<float> getInterpolatedHistory(){
std::vector<float> tmp;
for(History val : inputInterp){
tmp.push_back(val.data.hPa);
}
return tmp;
}
std::vector<float> getOutputHistory(){
std::vector<float> tmp;
for(History val : output){
tmp.push_back(val.data.hPa);
}
return tmp;
}
std::vector<float> getSumHistory(){
return sumHist;
}
std::vector<History> getActHistory(){
return actHist;
}
};
#endif // ACTIVITYBUTTERPRESSURE_H