reflow/libs/profile.cpp

191 lines
4.3 KiB
C++
Raw Normal View History

2012-10-25 15:07:57 +00:00
#include "profile.h"
#include "oven_control.h"
#include <LiquidCrystal.h>
#include <DFR_Key.h>
#define P_TS_MIN 0
#define P_TS_MAX 1
#define P_TL 2
#define P_TP 3
#define P_TIME_MAX 4
// PROFILE TEMP PER SECOND RATES
#define P_RAMP_UP_RATE_MIN 5
#define P_RAMP_UP_RATE_MAX 6
#define P_RAMP_DOWN_MAX 7
#define P_RAMP_DOWN_MIN 8
// PROFILE TEMP DURATIONS
#define P_TS_DURATION_MIN 9
#define P_TS_DURATION_MAX 10
#define P_TL_DURATION_MIN 11
#define P_TL_DURATION_MAX 12
#define P_TP_DURATION_MIN 13
#define P_TP_DURATION_MAX 14
#define P_END 15
Profile::Profile() :
data({150, // °C
200, // °C
217, // °C
260, // 245-260°C
480, // seconds
// profile temp per second rates
0, // not used yet
50, // 3°C/second
-2, // 2°C/seconds min
-6, // 6°C/seconds max
// profile temp durations
60,
180,
60,
150,
2012-10-26 06:45:05 +00:00
1,
2012-10-25 15:07:57 +00:00
40}),
config_index(0),
config_state(0),
key(NO_KEY) {}
boolean Profile::handle_config_state(LiquidCrystal * lcd, DFR_Key * keypad) {
boolean changed = false;
key = keypad->getKey();
switch (config_state) {
case 0:
if (key == SELECT_KEY) {
config_state = 2;
}
else if (key > 0) {
config_state++;
print_config_state(lcd);
}
break;
case 1:
switch (key) {
case LEFT_KEY:
config_index = (config_index-1) % P_END;
changed = true;
break;
case RIGHT_KEY:
config_index = (config_index+1) % P_END;
changed = true;
break;
case UP_KEY:
data[config_index]++;
changed = true;
break;
case DOWN_KEY:
data[config_index]--;
changed = true;
break;
case SELECT_KEY:
config_state = 2;
break;
default:
;
}
if (changed)
print_config_state(lcd);
break;
case 2:
return true;
}
return false;
}
void Profile::print_config_state_0(LiquidCrystal * lcd) {
lcd->clear();
lcd->setCursor(0, 0);
lcd->print("start | config");
lcd->setCursor(0, 1);
lcd->print("[sel] | [other]");
}
void Profile::print_config_state(LiquidCrystal * lcd) {
lcd->clear();
switch (config_index) {
case P_TS_MIN:
lcd->setCursor(0,0);
lcd->print("P_TS_MIN: ");
lcd->print(data[PI_TS_MIN]);
break;
case P_TS_MAX:
lcd->setCursor(0,0);
lcd->print("P_TS_MAX: ");
lcd->print(data[PI_TS_MAX]);
break;
case P_TL:
lcd->setCursor(0,0);
lcd->print("Tl: ");
lcd->print(data[PI_TL]);
break;
case P_TP:
lcd->setCursor(0,0);
lcd->print("Tp: ");
lcd->print(data[PI_TP]);
break;
case P_TIME_MAX:
lcd->setCursor(0,0);
lcd->print("time_max: ");
lcd->print(data[PI_TIME_MAX]);
break;
// PROFILE TEMP PER SECOND RATES
case P_RAMP_UP_RATE_MIN:
lcd->setCursor(0,0);
lcd->print("ramp_up_min: ");
lcd->print(data[PI_RAMP_UP_MIN]);
break;
case P_RAMP_UP_RATE_MAX:
lcd->setCursor(0,0);
lcd->print("ramp_up_max: ");
lcd->print(data[PI_RAMP_UP_MAX]);
break;
case P_RAMP_DOWN_MAX:
lcd->setCursor(0,0);
lcd->print("ramp_down_min: ");
lcd->print(data[PI_RAMP_DOWN_MIN]);
break;
case P_RAMP_DOWN_MIN:
lcd->setCursor(0,0);
lcd->print("ramp_down_max: ");
lcd->print(data[PI_RAMP_DOWN_MAX]);
break;
// PROFILE TEMP DURATIONS
case P_TS_DURATION_MIN:
lcd->setCursor(0,0);
lcd->print("Ts_duration_min: ");
lcd->print(data[PI_TS_DURATION_MIN]);
break;
case P_TS_DURATION_MAX:
lcd->setCursor(0,0);
lcd->print("Ts_duration_max: ");
lcd->print(data[PI_TS_DURATION_MAX]);
break;
case P_TL_DURATION_MIN:
lcd->setCursor(0,0);
lcd->print("Tl_duration_min: ");
lcd->print(data[PI_TL_DURATION_MIN]);
break;
case P_TL_DURATION_MAX:
lcd->setCursor(0,0);
lcd->print("Tl_duration_max: ");
lcd->print(data[PI_TL_DURATION_MAX]);
break;
case P_TP_DURATION_MIN:
lcd->setCursor(0,0);
lcd->print("Tp_duration_min: ");
lcd->print(data[PI_TP_DURATION_MIN]);
break;
case P_TP_DURATION_MAX:
lcd->setCursor(0,0);
lcd->print("Tp_duration_max: ");
lcd->print(data[PI_TP_DURATION_MAX]);
break;
}
}