int i=0,o=0,n=0; //i:In o:Out n:Next b:Back.
int t[5]={0,0,0,0,0};
void menu_principal(void);
void posicion(void);
#int_TIMER0
void Timer0_isr(void)
{
if(!input(PIN_D0)) //Ver si se apreto el boton ENTRAR.
{
delay_ms(151);
i=1;
menu_principal();
i=0;
posicion();
}
if(!input(PIN_D1)) //Ver si se apreto el boton SALIR.
{
delay_ms(151);
o=1;
menu_principal();
o=0;
posicion();
}
if(!input(PIN_D2)) //Ver si se apreto el boton SIGUIENTE.
{
delay_ms(151);
n=1;
menu_principal();
n=0;
posicion();
}
set_timer0(252);
}
void menu_principal(void)
{
t[0]=(t[0]&(!t[3])&t[4]) | (t[0]&t[3]&(!t[4])) | (t[0]&t[2]) | (t[1]&t[2]&t[3]&t[4]&i) | (t[0]&(!o));
t[1]=(t[1]&(!t[3])&t[4]) | (t[1]&t[3]&(!t[4])) | ((!t[0])&(!t[1])&(!t[2])&(!t[3])&(!t[4])&n) | (t[1]&t[2]&(!i)) | (t[0]&(!t[2])&(!t[3])&(!t[4])&o) | (t[0]&t[3]&t[4]&o) | (t[1]&(!t[3])&i);
t[1]=t[1] | (t[1]&(!t[2])&t[4]&(!o));
t[2]=((!t[1])&t[2]&t[3]) | (t[1]&t[2]&(!t[3])&t[4]) | (t[2]&t[3]&(!t[4])) | ((!t[2])&t[3]&t[4]&i) | (t[2]&(!t[3])&(!o)) | (t[2]&n) | (t[0]&(!t[2])&(!t[3])&(!t[4])&o) | (t[0]&t[3]&t[4]&(!n));
t[3]=((!t[2])&(!t[3])&n)| (t[3]&(!t[4])&i) | (t[1]&t[2]&t[3]&(!o)) | (t[1]&(!t[3])&n) | (t[1]&t[2]&t[3]&t[4]&o) | (t[0]&t[3]&t[4]&o) | (t[2]&(!t[3])&(!t[4])&o) | (t[0]&(!t[3])&(!t[4])&o);
t[3]=t[3] | ((!t[1])&t[2]&(!t[3])&o) | ((!t[0])&(!t[1])&(!t[2])&t[4]&i);
t[4]=(t[0]&t[2]&t[4])| ((!t[2])&(!t[3])&i) | ((!t[1])&t[2]&o) | ((!t[1])&t[2]&t[3]&t[4]&(!n)) | (t[1]&(!t[3])&i) | (t[2]&t[3]&t[4]&o) | (t[0]&t[3]&t[4]&o) | (t[0]&(!t[2])&(!t[3])&(!t[4]));
t[4]=t[4] | ((!t[0])&(!t[4])&n) | (t[1]&t[2]&(!t[3])&(!t[4])) | ((!t[2])&(!t[4])&n);
}
void posicion(void)
{
if((t[0]==0)&(t[1]==0)&(t[2]==0)&(t[3]==0)&(t[4]==0))
{
lcd_putc('\f');
lcd_putc("Hora");
delay_ms(5);
}
if((t[0]==0)&(t[1]==0)&(t[2]==0)&(t[3]==0)&(t[4]==1))
{
lcd_putc('\f');
lcd_putc("Mostrar Hora");
}
if((t[0]==0)&(t[1]==0)&(t[2]==0)&(t[3]==1)&(t[4]==0))
{
lcd_putc('\f');
lcd_putc("Configurar Hora");
}
if((t[0]==0)&(t[1]==0)&(t[2]==0)&(t[3]==1)&(t[4]==1))
{
lcd_putc('\f');
lcd_putc("Temperatura");
}
if((t[0]==0)&(t[1]==0)&(t[2]==1)&(t[3]==0)&(t[4]==0))
{
lcd_putc('\f');
lcd_putc("Mostrar Temp");
}
if((t[0]==0)&(t[1]==0)&(t[2]==1)&(t[3]==0)&(t[4]==1))
{
lcd_putc('\f');
lcd_putc("Config Temp");
}
if((t[0]==0)&(t[1]==0)&(t[2]==1)&(t[3]==1)&(t[4]==0))
{
lcd_putc('\f');
lcd_putc("Temp Minima");
}
if((t[0]==0)&(t[1]==0)&(t[2]==1)&(t[3]==1)&(t[4]==1))
{
lcd_putc('\f');
lcd_putc("Temp Maxima");
}
if((t[0]==0)&(t[1]==1)&(t[2]==0)&(t[3]==0)&(t[4]==0))
{
lcd_putc('\f');
lcd_putc("Alarma");
}
if((t[0]==0)&(t[1]==1)&(t[2]==0)&(t[3]==0)&(t[4]==1))
{
lcd_putc('\f');
lcd_putc("Activada");
}
if((t[0]==0)&(t[1]==1)&(t[2]==0)&(t[3]==1)&(t[4]==0))
{
lcd_putc('\f');
lcd_putc("Desactivada");
}
if((t[0]==0)&(t[1]==1)&(t[2]==0)&(t[3]==1)&(t[4]==1))
{
lcd_putc('\f');
lcd_putc("Luz");
}
if((t[0]==0)&(t[1]==1)&(t[2]==1)&(t[3]==0)&(t[4]==0))
{
lcd_putc('\f');
lcd_putc("Programar Hora");
}
if((t[0]==0)&(t[1]==1)&(t[2]==1)&(t[3]==0)&(t[4]==1))
{
lcd_putc('\f');
lcd_putc("Hora ON");
}
if((t[0]==0)&(t[1]==1)&(t[2]==1)&(t[3]==1)&(t[4]==0))
{
lcd_putc('\f');
lcd_putc("Hora OFF");
}
if((t[0]==0)&(t[1]==1)&(t[2]==1)&(t[3]==1)&(t[4]==1))
{
lcd_putc('\f');
lcd_putc("Intensidad");
}
if((t[0]==1)&(t[1]==0)&(t[2]==0)&(t[3]==0)&(t[4]==0))
{
lcd_putc('\f');
lcd_putc("Automatico");
}
if((t[0]==1)&(t[1]==0)&(t[2]==0)&(t[3]==0)&(t[4]==1))
{
lcd_putc('\f');
lcd_putc("Activado");
}
if((t[0]==1)&(t[1]==0)&(t[2]==0)&(t[3]==1)&(t[4]==0))
{
lcd_putc('\f');
lcd_putc("Desactivado");
}
if((t[0]==1)&(t[1]==0)&(t[2]==0)&(t[3]==1)&(t[4]==1))
{
lcd_putc('\f');
lcd_putc("Manual");
}
if((t[0]==1)&(t[1]==0)&(t[2]==1)&(t[3]==0)&(t[4]==0))
{
lcd_putc('\f');
lcd_putc("Mas (+)");
}
if((t[0]==1)&(t[1]==0)&(t[2]==1)&(t[3]==0)&(t[4]==1))
{
lcd_putc('\f');
lcd_putc("Menos (-)");
}
}
1: Luz
1: Programar Hora
1: Hora de Encendido.
2: Hora de Apagado.
2: Intensidad
1: Automático.
1: Activado.
2: Desactivado.
2: Manual.
1: Nivel 1.
2: Nivel 2.
3: Nivel 3.
4: Nivel 4.
2: Alarma
1: Activado.
2: Desactivado.
3: Temperatura.
1: Mostrar.
2: Configurar.
1: Temperatura Minima.
2: Temperatura Maxima.
4: Hora
1: Mostrar Hora.
2: Configurar Hora.
D0: Entrar.
D1: Salir.
D2: Siguiente.
typedef union
{
unsigned int8 valor;
struct
{
unsigned b0:1;
unsigned b1:1;
unsigned b2:1;
unsigned b3:1;
unsigned b4:1;
unsigned b5:1;
unsigned i:1;
unsigned o:1;
unsigned n:1;
}bits;
}tbyte;
tbyte t, q;
q[0]=((t[0]&(!t[3]))&t[4]) | ((t[0]&t[3])&(!t[4])) | (t[0]&t[2]) | (((t[1]&t[2])&(t[3]&t[4]))&i) | (t[0]&(!o));
t[0]=q[0];