moving sensor data collection to collector src

This commit is contained in:
Torsten Ruger
2021-06-27 22:12:14 +03:00
parent de0532bc93
commit 568a8b88c3
4 changed files with 75 additions and 57 deletions

View File

@ -1,31 +1,27 @@
#include <Arduino.h>
#include <vector>
using namespace std;
void collector_setup();
void collector_loop();
class Collector
{
protected:
float week[100];
float month[100];
float week_in[1500]; // 10 per hour, 1 week
float week_out[1500]; // 10 per hour, 1 week
float month_in[750]; // 1 per hour, about a month
float month_out[750]; // 1 per hour, about a month
float minute = 0 ;
int counter = 0;
int max = 100 ;
int bucket = 10;
int bucket = 30; // sampling every 2 sec
public:
void add(float val)
{
minute += val;
counter++ ;
if(counter % bucket){
int at_week = counter / bucket;
week[at_week] = minute / bucket;
minute = 0;
}
if(counter % (bucket*bucket)){
int at_week = counter / bucket;
month[at_week] = minute / bucket;
counter = 0;
}
void add(float in , float out) ;
};
}
};
extern Collector collector;