switch to teensy 3.0

This commit is contained in:
hg
2014-03-08 00:23:46 +01:00
parent 987be758ad
commit 89771e70d1
11 changed files with 269 additions and 207 deletions

View File

@ -63,8 +63,8 @@ String ThermValues::exec(String params) {
for (unsigned int i = 0; i < NUM_OF_CHANNELS; i++) {
m_stream->print(getResource(INDEX_KEY)); m_stream->print(i); m_stream->print(getResource(COMMA_SPACE_KEY));
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->print(getResource(T_KEY)); m_stream->print(m_thermometer->m_temperature[i], 6); m_stream->print(getResource(COMMA_SPACE_KEY));
m_stream->print(getResource(TS_KEY)); m_stream->print(m_thermometer->m_smoothedTemperature[i], 6);
m_stream->println();
}
@ -72,7 +72,7 @@ String ThermValues::exec(String params) {
}
ThermCalibrate::ThermCalibrate(Thermometer *thermometer) : m_thermometer(thermometer), m_enabled(false),
m_start_calibration(false), m_r_cal(1500.0) {
m_start_highCalibration(false), m_start_zeroCalibration(false), m_r_cal(1000.0) {
}
@ -102,10 +102,10 @@ String ThermCalibrate::exec(String params) {
if ((m_channel + 1) > NUM_OF_CHANNELS) {
res = "Invalid channel number";
} else {
m_start_calibration = true;
m_start_highCalibration = true;
}
} else if (params.startsWith("stop")) {
m_start_calibration = false;
m_start_highCalibration = false;
} else if (params.startsWith("r ") && (space != -1)) {
m_r_cal = atof(pb1);
} else if (params.equalsIgnoreCase("show")) {
@ -121,7 +121,7 @@ Thermometer::Thermometer() : m_periodMillis(DEFAULT_PERIOD),
m_debug(DEBUG), m_info(INFO),
thermConfig(this), thermValues(this), thermCalibrate(this),
m_timeOutFailureCnt(0), m_cylceCnt(0), m_alpha(1.0),
m_calibrationMode(false)
m_calibrationHighMode(false)
{
for (unsigned int i = 0; i < NUM_OF_CHANNELS; i++) {
m_lastSmoothedTemperature[i] = INVALID_TEMPERATURE;
@ -356,9 +356,12 @@ void Thermometer::exec() {
SPI_Disable(AD7190_SLAVE_ID);
if (m_calibrationMode || thermCalibrate.m_start_calibration) {
if (m_calibrationHighMode || thermCalibrate.m_start_highCalibration) {
Serial.println(getResource(CALIBRATION_MODE_HINT_KEY));
state = 20;
} else if (m_calibrationZeroMode || thermCalibrate.m_start_zeroCalibration) {
Serial.println(getResource(CALIBRATION_ZEOR_MODE_HINT_KEY));
state = 21;
} else {
for (unsigned int i = 0; i < NUM_OF_CHANNELS; i++) {
if (COMPILE_TIME_DEBUG && getDebug()) { Serial.print("i="); Serial.print(i); Serial.print(getResource(COMMA_SPACE_KEY)); }
@ -391,8 +394,8 @@ void Thermometer::exec() {
break;
case 20:
if (thermCalibrate.m_start_calibration) {
if (m_calibrationMode) {
if (thermCalibrate.m_start_highCalibration) {
if (m_calibrationHighMode) {
// do the calibration stuff
for (unsigned int i = 0; i < NUM_OF_CHANNELS; i++) {
float r = (((float)(m_n[i] - ((i == 3) ? 0 : m_n[i + 1]))) / ((float)N_MAX)) * R_REF;
@ -414,11 +417,11 @@ void Thermometer::exec() {
m_periodMillis = 500;
thermCalibrate.m_r_sum = 0.0;
thermCalibrate.m_turn = 0;
m_calibrationMode = true;
m_calibrationHighMode = true;
}
} else {
// end calibrationMode
m_calibrationMode = false;
m_calibrationHighMode = false;
m_alpha = thermCalibrate.m_preserved_alpha;
m_periodMillis = thermCalibrate.m_preserved_period;
Serial.println(getResource(STATE_20_MSG_3_KEY));
@ -432,6 +435,20 @@ void Thermometer::exec() {
state = 11;
break;
case 21:
if (thermCalibrate.m_start_zeroCalibration) {
if (m_calibrationZeroMode) {
// do the calibration stuff
} else {
m_calibrationZeroMode = true;
}
} else {
// end calibrationMode
m_calibrationZeroMode = false;
}
state = 11;
break;
default:
fatal(FATAL_ILLEGAL_STATE);