debug and smoothing

This commit is contained in:
hg
2014-02-26 20:54:54 +01:00
parent 15cc422fc1
commit 63a3853294
2 changed files with 120 additions and 26 deletions

View File

@ -11,10 +11,10 @@
#include <Metro.h>
#include "cmd.h"
const bool DEBUG = false;
const bool DEBUG = true;
const bool INFO = true;
const unsigned long DEFAULT_PERIOD = 10000;
const unsigned long DEFAULT_PERIOD = 1000;
const unsigned int NUM_OF_CHANNELS = 4;
const unsigned long N_MAX = 0xffffff;
const float R_REF = 6000.0;
@ -23,20 +23,53 @@ const float PT1000_Coeff = 3.85e-3;
const unsigned long CONV_TIMEOUT = 0xfffff;
class Thermometer;
class ThermConfig : public Cmd {
public:
ThermConfig(Thermometer *thermometer) : m_thermometer(thermometer) {};
virtual String getCmdName() { return "TCFG"; }
virtual String getHelp() { return "Thermometer configuration operations"; }
virtual String exec(String params);
private:
Thermometer *m_thermometer;
};
class Thermometer {
public:
Thermometer();
void begin(CmdServer *cmdServer);
void exec();
friend class ThermConfig;
private:
Metro m_period;
unsigned long m_periodMillis;
ThermConfig thermConfig;
bool m_debug;
bool m_info;
unsigned long m_n[NUM_OF_CHANNELS];
float m_calibrateFactor[NUM_OF_CHANNELS];
float m_temperature[NUM_OF_CHANNELS];
float m_lastSmoothedTemperature[NUM_OF_CHANNELS];
float m_smoothedTemperature[NUM_OF_CHANNELS];
unsigned long m_timeOutFailureCnt;
unsigned long m_cylceCnt;
float m_alpha;
void startSingleConv();
void prepareAdc();
void setTemperature(unsigned int index, float t);
void setPeriodMeasure(unsigned long p);
void setAlpha(float a);
};