prelimary lcd shield support

This commit is contained in:
Stefan Kögl 2012-10-21 13:47:44 +02:00
parent 85126113e8
commit 97572dbe10
2 changed files with 78 additions and 54 deletions

View File

@ -12,7 +12,7 @@ cmake_minimum_required(VERSION 2.8.5)
project(ReflowCtl C CXX) project(ReflowCtl C CXX)
set(ARDUINO_DEFAULT_BOARD diecimila) # Default Board ID, when not specified set(ARDUINO_DEFAULT_BOARD atmega328) # Default Board ID, when not specified
set(ARDUINO_DEFAULT_PORT /dev/ttyUSB0) # Default Port, when not specified set(ARDUINO_DEFAULT_PORT /dev/ttyUSB0) # Default Port, when not specified
link_directories(/usr/share/arduino/libraries) link_directories(/usr/share/arduino/libraries)
@ -20,4 +20,4 @@ link_directories(/usr/share/arduino/libraries)
generate_arduino_firmware(reflowctl generate_arduino_firmware(reflowctl
SKETCH reflowctl SKETCH reflowctl
PORT /dev/ttyUSB0 PORT /dev/ttyUSB0
BOARD diecimila) BOARD atmega328)

View File

@ -30,7 +30,6 @@ unsigned int temperature = 25; // actual oven temp
unsigned int last_temperature = 25; // last oven temp unsigned int last_temperature = 25; // last oven temp
int actual_dt = 0; // actual difference from last to actual temperatur int actual_dt = 0; // actual difference from last to actual temperatur
// profile temperatures // profile temperatures
unsigned int Ts_min = 150; // °C unsigned int Ts_min = 150; // °C
unsigned int Ts_max = 200; // °C unsigned int Ts_max = 200; // °C
@ -38,14 +37,12 @@ unsigned int Tl = 217; // 217°C
unsigned int Tp = 260; // 245-260°C unsigned int Tp = 260; // 245-260°C
unsigned int time_max = 480; // 8*60s max unsigned int time_max = 480; // 8*60s max
// profile temp per second rates // profile temp per second rates
unsigned int ramp_up_rate_min = 0; // not used yet unsigned int ramp_up_rate_min = 0; // not used yet
unsigned int ramp_up_rate_max = 50; // 3°C/s unsigned int ramp_up_rate_max = 50; // 3°C/s
unsigned int ramp_down_max = 6; // 6°C/s max unsigned int ramp_down_max = 6; // 6°C/s max
unsigned int ramp_down_min = 2; // 2°C/s max unsigned int ramp_down_min = 2; // 2°C/s max
// profile temp durations // profile temp durations
unsigned int Ts_duration_min = 60; // s unsigned int Ts_duration_min = 60; // s
unsigned int Ts_duration_max = 180; // s unsigned int Ts_duration_max = 180; // s
@ -54,7 +51,6 @@ unsigned int Tl_duration_max = 150; // 60-150s
unsigned int Tp_duration_min = 20; // 20-40s unsigned int Tp_duration_min = 20; // 20-40s
unsigned int Tp_duration_max = 40; // 20-40s unsigned int Tp_duration_max = 40; // 20-40s
// timestamps of event beginnings/ends // timestamps of event beginnings/ends
unsigned int Ts_time_start = 0; unsigned int Ts_time_start = 0;
unsigned int Ts_time_end = 0; unsigned int Ts_time_end = 0;
@ -63,7 +59,6 @@ unsigned int Tl_time_end = 0;
unsigned int Tp_time_start = 0; unsigned int Tp_time_start = 0;
unsigned int Tp_time_end = 0; unsigned int Tp_time_end = 0;
// thermostat // thermostat
unsigned int set_min = 0; unsigned int set_min = 0;
unsigned int set_max = 0; unsigned int set_max = 0;
@ -86,18 +81,46 @@ DFR_Key keypad;
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
delay(300);
pinMode(13, OUTPUT); pinMode(13, OUTPUT);
pinMode(2, INPUT);
set_start_state(); set_start_state();
lcd.begin(16, 2); lcd.begin(16, 2);
lcd.clear(); lcd.clear();
lcd.setCursor(0, 0);
lcd.print("hello, world!");
keypad.setRate(10); keypad.setRate(10);
Serial.println("init done");
} }
void print_profile_state() {
String tmp("P: ");
tmp += state;
tmp += "/";
tmp += error_condition;
lcd.setCursor(0, 1);
lcd.print(tmp);
}
void print_status() {
String tmp("s: ");
tmp += time;
tmp += " C: ";
tmp += temperature;
lcd.setCursor(0, 0);
lcd.print(tmp);
}
/* led edit mode procedures
* global menu (up/down) -> select
* start
* edit profile
* select value (up/down) -> select | left
* value (up/down) -> select | left
*
*/
void print_edit() {
}
void control_oven() { void control_oven() {
if (temperature < set_min && !is_oven_heating) { if (temperature < set_min && !is_oven_heating) {
is_oven_heating = true; is_oven_heating = true;
@ -381,50 +404,51 @@ void loop() {
get_temp(); get_temp();
check_dt(); check_dt();
if (!error_condition) { // if (!error_condition) {
print_debug(); // print_debug();
} // }
else { // else {
set_error_state(); // set_error_state();
} // }
//
switch (state) { // switch (state) {
case START_STATE: // case START_STATE:
handle_start_state(); // handle_start_state();
break; // break;
case PREHEAT_STATE: // case PREHEAT_STATE:
handle_preheat_state(); // handle_preheat_state();
break; // break;
case RAMP_UP_STATE: // case RAMP_UP_STATE:
handle_ramp_up_state(); // handle_ramp_up_state();
break; // break;
case TAL_FIRST_STATE: // case TAL_FIRST_STATE:
handle_tal_first_state(); // handle_tal_first_state();
break; // break;
case PEAK_STATE: // case PEAK_STATE:
handle_peak_state(); // handle_peak_state();
break; // break;
case TAL_SECOND_STATE: // case TAL_SECOND_STATE:
Tl_time_end = time; // Tl_time_end = time;
handle_tal_second_state(); // handle_tal_second_state();
break; // break;
case RAMP_DOWN_STATE: // case RAMP_DOWN_STATE:
handle_ramp_down_state(); // handle_ramp_down_state();
break; // break;
case END_STATE: // case END_STATE:
handle_end_state(); // handle_end_state();
break; // break;
case ERROR_STATE: // case ERROR_STATE:
handle_error_state(); // handle_error_state();
break; // break;
default: // default:
break; // break;
} // }
//
control_oven(); // control_oven();
lcd.clear(); lcd.clear();
lcd.setCursor(0, 0); print_debug();
lcd.print(time); print_status();
print_profile_state();
delay(1000); delay(1000);
} }