#include "lcd.h" #include "menu.h" #include // 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(0,5); lcd_cursor(1); break; case 2: lcd_set_position(0,9); lcd_cursor(1); break; case 3: 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); break; default: lcd_cursor(0); break; } } void draw_menu(){ lcd_clear(); lcd_set_position(0, 0); lcd_write("s:"); lcd_set_position(1, 0); lcd_write("r:"); lcd_set_position(2, 0); lcd_write("motor:"); lcd_set_position(3, 0); lcd_write("fan :"); } 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(){ char str[5]; str[4] = 0; //null terminated lcd_set_position(1, 3); sprintf(str, "%3i", temp_values[0]); str[3] = 0xDF; lcd_print_str(str); lcd_set_position(1, 7); sprintf(str, "%3i", temp_values[1]); str[3] = 0xDF; lcd_print_str(str); lcd_set_position(1, 12); sprintf(str, "%3d", temp_values[2]); str[3] = 0xDF; lcd_print_str(str); } void write_setpoints(){ char str[5]; str[4] = 0; //null terminated lcd_set_position(0, 3); sprintf(str, "%3i", temp_setpoints[0]); str[3] = 0xDF; lcd_print_str(str); lcd_set_position(0, 7); sprintf(str, "%3i%%", temp_setpoints[1]); lcd_print_str(str); lcd_set_position(0, 12); 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<= 1) && (menu_state <= 3)){ if(PIND & (1<<6)) 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<<6)){ // if(temp_setpoints[menu_state] > 0) // } // else{ // if(temp_setpoints[menu_state] < 300) // } }