|
|
|
@ -19,15 +19,23 @@ void write_heater_set_temp(uint8_t n, uint16_t temp){
|
|
|
|
void update_cursor(){
|
|
|
|
void update_cursor(){
|
|
|
|
switch(menu_state){
|
|
|
|
switch(menu_state){
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
lcd_set_position(2,8);
|
|
|
|
lcd_set_position(0,5);
|
|
|
|
lcd_cursor(1);
|
|
|
|
lcd_cursor(1);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
lcd_set_position(2,13);
|
|
|
|
lcd_set_position(0,9);
|
|
|
|
lcd_cursor(1);
|
|
|
|
lcd_cursor(1);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 3:
|
|
|
|
lcd_set_position(2,18);
|
|
|
|
lcd_set_position(0,14);
|
|
|
|
|
|
|
|
lcd_cursor(1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
|
|
lcd_set_position(2,9);
|
|
|
|
|
|
|
|
lcd_cursor(1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
|
|
lcd_set_position(3,9);
|
|
|
|
lcd_cursor(1);
|
|
|
|
lcd_cursor(1);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
@ -38,48 +46,59 @@ void update_cursor(){
|
|
|
|
|
|
|
|
|
|
|
|
void draw_menu(){
|
|
|
|
void draw_menu(){
|
|
|
|
lcd_clear();
|
|
|
|
lcd_clear();
|
|
|
|
lcd_write(" Heat Zone Control");
|
|
|
|
lcd_set_position(0, 0);
|
|
|
|
|
|
|
|
lcd_write("s:");
|
|
|
|
|
|
|
|
lcd_set_position(1, 0);
|
|
|
|
|
|
|
|
lcd_write("r:");
|
|
|
|
lcd_set_position(2, 0);
|
|
|
|
lcd_set_position(2, 0);
|
|
|
|
lcd_write(" set:");
|
|
|
|
lcd_write("motor:");
|
|
|
|
lcd_set_position(3, 0);
|
|
|
|
lcd_set_position(3, 0);
|
|
|
|
lcd_write("real:");
|
|
|
|
lcd_write("fan :");
|
|
|
|
//char str[16];
|
|
|
|
}
|
|
|
|
//sprintf(str, "test %d", 1);
|
|
|
|
|
|
|
|
//lcd_print_str(str);
|
|
|
|
void write_motor(){
|
|
|
|
|
|
|
|
char str[5];
|
|
|
|
|
|
|
|
str[4] = 0; //null terminated
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lcd_set_position(2, 7);
|
|
|
|
|
|
|
|
sprintf(str, "%3i", OCR2B);
|
|
|
|
|
|
|
|
lcd_print_str(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void write_temps(){
|
|
|
|
void write_temps(){
|
|
|
|
char str[4];
|
|
|
|
char str[5];
|
|
|
|
|
|
|
|
str[4] = 0; //null terminated
|
|
|
|
|
|
|
|
|
|
|
|
lcd_set_position(3, 6);
|
|
|
|
lcd_set_position(1, 3);
|
|
|
|
sprintf(str, "%3i", temp_values[0]);
|
|
|
|
sprintf(str, "%3i", temp_values[0]);
|
|
|
|
str[3] = 0xDF;
|
|
|
|
str[3] = 0xDF;
|
|
|
|
lcd_print_str(str);
|
|
|
|
lcd_print_str(str);
|
|
|
|
|
|
|
|
|
|
|
|
lcd_set_position(3, 11);
|
|
|
|
lcd_set_position(1, 7);
|
|
|
|
sprintf(str, "%3i", temp_values[1]);
|
|
|
|
sprintf(str, "%3i", temp_values[1]);
|
|
|
|
str[3] = 0xDF;
|
|
|
|
str[3] = 0xDF;
|
|
|
|
lcd_print_str(str);
|
|
|
|
lcd_print_str(str);
|
|
|
|
|
|
|
|
|
|
|
|
lcd_set_position(3, 16);
|
|
|
|
lcd_set_position(1, 12);
|
|
|
|
sprintf(str, "%3d", temp_values[2]);
|
|
|
|
sprintf(str, "%3d", temp_values[2]);
|
|
|
|
str[3] = 0xDF;
|
|
|
|
str[3] = 0xDF;
|
|
|
|
lcd_print_str(str);
|
|
|
|
lcd_print_str(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void write_setpoints(){
|
|
|
|
void write_setpoints(){
|
|
|
|
char str[4];
|
|
|
|
char str[5];
|
|
|
|
|
|
|
|
str[4] = 0; //null terminated
|
|
|
|
|
|
|
|
|
|
|
|
lcd_set_position(2, 6);
|
|
|
|
lcd_set_position(0, 3);
|
|
|
|
sprintf(str, "%3i", temp_setpoints[0]);
|
|
|
|
sprintf(str, "%3i", temp_setpoints[0]);
|
|
|
|
str[3] = 0xDF;
|
|
|
|
str[3] = 0xDF;
|
|
|
|
lcd_print_str(str);
|
|
|
|
lcd_print_str(str);
|
|
|
|
|
|
|
|
|
|
|
|
lcd_set_position(2, 11);
|
|
|
|
lcd_set_position(0, 7);
|
|
|
|
sprintf(str, "%3i%%", temp_setpoints[1]);
|
|
|
|
sprintf(str, "%3i%%", temp_setpoints[1]);
|
|
|
|
lcd_print_str(str);
|
|
|
|
lcd_print_str(str);
|
|
|
|
|
|
|
|
|
|
|
|
lcd_set_position(2, 16);
|
|
|
|
lcd_set_position(0, 12);
|
|
|
|
sprintf(str, "%3i%%", temp_setpoints[2]);
|
|
|
|
sprintf(str, "%3i%%", temp_setpoints[2]);
|
|
|
|
lcd_print_str(str);
|
|
|
|
lcd_print_str(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -101,11 +120,19 @@ void enc_init(){
|
|
|
|
|
|
|
|
|
|
|
|
void encoder_isr(){
|
|
|
|
void encoder_isr(){
|
|
|
|
//TODO good quadrature reading code
|
|
|
|
//TODO good quadrature reading code
|
|
|
|
if((PIND & (1<<7)) && (menu_state >= 1) && (menu_state <= 3)){
|
|
|
|
if((PIND & (1<<7))){
|
|
|
|
if(PIND & (1<<6))
|
|
|
|
if((menu_state >= 1) && (menu_state <= 3)){
|
|
|
|
temp_setpoints[menu_state-1]--;
|
|
|
|
if(PIND & (1<<6))
|
|
|
|
else
|
|
|
|
temp_setpoints[menu_state-1]--;
|
|
|
|
temp_setpoints[menu_state-1]++;
|
|
|
|
else
|
|
|
|
|
|
|
|
temp_setpoints[menu_state-1]++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(menu_state == 4){
|
|
|
|
|
|
|
|
if(PIND & (1<<6) && (OCR2B > 0))
|
|
|
|
|
|
|
|
OCR2B--;
|
|
|
|
|
|
|
|
else if(!(PIND & (1<<6)) && (OCR2B < 255))
|
|
|
|
|
|
|
|
OCR2B++;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//if(PIND & (1<<7))
|
|
|
|
//if(PIND & (1<<7))
|
|
|
|
|