Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Profesor:
Rafael Surga
Bachiller
Evelyn Gmez. C.I: 18.451.867
Cristal Martinez C.I: 19905329
2.2.- Si se activa la segunda opcin debe generarse una calculadora digital con las opciones
bsicas aritmticas (+,-,*,/) y con al menos 3 dgitos de precisin. Los valores sern
introducidos por teclado y se visualizarn en la interfaz grfica.
2.3.- Si se activa la tercera opcin debe generarse una rutina que permita que el valor de 8
Dip-switch conectados al DSPIC sean visualizados en 8 Leds que tambin estn conectados
al mismo respectivamente.
int menu=0,menu_2,boton_1,boton_2,boton_3,ultimo=1,ultimo2=1,inter=1,y=0;
char txt_cuenta[20]={' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
char conversion[15]={' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
char tecla;
int
op=0,operacion,opx=0,x=0,operando=0,hay_decimal_1=0,hay_decimal_2=0,cant_decimal_1=0,can
t_decimal_2=0;
float
aux_op1,aux_op2,resul=0.0,n1=0.0,op1=0,dato_1=0.0,dato_2=0.0,num_decimal_1=0.0,num_decim
al_2=0.0;
unsigned short keydata = 0, special = 0, down = 0;
// ------------------------------------------------------
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 192, 255, 255, 254, 252, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
248, 248, 248, 248, 248, 248, 248, 252, 254, 255, 255, 255, 192, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255
};
246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
246, 246, 246, 246, 246, 246, 246, 239, 31, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 0, 255, 255, 63, 30, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 30, 63, 255,
255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 192, 255, 255, 254, 252, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
248, 248, 248, 248, 248, 248, 248, 252, 254, 255, 255, 255, 192, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255
};
251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 3, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 0, 255, 255, 15, 7, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 7, 15, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 0, 255, 255, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 0, 255, 255, 31, 15, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 15, 31, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 0, 255, 255, 63, 222, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236,
236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236,
236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236,
236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236,
236, 236, 236, 236, 236, 236, 236, 222, 63, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 192, 255, 255, 254, 253, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
251, 251, 251, 251, 251, 251, 251, 253, 254, 255, 255, 255, 192, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255
};
// -----------------------------------------------------// GLCD Picture name: hist_1.bmp
// GLCD Model: KS0108 128x64
// ------------------------------------------------------
0,
0,
0,
0,
0,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4, 4,
4, 4,
4, 4,
4, 4,
4, 12,
4, 4, 4, 4, 4,
4, 4, 4, 4, 4,
4, 4, 4, 4, 4,
4, 4, 4, 4, 4,
24, 240, 0, 0,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 255, 0, 0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 255, 0, 0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
16,
0,
0,
0,
0, 0, 255, 0,
66, 255, 66, 66,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, 0, 3, 6, 12, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 63, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 255, 0, 0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
0,
0,
0,
66,
0,
0,
0,
8, 8,
8, 8,
8, 8,
8, 8,
8, 12,
8,
8,
8,
8,
6,
8,
8,
8,
8,
3,
0,
8,
8,
8,
0,
8,
8,
8,
0,
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
0,
8,
8,
8,
8,
0
0,
8,
8,
8,
};
// -----------------------------------------------------// -----------------------------------------------------// -----------------------------------------------------// GLCD Picture name: CAL_1.bmp
// GLCD Model: KS0108 128x64
// ------------------------------------------------------
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
240, 240, 0, 240, 240, 240, 240, 252, 254, 254, 254, 254, 254, 254, 254, 254, 254, 126, 62, 158,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 158, 62, 126,
254, 254, 254, 254, 254, 254, 254, 254, 254, 252, 240, 240, 240, 240, 0, 240, 240,
255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0,
0, 0, 0, 0, 0, 0, 0, 112, 136, 4, 4, 4, 136, 0, 192, 112, 76, 76, 112, 192, 0, 252, 0, 0,
0, 112, 136, 4, 4, 4, 136, 0, 252, 0, 0, 0, 0, 252, 0, 252, 0, 0, 0, 192, 112, 76, 76, 112,
192, 0, 252, 4, 4, 4, 136, 112, 0, 112, 136, 4, 4, 4, 136, 112, 0, 252, 36, 100, 164, 24, 0,
192, 112, 76, 76, 112, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255,
255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 240, 231, 200,
208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 209, 209, 209, 208, 208, 209, 208, 208, 208, 208,
209, 208, 209, 209, 209, 209, 208, 208, 209, 209, 209, 208, 208, 208, 209, 209, 209, 209, 208, 208,
209, 209, 209, 208, 209, 208, 208, 208, 208, 209, 208, 209, 209, 209, 209, 208, 208, 208, 208, 208,
209, 209, 209, 208, 208, 208, 209, 208, 208, 208, 209, 208, 209, 208, 208, 208, 208, 209, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208, 200, 231, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 0, 255, 255,
195, 195, 192, 195, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
247, 247, 247, 193, 193, 192, 193, 193
};
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 48, 16, 16, 16, 16,
16, 16, 16, 48, 112, 240, 240, 240, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 240, 240, 240, 240, 240,
240, 240, 240, 240, 240, 112, 48, 16, 16, 16, 16, 16, 16, 16, 48, 112, 240, 240, 240, 240, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 192, 128, 0, 0, 0, 0, 0,
0, 0, 128, 192, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
192, 128, 0, 0, 0, 0, 0, 0, 0, 128, 192, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 7, 3, 3, 3, 3, 3, 3,
3, 7, 15, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 7,
3, 3, 3, 3, 3, 3, 3, 7, 15, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248, 240, 96, 96, 96, 96,
96, 96, 96, 240, 248, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 248, 240, 96, 96, 96, 96, 96, 96, 96, 240, 248, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 63, 30, 12, 12, 12, 12, 12,
12, 12, 30, 63, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
63, 30, 12, 12, 12, 12, 12, 12, 12, 30, 63, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 224, 192, 128, 128, 128, 128,
128, 128, 192, 192, 224, 255, 255, 255, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 224, 192, 128, 128, 128, 128, 128, 128, 128, 192, 224,
255, 255, 255, 255, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255
};
IFS1BITS.INT1IF=0;
}
void INT2() org 0x00004E
{ delay_ms(200);
boton_1++;
inter=1;
if(boton_1>120)boton_1=121;
IFS1BITS.INT2IF=0;
}
//////////////////////////////////////////////////
char keyboard(void){ //funcion que retorna tecla pulsada
do {
if (Ps2_Key_Read(&keydata, &special, &down)) {
if (down && keydata) break;
}
} while (1);
return keydata;
}
/////////////////////////////////////////////////////////
///funcion menu principal
void PANTALLA_PRINCIPAL(void){
Glcd_Set_Font(FontSystem5x7_v2, 5, 7, 32); // Change font
switch (menu)
{
case 0:
Glcd_Image(hist);//imagen de fondo del histograma
Glcd_Write_Text("HISTOGRAMA", 30, 2, 0);
Glcd_Write_Text("CALCULADORA", 30, 4, 1);
case 1:
Glcd_Image(cal);//imagen de fondo de la calculadora
Glcd_Write_Text("HISTOGRAMA", 30, 2, 1);
Glcd_Write_Text("CALCULADORA", 30, 4, 0);
Glcd_Write_Text("LEDs", 30, 6, 1);
break;
case 2:
Glcd_Image(leds);//imagen de fondo de la visualizacion de leds
Glcd_Write_Text("HISTOGRAMA", 30, 2, 1);
Glcd_Write_Text("CALCULADORA", 30, 4, 1);
Glcd_Write_Text("LEDs", 30, 6, 0);
break;
}
}
////////////////////////////////////////////////////////////
//con esta funcion se procesa la operacion en pantalla
void conver_operacion(char *txt_cuenta,int x)
{ int i=0;
///iniciolizacion de variables
operacion=-1;
operando=0;
ultimo=0;
dato_1=0.0;
dato_2=0.0;
num_decimal_1=0.0;
num_decimal_2=0.0;
cant_decimal_1=0;
cant_decimal_2=0;
hay_decimal_1=0;
hay_decimal_2=0;
//////////////////////////////////
for(y=0; y<x; y++){//se recorre la cadena en pantalla
tecla=txt_cuenta[y];//se extraen cada valor ascii
switch (tecla){ //caracteres de operacion y punto decimal
case 43://si es +
operando=1; //indica primer operando ya introducido
operacion=0;//contiene la operacion a realizar
i++;//para el control de no mas de dos operando
break;
case 42:// si es *
operando=1; //indica primer operando ya introducido
operacion=2;//contiene la operacion a realizar
i++; //para el control de no mas de dos operando
break;
case 47:// si es /
}
}
}
if(i<=1){//indica que no hay error de varios signos
if(hay_decimal_1){//si hay decimal se le agraga a dato1
switch (cant_decimal_1){
case 1:
dato_1=dato_1+(num_decimal_1/10); //dato con 1 decimal
break;
case 2:
dato_1=dato_1+(num_decimal_1/100);//dato con 2 decimal
break;
case 3:
dato_1=dato_1+(num_decimal_1/1000);//dato con 3 decimal
break;
}
}
break;
}
}
if(operacion==0){// realiza la suma
resul=dato_1 + dato_2;
}
if(operacion==1){//realiza la resta
resul=dato_1- dato_2;
}
if(operacion==2){//realiza la multiplicacion
resul=dato_1 * dato_2;
}
if(operacion==3){//realiza la division
resul=dato_1 / dato_2;
}
FloatToStr(resul, conversion);//pasa el dato a string
Glcd_Write_Text(conversion, 20, 3, 1); //muestra el resultado
}
else{//en caso de error de signo
Glcd_Write_Text("Solo dos operando", 20, 3, 1);//avisa
delay_ms(2000);
num_decimal_1=0.0;
num_decimal_2=0.0;
cant_decimal_1=0;
cant_decimal_2=0;
hay_decimal_1=0;
hay_decimal_2=0;
x=0;
/////////////////////////////////////////
}
void init()
{
//CONFIGURACION DEL PLL PARA ALCANZAR UNA VELOCIDAD DE 40MHZ
// Configure PLL prescaler, PLL postscaler, PLL divisor
PLLFBD=78; // M=80
CLKDIVbits.PLLPOST=1; // N2=4
CLKDIVbits.PLLPRE=0; // N1=2
OSCCON=0x46;
OSCCON=0x57;
OSCCONBITS.IOLOCK=0;
RPINR0BITS.INT1R=75; //ENTRADA INT1
RPINR1BITS.INT2R=74; //ENTRADA INT2
OSCCONBITS.IOLOCK=1;
void main() {
int graf_1=0,graf_2=0,graf_3=0,scal=1,num_lock=1;;
init();//iniciliza dspic
Ps2_Config();// Init PS/2 Keyboard
Glcd_Init(); // Initialize GLCD
while(1){
if(inter){//grafica si hay cambio en las variables
inter=0;
if(boton_1>120 || boton_2>120 ||boton_3>120 ){//se llego al maximo en un pulsador
Glcd_Write_Text("max", 105, 6, 2);
delay_ms(1000);
}
if((boton_1>=40||boton_2>=40 ||boton_3>=40) && ultimo)
{
Glcd_Image(hist_1);//limpia fondo de pantalla
Glcd_Write_Text_Adv("HISTOGRAMA",30, 3 );
scal=2;
ultimo=0;//para que lo haga una sola vez
}
graf_1=(boton_1);
graf_2=(boton_2);
graf_3=(boton_3);
}
if(scal==2)//autoescala 2x
{
Glcd_Write_Text_Adv("2X",8, 44);
graf_1=(boton_1/2);
graf_2=(boton_2/2);
graf_3=(boton_3/2);
}
if(scal==3)//autoescala 3x
{
Glcd_Write_Text_Adv("3X",8, 44);
graf_1=(boton_1/3);
graf_2=(boton_2/3);
graf_3=(boton_3/3);
}
//grafica cuadro
Glcd_Box(38, 59-graf_1, 57, 59, 1);
x=0;
ultimo=0;
Glcd_Image(CALC_1);
while(1){
tecla=keyboard();
if(tecla==29 && num_lock){num_lock=0;}//desbloqueo y bloqueo del teclado numerico
else {if(tecla==29 && num_lock==0)num_lock=1;}
dato_1=0.0;
dato_2=0.0;
num_decimal_1=0.0;
num_decimal_2=0.0;
cant_decimal_1=0;
cant_decimal_2=0;
hay_decimal_1=0;
hay_decimal_2=0;
}else{
if(tecla==13){
}else{//si no es enter
txt_cuenta[x]=tecla;
Glcd_Write_Text(txt_cuenta, 20, 1, 1);
x++;}}
break;
Glcd_Image(LEDS_1);
Glcd_Write_Text_Adv("LEDs",57, 2 );
Glcd_Write_Text_Adv("RB15",32, 13 );
Glcd_Write_Text_Adv("RB14",32, 26 );
Glcd_Write_Text_Adv("RB13",32, 39 );
Glcd_Write_Text_Adv("RB12",32, 52 );
Glcd_Write_Text_Adv("RB11",87, 13 );
Glcd_Write_Text_Adv("RB10",87, 26 );
Glcd_Write_Text_Adv("RB9",87, 39 );
Glcd_Write_Text_Adv("RB8",87, 52 );
//////////////////////////////////////
while(1) {
if(!(PORTDBITS.RD8==PORTBBITS.RB15)){//en caso que cambie
PORTDBITS.RD8=PORTBBITS.RB15;
if(!PORTBBITS.RB15)Glcd_Circle_Fill(19,18, 3, 0);
else Glcd_Circle_Fill(19,18, 3, 1);}
break;
}
}
}
}