You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
2.3 KiB
C
119 lines
2.3 KiB
C
#include "lcd.h"
|
|
#include "menu.h"
|
|
#include <stdio.h>
|
|
|
|
// 0 = nothing selected
|
|
// 1 = change zone 1
|
|
// 2 = change zone 2
|
|
// 3 = change zone 3
|
|
volatile uint8_t menu_state = 0;
|
|
|
|
void write_heater_real_temp(uint8_t n, uint16_t temp){
|
|
|
|
}
|
|
|
|
void write_heater_set_temp(uint8_t n, uint16_t temp){
|
|
|
|
}
|
|
|
|
void update_cursor(){
|
|
switch(menu_state){
|
|
case 1:
|
|
lcd_set_position(2,8);
|
|
lcd_cursor(1);
|
|
break;
|
|
case 2:
|
|
lcd_set_position(2,13);
|
|
lcd_cursor(1);
|
|
break;
|
|
case 3:
|
|
lcd_set_position(2,18);
|
|
lcd_cursor(1);
|
|
break;
|
|
default:
|
|
lcd_cursor(0);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void draw_menu(){
|
|
lcd_clear();
|
|
lcd_write(" Heat Zone Control");
|
|
lcd_set_position(2, 0);
|
|
lcd_write(" set:");
|
|
lcd_set_position(3, 0);
|
|
lcd_write("real:");
|
|
//char str[16];
|
|
//sprintf(str, "test %d", 1);
|
|
//lcd_print_str(str);
|
|
}
|
|
|
|
void write_temps(){
|
|
char str[4];
|
|
|
|
lcd_set_position(3, 6);
|
|
sprintf(str, "%3i", temp_values[0]);
|
|
str[3] = 0xDF;
|
|
lcd_print_str(str);
|
|
|
|
lcd_set_position(3, 11);
|
|
sprintf(str, "%3i", temp_values[1]);
|
|
str[3] = 0xDF;
|
|
lcd_print_str(str);
|
|
|
|
lcd_set_position(3, 16);
|
|
sprintf(str, "%3d", temp_values[2]);
|
|
str[3] = 0xDF;
|
|
lcd_print_str(str);
|
|
}
|
|
|
|
void write_setpoints(){
|
|
char str[4];
|
|
|
|
lcd_set_position(2, 6);
|
|
sprintf(str, "%3i", temp_setpoints[0]);
|
|
str[3] = 0xDF;
|
|
lcd_print_str(str);
|
|
|
|
lcd_set_position(2, 11);
|
|
sprintf(str, "%3i%%", temp_setpoints[1]);
|
|
lcd_print_str(str);
|
|
|
|
lcd_set_position(2, 16);
|
|
sprintf(str, "%3i%%", temp_setpoints[2]);
|
|
lcd_print_str(str);
|
|
}
|
|
|
|
void set_item(uint8_t page_num){
|
|
//if(menu_state=page_num)
|
|
// menu_state=0;
|
|
//else
|
|
menu_state = page_num;
|
|
}
|
|
|
|
void enc_init(){
|
|
PORTD |= (1<<6) | (1 << 7);
|
|
PCICR |= (1<<PCIE2);
|
|
PCMSK2 |= (1<<PCINT23);
|
|
}
|
|
|
|
|
|
|
|
void encoder_isr(){
|
|
//TODO good quadrature reading code
|
|
if((PIND & (1<<7)) && (menu_state >= 1) && (menu_state <= 3)){
|
|
if(PIND & (1<<6))
|
|
temp_setpoints[menu_state-1]--;
|
|
else
|
|
temp_setpoints[menu_state-1]++;
|
|
}
|
|
|
|
//if(PIND & (1<<7))
|
|
// if(PIND & (1<<6)){
|
|
// if(temp_setpoints[menu_state] > 0)
|
|
// }
|
|
// else{
|
|
// if(temp_setpoints[menu_state] < 300)
|
|
// }
|
|
}
|