Resources handling started
This commit is contained in:
21
Resources.cpp
Normal file
21
Resources.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Resources.cpp
|
||||
*
|
||||
* Created on: 05.03.2014
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
|
||||
#include "Resources.h"
|
||||
|
||||
|
||||
|
||||
String TEXT;
|
||||
|
||||
|
||||
const String& getResource(uint8_t key) {
|
||||
// return TEXT_RESOURCES[key];
|
||||
TEXT = String("T") + key + String(": ");
|
||||
return TEXT;
|
||||
}
|
||||
|
115
Resources.h
Normal file
115
Resources.h
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Resources.h
|
||||
*
|
||||
* Created on: 05.03.2014
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef RESOURCES_H_
|
||||
#define RESOURCES_H_
|
||||
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
const uint8_t TEXT1_KEY = 0;
|
||||
const uint8_t PERIOD_MEASURE_KEY = 1;
|
||||
const uint8_t ALPHA_SPACES_KEY = 2;
|
||||
const uint8_t CALIBRATION_SPACES_KEY = 3;
|
||||
const uint8_t INFO_SPACES_KEY = 4;
|
||||
const uint8_t DEBUG_SPACES_KEY = 5;
|
||||
const uint8_t COMPILE_TIME_DEBUG_KEY = 6;
|
||||
const uint8_t TIMEOUTS_SPACES_KEY = 7;
|
||||
const uint8_t CYCLES_SPACES_KEY = 8;
|
||||
const uint8_t PERIOD_SPACES_KEY = 9;
|
||||
const uint8_t ALPHA_2_SPACES_KEY = 10;
|
||||
const uint8_t INDEX_KEY = 11;
|
||||
const uint8_t CAL_KEY = 12;
|
||||
const uint8_t T_KEY = 13;
|
||||
const uint8_t TS_KEY = 14;
|
||||
const uint8_t COMMA_SPACE_KEY = 15;
|
||||
const uint8_t CALI_HELP_1_KEY = 16;
|
||||
const uint8_t CALI_HELP_2_KEY = 17;
|
||||
const uint8_t CALI_HELP_3_KEY = 18;
|
||||
const uint8_t CALI_HELP_4_KEY = 19;
|
||||
const uint8_t CALI_HELP_5_KEY = 20;
|
||||
const uint8_t CALI_HELP_6_KEY = 21;
|
||||
const uint8_t CALI_SHOW_1_KEY = 22;
|
||||
const uint8_t CALI_SHOW_2_KEY = 23;
|
||||
const uint8_t SET_TEMPERATURE_DEBUG_1_KEY = 24;
|
||||
const uint8_t SET_TEMPERATURE_DEBUG_2_KEY = 25;
|
||||
const uint8_t SET_TEMPERATURE_DEBUG_3_KEY = 26;
|
||||
const uint8_t CONF_COLON_KEY = 27;
|
||||
const uint8_t MODE_COLON_KEY = 28;
|
||||
const uint8_t THERMOMETER_BEGIN_1_KEY = 29;
|
||||
const uint8_t STATE_0_KEY = 30;
|
||||
const uint8_t TO_STATE_1_KEY = 31;
|
||||
const uint8_t TO_STATE_10_KEY = 32;
|
||||
const uint8_t STATE_9_KEY = 33;
|
||||
const uint8_t STATE_9_DEBUG_1 = 34;
|
||||
const uint8_t STATE_10_KEY = 35;
|
||||
const uint8_t CALIBRATION_MODE_HINT_KEY = 36;
|
||||
const uint8_t TO_STATE_11_KEY = 37;
|
||||
const uint8_t STATE_20_MSG_1_KEY = 38;
|
||||
const uint8_t STATE_20_MSG_2_KEY = 39;
|
||||
const uint8_t STATE_20_MSG_3_KEY = 40;
|
||||
const uint8_t STATE_20_MSG_4_KEY = 41;
|
||||
const uint8_t COLON_SPACE_KEY = 42;
|
||||
|
||||
|
||||
/*
|
||||
const String TEXT_RESOURCES[] = {
|
||||
"Text1",
|
||||
"PeriodMeasure (ms): ",
|
||||
"Alpha: ",
|
||||
"Calibration: ",
|
||||
"Info: ",
|
||||
"Debug: ",
|
||||
"COMPILE_TIME_DEBUG: ",
|
||||
"TimeOuts: ",
|
||||
"Cycles: ",
|
||||
"Period (ms): ",
|
||||
"Alpha: ",
|
||||
"index: ",
|
||||
"cal: ",
|
||||
"t: ",
|
||||
"ts: ",
|
||||
", ",
|
||||
" enable : enable the calibration mode",
|
||||
" disable : disable the calibration mode",
|
||||
" show : show parameters for calibration process",
|
||||
" r : set value of calibration resistor",
|
||||
" start <0..3>: start calibration on channel",
|
||||
" stop <10..3>: stop calibration on channel",
|
||||
" enabled : ",
|
||||
" r_cal : ",
|
||||
"setTemperature: i=",
|
||||
"t=",
|
||||
"t_smoothed=",
|
||||
"CONF: ",
|
||||
"MODE: ",
|
||||
"Initializing EEPROM",
|
||||
"State 0",
|
||||
"Switching to State 1",
|
||||
"Switching to State 10",
|
||||
"State 9",
|
||||
"Timeout: ",
|
||||
"State 10",
|
||||
"No, no, we are in calibration mode, so directly switch to state 20",
|
||||
"Switching to state 11",
|
||||
"r_avg on channel ",
|
||||
"calibration factor: ",
|
||||
"Calibration stopped",
|
||||
"Save calibration factor for channel ",
|
||||
": ",
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
const String& getResource(uint8_t key);
|
||||
|
||||
|
||||
|
||||
#endif /* RESOURCES_H_ */
|
@ -5,6 +5,8 @@
|
||||
#include "Streaming.h"
|
||||
#include "Config.h"
|
||||
|
||||
#include "Resources.h"
|
||||
|
||||
|
||||
|
||||
const bool COMPILE_TIME_DEBUG = false;
|
||||
@ -37,15 +39,15 @@ String ThermConfig::exec(String params) {
|
||||
bool b = (strcmp(pb1, "on") == 0);
|
||||
m_thermometer->setInfo(b);
|
||||
} else if (params.equalsIgnoreCase("show")) {
|
||||
m_stream->print("PeriodMeasure (ms): "); m_stream->print(m_thermometer->getPeriodMeasure()); m_stream->println();
|
||||
m_stream->print("Alpha: "); m_stream->print(m_thermometer->getAlpha()); m_stream->println();
|
||||
m_stream->print(getResource(PERIOD_MEASURE_KEY)); m_stream->print(m_thermometer->getPeriodMeasure()); m_stream->println();
|
||||
m_stream->print(getResource(ALPHA_SPACES_KEY)); m_stream->print(m_thermometer->getAlpha()); m_stream->println();
|
||||
for (unsigned int i = 0; i < NUM_OF_CHANNELS; i++) {
|
||||
m_stream->print("Calibration: "); m_stream->print(i); m_stream->print(", ");
|
||||
m_stream->print(getResource(CALIBRATION_SPACES_KEY)); m_stream->print(i); m_stream->print(getResource(COMMA_SPACE_KEY));
|
||||
m_stream->print(m_thermometer->getCalibrateFactor(i), 6); m_stream->println();
|
||||
}
|
||||
m_stream->print("Info: "); m_stream->print(m_thermometer->getInfo()); m_stream->println();
|
||||
m_stream->print("Debug: "); m_stream->print(m_thermometer->getDebug()); m_stream->println();
|
||||
m_stream->print("COMPILE_TIME_DEBUG: "); m_stream->print(COMPILE_TIME_DEBUG); m_stream->println();
|
||||
m_stream->print(getResource(INFO_SPACES_KEY)); m_stream->print(m_thermometer->getInfo()); m_stream->println();
|
||||
m_stream->print(getResource(DEBUG_SPACES_KEY)); m_stream->print(m_thermometer->getDebug()); m_stream->println();
|
||||
m_stream->print(getResource(COMPILE_TIME_DEBUG_KEY)); m_stream->print(COMPILE_TIME_DEBUG); m_stream->println();
|
||||
|
||||
} else {
|
||||
res = "subcommand not found";
|
||||
@ -54,16 +56,16 @@ String ThermConfig::exec(String params) {
|
||||
}
|
||||
|
||||
String ThermValues::exec(String params) {
|
||||
m_stream->print("TimeOuts: "); m_stream->print(m_thermometer->m_timeOutFailureCnt); m_stream->println();
|
||||
m_stream->print("Cycles: "); m_stream->print(m_thermometer->m_cylceCnt); m_stream->println();
|
||||
m_stream->print("Period (ms): "); m_stream->print(m_thermometer->getPeriodMeasure()); m_stream->println();
|
||||
m_stream->print("Alpha: "); m_stream->print(m_thermometer->getAlpha()); m_stream->println();
|
||||
m_stream->print(getResource(TIMEOUTS_SPACES_KEY)); m_stream->print(m_thermometer->m_timeOutFailureCnt); m_stream->println();
|
||||
m_stream->print(getResource(CYCLES_SPACES_KEY)); m_stream->print(m_thermometer->m_cylceCnt); m_stream->println();
|
||||
m_stream->print(getResource(PERIOD_SPACES_KEY)); m_stream->print(m_thermometer->getPeriodMeasure()); m_stream->println();
|
||||
m_stream->print(getResource(ALPHA_2_SPACES_KEY)); m_stream->print(m_thermometer->getAlpha()); m_stream->println();
|
||||
|
||||
for (unsigned int i = 0; i < NUM_OF_CHANNELS; i++) {
|
||||
m_stream->print("index: "); m_stream->print(i); m_stream->print(", ");
|
||||
m_stream->print("cal: "); m_stream->print(m_thermometer->getCalibrateFactor(i), 6); m_stream->print(", ");
|
||||
m_stream->print("t: "); m_stream->print(m_thermometer->m_temperature[i]); m_stream->print(", ");
|
||||
m_stream->print("ts: "); m_stream->print(m_thermometer->m_smoothedTemperature[i]);
|
||||
m_stream->print(getResource(INDEX_KEY)); m_stream->print(i); m_stream->print(", ");
|
||||
m_stream->print(getResource(CAL_KEY)); m_stream->print(m_thermometer->getCalibrateFactor(i), 6); m_stream->print(getResource(COMMA_SPACE_KEY));
|
||||
m_stream->print(getResource(T_KEY)); m_stream->print(m_thermometer->m_temperature[i]); m_stream->print(getResource(COMMA_SPACE_KEY));
|
||||
m_stream->print(getResource(TS_KEY)); m_stream->print(m_thermometer->m_smoothedTemperature[i]);
|
||||
m_stream->println();
|
||||
}
|
||||
|
||||
@ -90,12 +92,12 @@ String ThermCalibrate::exec(String params) {
|
||||
} else if (params.startsWith("disable")) {
|
||||
m_enabled = false;
|
||||
} else if (params.startsWith("help")) {
|
||||
*m_stream << " enable : enable the calibration mode" << endl;
|
||||
*m_stream << " disable : disable the calibration mode" << endl;
|
||||
*m_stream << " show : show parameters for calibration process" << endl;
|
||||
*m_stream << " r : set value of calibration resistor" << endl;
|
||||
*m_stream << " start <0..3>: start calibration on channel" << endl;
|
||||
*m_stream << " stop <10..3>: stop calibration on channel" << endl;
|
||||
*m_stream << getResource(CALI_HELP_1_KEY) << endl;
|
||||
*m_stream << getResource(CALI_HELP_2_KEY) << endl;
|
||||
*m_stream << getResource(CALI_HELP_3_KEY) << endl;
|
||||
*m_stream << getResource(CALI_HELP_4_KEY) << endl;
|
||||
*m_stream << getResource(CALI_HELP_5_KEY) << endl;
|
||||
*m_stream << getResource(CALI_HELP_6_KEY) << endl;
|
||||
} else if (params.startsWith("start ") && (space != -1) && m_enabled) {
|
||||
m_channel = atoi(pb1);
|
||||
if ((m_channel + 1) > NUM_OF_CHANNELS) {
|
||||
@ -108,8 +110,8 @@ String ThermCalibrate::exec(String params) {
|
||||
} else if (params.startsWith("r ") && (space != -1)) {
|
||||
m_r_cal = atof(pb1);
|
||||
} else if (params.equalsIgnoreCase("show")) {
|
||||
*m_stream << " enabled : " << m_enabled << endl;
|
||||
*m_stream << " r_cal : " << m_r_cal << endl;
|
||||
*m_stream << getResource(CALI_SHOW_1_KEY) << m_enabled << endl;
|
||||
*m_stream << getResource(CALI_SHOW_2_KEY) << m_r_cal << endl;
|
||||
} else {
|
||||
res = "subcommand not found";
|
||||
}
|
||||
@ -190,8 +192,9 @@ void Thermometer::setTemperature(unsigned int index, float t) {
|
||||
m_smoothedTemperature[index] = getAlpha() * t + (1 - m_alpha) * m_lastSmoothedTemperature[index];
|
||||
}
|
||||
if (getDebug() || getInfo()) {
|
||||
Serial.print("setTemperature: i="); Serial.print(index); Serial.print(", t="); Serial.print(t);
|
||||
Serial.print(", t_smoothed="); Serial.print(m_smoothedTemperature[index]);
|
||||
Serial.print(getResource(SET_TEMPERATURE_DEBUG_1_KEY)); Serial.print(index); Serial.print(getResource(COMMA_SPACE_KEY));
|
||||
Serial.print(getResource(SET_TEMPERATURE_DEBUG_2_KEY)); Serial.print(t); Serial.print(getResource(COMMA_SPACE_KEY));
|
||||
Serial.print(getResource(SET_TEMPERATURE_DEBUG_3_KEY)); Serial.print(m_smoothedTemperature[index]);
|
||||
Serial.println();
|
||||
}
|
||||
m_lastSmoothedTemperature[index] = m_smoothedTemperature[index];
|
||||
@ -205,7 +208,7 @@ void Thermometer::prepareAdc() {
|
||||
AD7190_CONF_CHAN(1 << AD7190_CH_AIN2P_AINCOM) |
|
||||
AD7190_CONF_CHAN(1 << AD7190_CH_AIN3P_AINCOM) |
|
||||
AD7190_CONF_CHAN(1 << AD7190_CH_AIN4P_AINCOM);
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("CONF: "); Serial.print(newRegValue, 16); Serial.println(); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print(getResource(CONF_COLON_KEY)); Serial.print(newRegValue, 16); Serial.println(); }
|
||||
AD7190_SetRegisterValue(AD7190_REG_CONF, newRegValue, 3, 1);
|
||||
|
||||
newRegValue = AD7190_MODE_SEL(AD7190_MODE_IDLE) |
|
||||
@ -213,7 +216,7 @@ void Thermometer::prepareAdc() {
|
||||
AD7190_MODE_REJ60 |
|
||||
AD7190_MODE_DAT_STA |
|
||||
AD7190_MODE_RATE(0x060);
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("MODE: "); Serial.print(newRegValue, 16); Serial.println(); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print(getResource(MODE_COLON_KEY)); Serial.print(newRegValue, 16); Serial.println(); }
|
||||
|
||||
AD7190_SetRegisterValue(AD7190_REG_MODE, newRegValue, 3, 1);
|
||||
}
|
||||
@ -222,7 +225,7 @@ void Thermometer::startSingleConv() {
|
||||
unsigned long oldRegValue = AD7190_GetRegisterValue(AD7190_REG_MODE, 3, 0);
|
||||
oldRegValue &= ~(AD7190_MODE_SEL(0x07));
|
||||
unsigned long newRegValue = oldRegValue | AD7190_MODE_SEL(AD7190_MODE_SINGLE);
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("MODE: "); Serial.print(newRegValue, 16); Serial.println(); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print(getResource(MODE_COLON_KEY)); Serial.print(newRegValue, 16); Serial.println(); }
|
||||
AD7190_SetRegisterValue(AD7190_REG_MODE, newRegValue, 3, 0);
|
||||
}
|
||||
|
||||
@ -253,7 +256,7 @@ void Thermometer::begin(CmdServer *cmdServer) {
|
||||
|
||||
|
||||
if (! Config::isInitialized()) {
|
||||
Serial << "Initializing EEPROM" << endl;
|
||||
Serial << getResource(THERMOMETER_BEGIN_1_KEY) << endl;
|
||||
Config::setFloat(Config::THERMOMETER_ALPHA, 1.0);
|
||||
Config::setULong(Config::THERMOMETER_PERIOD, 1000);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
@ -294,13 +297,13 @@ void Thermometer::exec() {
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println(); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println("State 0"); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println(getResource(STATE_0_KEY)); }
|
||||
// start conversion
|
||||
SPI_Enable(AD7190_SLAVE_ID);
|
||||
startSingleConv();
|
||||
|
||||
state = 1;
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println("Switching to State 1"); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println(getResource(TO_STATE_1_KEY)); }
|
||||
|
||||
timeOutCnt = CONV_TIMEOUT;
|
||||
m_cylceCnt++;
|
||||
@ -322,7 +325,7 @@ void Thermometer::exec() {
|
||||
channelCnt++;
|
||||
if (channelCnt >= 4) {
|
||||
state = 10;
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println("Switching to State 10"); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println(getResource(TO_STATE_10_KEY)); }
|
||||
}
|
||||
|
||||
timeOutCnt = CONV_TIMEOUT;
|
||||
@ -331,7 +334,7 @@ void Thermometer::exec() {
|
||||
break;
|
||||
|
||||
case 9:
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println("State 9"); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println(getResource(STATE_9_KEY)); }
|
||||
|
||||
|
||||
// end cycle
|
||||
@ -341,39 +344,39 @@ void Thermometer::exec() {
|
||||
m_timeOutFailureCnt++;
|
||||
|
||||
if (getDebug() || getInfo()) {
|
||||
Serial << "Timeout: " << m_timeOutFailureCnt << endl;
|
||||
Serial << getResource(STATE_9_DEBUG_1) << m_timeOutFailureCnt << endl;
|
||||
}
|
||||
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
case 10:
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println("State 10"); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println(getResource(STATE_10_KEY)); }
|
||||
|
||||
SPI_Disable(AD7190_SLAVE_ID);
|
||||
|
||||
if (m_calibrationMode || thermCalibrate.m_start_calibration) {
|
||||
Serial << "No, no, we are in calibration mode, so directly switch to state 20" << endl;
|
||||
Serial << getResource(CALIBRATION_MODE_HINT_KEY) << endl;
|
||||
state = 20;
|
||||
} else {
|
||||
for (unsigned int i = 0; i < NUM_OF_CHANNELS; i++) {
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("i="); Serial.print(i); Serial.print(", "); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("m_n="); Serial.print(m_n[i]); Serial.print(", "); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print(""); Serial.print((m_n[i] - ((i == 3) ? 0 : m_n[i + 1]))); Serial.print(", "); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("calibrateFactor="); Serial.print(getCalibrateFactor(i), 6); Serial.print(", "); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("i="); Serial.print(i); Serial.print(getResource(COMMA_SPACE_KEY)); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("m_n="); Serial.print(m_n[i]); Serial.print(getResource(COMMA_SPACE_KEY)); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print(""); Serial.print((m_n[i] - ((i == 3) ? 0 : m_n[i + 1]))); Serial.print(getResource(COMMA_SPACE_KEY)); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("calibrateFactor="); Serial.print(getCalibrateFactor(i), 6); Serial.print(getResource(COMMA_SPACE_KEY)); }
|
||||
float r = (((float)(m_n[i] - ((i == 3) ? 0 : m_n[i + 1]))) / ((float)N_MAX)) * R_REF * getCalibrateFactor(i);
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("r="); Serial.print(r); Serial.print(", "); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("r="); Serial.print(r); Serial.print(getResource(COMMA_SPACE_KEY)); }
|
||||
float t = pt1000(r);
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("t="); Serial.print(t); Serial.print(", "); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("t="); Serial.print(t); Serial.print(getResource(COMMA_SPACE_KEY)); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println(); }
|
||||
setTemperature(i, t);
|
||||
}
|
||||
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("timeOuts="); Serial.print(m_timeOutFailureCnt); Serial.print(", "); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("cycles="); Serial.print(m_cylceCnt); Serial.print(", "); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("timeOuts="); Serial.print(m_timeOutFailureCnt); Serial.print(getResource(COMMA_SPACE_KEY)); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("cycles="); Serial.print(m_cylceCnt); Serial.print(getResource(COMMA_SPACE_KEY)); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println(); }
|
||||
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println("Switching to state 11"); }
|
||||
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.println(getResource(TO_STATE_11_KEY)); }
|
||||
state = 11;
|
||||
}
|
||||
break;
|
||||
@ -396,9 +399,9 @@ void Thermometer::exec() {
|
||||
}
|
||||
(thermCalibrate.m_turn)++;
|
||||
float r_avg = thermCalibrate.m_r_sum / thermCalibrate.m_turn;
|
||||
Serial << "r_avg on channel " << thermCalibrate.m_channel << ": " << _FLOAT(r_avg, 6) << endl;
|
||||
Serial << getResource(STATE_20_MSG_1_KEY) << thermCalibrate.m_channel << ": " << _FLOAT(r_avg, 6) << endl;
|
||||
float calFact = thermCalibrate.m_r_cal / r_avg;
|
||||
Serial << "calibration factor: " << _FLOAT(calFact, 6) << endl;
|
||||
Serial << getResource(STATE_20_MSG_2_KEY) << _FLOAT(calFact, 6) << endl;
|
||||
} else {
|
||||
thermCalibrate.m_preserved_alpha = m_alpha;
|
||||
m_alpha = 1;
|
||||
@ -415,10 +418,10 @@ void Thermometer::exec() {
|
||||
m_alpha = thermCalibrate.m_preserved_alpha;
|
||||
m_periodMillis = thermCalibrate.m_preserved_period;
|
||||
m_period = Metro(m_periodMillis);
|
||||
Serial << "Calibration stopped" << endl;
|
||||
Serial << getResource(STATE_20_MSG_3_KEY) << endl;
|
||||
float r_avg = thermCalibrate.m_r_sum / thermCalibrate.m_turn;
|
||||
float calFact = thermCalibrate.m_r_cal / r_avg;
|
||||
Serial << "Save calibration factor for channel " << thermCalibrate.m_channel <<": " << _FLOAT(calFact, 6) << endl;
|
||||
Serial << getResource(STATE_20_MSG_4_KEY) << thermCalibrate.m_channel << getResource(COLON_SPACE_KEY) << _FLOAT(calFact, 6) << endl;
|
||||
setCalibrateFactor(thermCalibrate.m_channel, calFact);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user