220 lines
4.7 KiB
C++
220 lines
4.7 KiB
C++
#include "profile.h"
|
|
#include "oven_control.h"
|
|
#include <LiquidCrystal.h>
|
|
#include <DFR_Key.h>
|
|
|
|
|
|
|
|
//
|
|
// state: temp_min, temp_max, duration
|
|
//
|
|
//
|
|
//
|
|
|
|
// x0 = time of last_state.temp_max
|
|
// y0 = time of last_state.temp_max
|
|
|
|
// x1 = xa + state.duration
|
|
// y1 = state.temp_max
|
|
|
|
|
|
// x = actual_time
|
|
// y = y0 + ((x - x0) * y1 - (x - x0) * y0) / (x1 - x0)
|
|
|
|
// preheat, soak, tal1, soak, tal2, rampdown
|
|
|
|
|
|
Profile::Profile() :
|
|
data {150, // °C
|
|
200, // °C
|
|
217, // °C
|
|
260, // 245-260°C
|
|
480, // seconds
|
|
|
|
0, // ts ramp up rates
|
|
2,
|
|
0, // tp ramp up rates
|
|
2,
|
|
-1, // ramp down rates
|
|
-6,
|
|
|
|
// profile temp durations
|
|
60,
|
|
180,
|
|
60,
|
|
150,
|
|
20,
|
|
40},
|
|
config_index(0),
|
|
config_state(CS_MENU),
|
|
key(NO_KEY) {}
|
|
|
|
boolean Profile::handle_config_state() {
|
|
boolean changed = false;
|
|
|
|
key = keypad.getKey();
|
|
|
|
switch (config_state) {
|
|
case CS_MENU:
|
|
if (key == SELECT_KEY) {
|
|
config_state = CS_END;
|
|
}
|
|
else if (key > 0) {
|
|
config_state = CS_EDIT;
|
|
print_config_state();
|
|
}
|
|
break;
|
|
case CS_EDIT:
|
|
switch (key) {
|
|
case LEFT_KEY:
|
|
config_index = (config_index-1) % PI_END;
|
|
changed = true;
|
|
break;
|
|
case RIGHT_KEY:
|
|
config_index = (config_index+1) % PI_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 = CS_END;
|
|
break;
|
|
default:
|
|
;
|
|
}
|
|
if (changed)
|
|
print_config_state();
|
|
break;
|
|
case 2:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void Profile::print_config_state_0() {
|
|
lcd.clear();
|
|
lcd.setCursor(0, 0);
|
|
lcd.print("start | config");
|
|
lcd.setCursor(0, 1);
|
|
lcd.print("[sel] | [other]");
|
|
}
|
|
|
|
void Profile::print_config_state() {
|
|
lcd.clear();
|
|
switch (config_index) {
|
|
case PI_TS_MIN:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("PI_TS_MIN: ");
|
|
lcd.print(data[PI_TS_MIN]);
|
|
break;
|
|
case PI_TS_MAX:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("PI_TS_MAX: ");
|
|
lcd.print(data[PI_TS_MAX]);
|
|
break;
|
|
case PI_TL:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("Tl: ");
|
|
lcd.print(data[PI_TL]);
|
|
break;
|
|
case PI_TP_MIN:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("Tp min: ");
|
|
lcd.print(data[PI_TP_MIN]);
|
|
break;
|
|
case PI_TP_MAX:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("Tp max: ");
|
|
lcd.print(data[PI_TP_MAX]);
|
|
break;
|
|
case PI_TIME_MAX:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("time_max: ");
|
|
lcd.print(data[PI_TIME_MAX]);
|
|
break;
|
|
|
|
// PROFILE TEMP PER SECOND RATES
|
|
case PI_TS_RAMP_UP_MIN:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("ramp_up_min: ");
|
|
lcd.print(data[PI_TS_RAMP_UP_MIN]);
|
|
break;
|
|
case PI_TS_RAMP_UP_MAX:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("ramp_up_max: ");
|
|
lcd.print(data[PI_TS_RAMP_UP_MAX]);
|
|
break;
|
|
case PI_TP_RAMP_UP_MIN:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("ramp_up_min: ");
|
|
lcd.print(data[PI_TP_RAMP_UP_MIN]);
|
|
break;
|
|
case PI_TP_RAMP_UP_MAX:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("ramp_up_max: ");
|
|
lcd.print(data[PI_TP_RAMP_UP_MAX]);
|
|
break;
|
|
case PI_RAMP_DOWN_MAX:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("ramp_down_min: ");
|
|
lcd.print(data[PI_RAMP_DOWN_MIN]);
|
|
break;
|
|
case PI_RAMP_DOWN_MIN:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("ramp_down_max: ");
|
|
lcd.print(data[PI_RAMP_DOWN_MAX]);
|
|
break;
|
|
|
|
// PROFILE TEMP DURATIONS
|
|
case PI_TS_DURATION_MIN:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("Ts_duration_min: ");
|
|
lcd.print(data[PI_TS_DURATION_MIN]);
|
|
break;
|
|
case PI_TS_DURATION_MAX:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("Ts_duration_max: ");
|
|
lcd.print(data[PI_TS_DURATION_MAX]);
|
|
break;
|
|
case PI_TL_DURATION_MIN:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("Tl_duration_min: ");
|
|
lcd.print(data[PI_TL_DURATION_MIN]);
|
|
break;
|
|
case PI_TL_DURATION_MAX:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("Tl_duration_max: ");
|
|
lcd.print(data[PI_TL_DURATION_MAX]);
|
|
break;
|
|
case PI_TP_DURATION_MIN:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("Tp_duration_min: ");
|
|
lcd.print(data[PI_TP_DURATION_MIN]);
|
|
break;
|
|
case PI_TP_DURATION_MAX:
|
|
lcd.setCursor(0,0);
|
|
lcd.print("Tp_duration_max: ");
|
|
lcd.print(data[PI_TP_DURATION_MAX]);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void set_std_profile() {
|
|
// ProfileState * ps = &states[0];
|
|
// ps->temp_min = 150;
|
|
// ps->duration = -1;
|
|
//
|
|
// ps = &states[1];
|
|
// ps->temp_min = 200;
|
|
// ps->duration = 100;
|
|
}
|
|
|
|
Profile2 std_profile = Profile2();
|
|
|