Está en la página 1de 30

UNIVERSIDAD NACIONAL EXPERIMENTAL POLITCNICA

ANTONIO JOS DE SUCRE


VICERRECTORADO PUERTO ORDAZ
DEPARTAMENTO DE INGENIERA ELECTRONICA
CTEDRA: Microprocesadores 2

Profesor:
Rafael Surga

Bachiller
Evelyn Gmez. C.I: 18.451.867
Cristal Martinez C.I: 19905329

CIUDAD GUAYANA, FEBRERO 2014.

Se debe disear un men principal que tenga las siguientes opciones:


2.1.- Si se activa la primera opcin debe generarse en la interfaz grfica un histograma para
medir el nmero de veces que son activados 3 pulsadores externos. Todos los pulsadores
sern atendidos por interrupcin de la siguiente manera.
2.1.1.- Al activarse cualquiera de ellos producir un aumento del histograma respectivo a la
vez de aumentar el valor del contador encima de ella como indica la figura (Ser explicada
en clase)
2.1.2.- Cuando se llegue al mximo del tamao el histograma debe autoescalarse y los
contadores continuaran trabajando igual al caso anterior (mximo 3 escalamientos).

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;

// -----------------------------------------------------// GLCD Picture name: hist.bmp


// GLCD Model: KS0108 128x64

// ------------------------------------------------------

const code char hist[1024] = {


255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 3, 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, 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, 247, 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, 247, 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, 127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 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, 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, 30, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 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
};

// -----------------------------------------------------// GLCD Picture name: cal.bmp


// GLCD Model: KS0108 128x64
// ------------------------------------------------------

const code char cal[1024] = {


255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 3, 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, 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, 239, 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, 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
};

// -----------------------------------------------------// GLCD Picture name: leds.bmp


// GLCD Model: KS0108 128x64
// ------------------------------------------------------

const code char leds[1024] = {


255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 3, 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, 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
// ------------------------------------------------------

const code char hist_1[1024] = {


0, 0, 240, 24, 12,
4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4,
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,

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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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
// ------------------------------------------------------

const code char CALC_1[1024] = {


112, 112, 0, 112, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 112, 112, 0, 112, 112,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0,
0,
0,
0,
0,

0,
0,
0,
0,
0,

0,
0,
0,
0,
0,

0,
0,
0,
0,
0,

0,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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
};

// -----------------------------------------------------// GLCD Picture name: LEDS_1.bmp


// GLCD Model: KS0108 128x64
// ------------------------------------------------------

const code char LEDS_1[1024] = {


255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 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, 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, 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
};

// Glcd module connections


sbit GLCD_D7 at RG7_bit;
sbit GLCD_D6 at RG8_bit;
sbit GLCD_D5 at RB5_bit;
sbit GLCD_D4 at RB4_bit;
sbit GLCD_D3 at RB3_bit;
sbit GLCD_D2 at RB2_bit;
sbit GLCD_D1 at RB1_bit;
sbit GLCD_D0 at RB0_bit;
sbit GLCD_D7_Direction at TRISG7_bit;
sbit GLCD_D6_Direction at TRISG8_bit;
sbit GLCD_D5_Direction at TRISB5_bit;
sbit GLCD_D4_Direction at TRISB4_bit;
sbit GLCD_D3_Direction at TRISB3_bit;
sbit GLCD_D2_Direction at TRISB2_bit;
sbit GLCD_D1_Direction at TRISB1_bit;
sbit GLCD_D0_Direction at TRISB0_bit;

sbit GLCD_CS1 at LATB6_bit;


sbit GLCD_CS2 at LATG6_bit;
sbit GLCD_RS at LATF3_bit;
sbit GLCD_RW at LATF5_bit;
sbit GLCD_EN at LATF4_bit;
sbit GLCD_RST at LATB7_bit;
sbit GLCD_CS1_Direction at TRISB6_bit;

sbit GLCD_CS2_Direction at TRISG6_bit;


sbit GLCD_RS_Direction at TRISF3_bit;
sbit GLCD_RW_Direction at TRISF5_bit;
sbit GLCD_EN_Direction at TRISF4_bit;
sbit GLCD_RST_Direction at TRISB7_bit;
// End Glcd module connections

// PS2 pinout definition


sbit PS2_Data at RD1_bit;
sbit PS2_Clock at RD2_bit;
sbit PS2_Data_Direction at TRISD1_bit;
sbit PS2_Clock_Direction at TRISD2_bit;
// End of PS2 pinout definition

// interruciones de pulsadores para el histograma


void INT0() org 0x000014
{ delay_ms(200);
boton_3++;
inter=1;
if(boton_3>120)boton_3=121;
IFS0BITS.INT0IF=0;
}
void INT1() org 0x00003C
{ delay_ms(200);
boton_2++;
inter=1;
if(boton_2>120)boton_2=121;

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);

Glcd_Write_Text("LEDs", 30, 6, 1);


break;

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 45://si es operando=1;//indica primer operando ya introducido


operacion=1;//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 /

operando=1;//indica primer operando ya introducido


operacion=3;//contiene la operacion a realizar
i++;//para el control de no mas de dos operando
break;

case '.':// punto decimal


if(operando==0)hay_decimal_1=1;//setea bandera de punto decimal para operando 1
else hay_decimal_2=1; //setea bandera de punto decimal para operando 2
break;

if(isdigit(tecla)){//si se pulsa un caracter alfanumerico


if(operando==0){//si es el primer operando
if(hay_decimal_1==0){dato_1=(float)(tecla-48)+(dato_1*10.0);//si no hay decimal compacta
dato1
}else{
num_decimal_1=(float)(tecla-48)+(num_decimal_1*10.0);//si hay decimal compacta dato
decimal2
cant_decimal_1++;//numero de decimales del primer operando
}

}else//entonces es el segundo operando


{ if(hay_decimal_2==0){dato_2=(float)(tecla-48)+(dato_2*10.0);//si no hay decimal compacta
dato2
}else{
num_decimal_2=(float)(tecla-48)+(num_decimal_2*10.0);//si hay decimal compacta dato
decimal2
cant_decimal_2++;//numero de decimales del segundo operando
}

}
}
}
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;
}
}

if(hay_decimal_2){//si hay decimal se le agraga a dato2


switch (cant_decimal_2){
case 1:
dato_2=dato_2+(num_decimal_2/10); //dato con 1 decimal
break;
case 2:
dato_2=dato_2+(num_decimal_2/100); //dato con 2 decimal
break;
case 3:
dato_2=dato_2+(num_decimal_2/1000);//dato con 3 decimal

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);

//inicializa variables y limpia pantalla


Glcd_Image(CALC_1);
for(x=0; x<20; x++){txt_cuenta[x]=' ';}//limpia cadena
operacion=-1;
operando=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;
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

// Wait for Clock switch to occur


while (OSCCONbits.COSC!= 0b011);
// Wait for PLL to lock
while (OSCCONbits.LOCK!= 1);

ANSELC=0x0000; //Configuracion de E/S digitales


ANSELD=0x0000; //Configuracion de E/S digitales
ANSELE=0x0000; //RE6 como entrada analogica
ANSELB=0x0000; //Configuracion de E/S digitales

ANSELG=0x0000; //Configuracion de E/S digitales

//mapeo de puertos e/s

OSCCON=0x46;
OSCCON=0x57;
OSCCONBITS.IOLOCK=0;
RPINR0BITS.INT1R=75; //ENTRADA INT1
RPINR1BITS.INT2R=74; //ENTRADA INT2

OSCCONBITS.IOLOCK=1;

//configuracion entradas y salidas


TRISD=0x0000;
TRISB=0xFF00;
TRISC=0x0000;
TRISDbits.TRISD10=1;
TRISDbits.TRISD11=1;
TRISDbits.TRISD0=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

Glcd_Fill(0x00);// Clear GLCD


IFS0BITS.INT0IF=0;//bandera de interrupcion para int0
IFS1BITS.INT1IF=0;//bandera de interrupcion para int1
IFS1BITS.INT2IF=0; //bandera de interrupcion para int2
IEC0BITS.INT0IE=1; //habilita interrupcion para int0
IEC1BITS.INT1IE=1; //habilita interrupcion para int0
IEC1BITS.INT2IE=1; //habilita interrupcion para int0
INTCON2BITS.INT0EP=1;//interrupcion por fanco de subida
INTCON2BITS.INT1EP=1;//interrupcion por fanco de subida
INTCON2BITS.INT2EP=1; //interrupcion por fanco de subida
//inicilizacion de variables
menu_2=0;
boton_1=0;
boton_2=0;
boton_3=0;
scal=1;
///////////////////////////////////////
Glcd_Image(hist);// imangen por defecto
//formato del fondo
Glcd_Write_Text("HISTOGRAMA", 30, 2, 0);
Glcd_Write_Text("CALCULADORA", 30, 4, 1);
Glcd_Write_Text("LEDs", 30, 6, 1);
////////////////////////////////////////
while(1) {

tecla=keyboard();//pregunta por una tecla


if(tecla==32){ //es tecla up
menu--; //sube menu
if(menu==-1)menu=2; }

if(tecla==33){//es tecla down


menu++; //baja menu
if(menu==3)menu=0;}

PANTALLA_PRINCIPAL();//muestra menu actualizado


if(tecla==13){//la tecla es ENTER
switch (menu)
{
case 0: //se seleccion histograma
inter=1;
Glcd_Image(hist_1);
Glcd_Set_Font(FontSystem5x7_v2, 5, 7, 32); // Change font
Glcd_Write_Text_Adv("HISTOGRAMA",30, 3 );
Glcd_Write_Text_Adv("1X",8, 44);

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
}

if((boton_1>=80||boton_2>=80 ||boton_3>=80) && ultimo2)


{ Glcd_Image(hist_1);//limpia fondo de pantalla
Glcd_Write_Text_Adv("HISTOGRAMA",30, 3 );
scal=3;
ultimo2=0;//para que lo haga una sola vez
}
if(scal==1)//sin autoescala
{

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);

Glcd_Box(59, 59-graf_2, 78, 59, 1);


Glcd_Box(80, 59-graf_3, 99, 59, 1);
/////////////////////////////////////
}
Ps2_Key_Read(&keydata, &special, &down);
if(keydata==34)break;//si se presiona ESC sale al mernu
}
break;
case 1: //se seleccion calculadora
Glcd_Set_Font(FontSystem5x7_v2, 5, 7, 32); // Change font

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;}

if(num_lock==1){//desbloqueo teclado numerico

if(tecla==34){ //iniciliza si se preciona ESC


ultimo++;//dos veces pulsada ESC y se sale al menu
Glcd_Image(CALC_1);
for(x=0; x<20; x++){txt_cuenta[x]=' ';}
x=0;
operacion=-1;
operando=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;
}else{
if(tecla==13){
}else{//si no es enter
txt_cuenta[x]=tecla;
Glcd_Write_Text(txt_cuenta, 20, 1, 1);
x++;}}

if(tecla==13){//si se presiona ENTER


conver_operacion(txt_cuenta,x);//opera y saca la cuenta
x=0;
}

if(ultimo>=1)break;//dos veces pulsada ESC y se sale al menu


}
}

break;

case 2://se seleccion visualizacion de leds


//formato pantalla de fondo

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);}

if(!( PORTCBITS.RC13==PORTBBITS.RB14)){//en caso que cambie


PORTCBITS.RC13=PORTBBITS.RB14;
if(!PORTBBITS.RB14)Glcd_Circle_Fill(19,31, 3, 0);
else Glcd_Circle_Fill(19,31, 3, 1); }

if(!(PORTCBITS.RC14==PORTBBITS.RB13)){//en caso que cambie


PORTCBITS.RC14=PORTBBITS.RB13;
if(!PORTBBITS.RB13)Glcd_Circle_Fill(19,44, 3, 0);
else Glcd_Circle_Fill(19,44, 3, 1); }

if(!(PORTDBITS.RD3==PORTBBITS.RB12)){//en caso que cambie


PORTDBITS.RD3=PORTBBITS.RB12;
if(!PORTBBITS.RB12)Glcd_Circle_Fill(19,57, 3, 0);
else Glcd_Circle_Fill(19,57, 3, 1); }

if(!(PORTDBITS.RD4==PORTBBITS.RB11)){//en caso que cambie


PORTDBITS.RD4=PORTBBITS.RB11;
if(!PORTBBITS.RB11)Glcd_Circle_Fill(74,18, 3, 0);
else Glcd_Circle_Fill(74,18, 3, 1); }

if(!(PORTDBITS.RD5==PORTBBITS.RB10)){//en caso que cambie


PORTDBITS.RD5=PORTBBITS.RB10;
if(!PORTBBITS.RB10)Glcd_Circle_Fill(74,31, 3, 0);
else Glcd_Circle_Fill(74,31, 3, 1); }

if(!(PORTDBITS.RD6==PORTBBITS.RB9)){//en caso que cambie


PORTDBITS.RD6=PORTBBITS.RB9;
if(!PORTBBITS.RB9) Glcd_Circle_Fill(74,44, 3, 0);
else Glcd_Circle_Fill(74,44, 3, 1); }

if(!(PORTDBITS.RD7==PORTBBITS.RB8)){//en caso que cambie


PORTDBITS.RD7=PORTBBITS.RB8;
if(!PORTBBITS.RB8)Glcd_Circle_Fill(74,57, 3, 0);
else Glcd_Circle_Fill(74,57, 3, 1); }

Ps2_Key_Read(&keydata, &special, &down);//pregunta por tecla


if(keydata==34)break;//si se preciona ESC se regresa a el menu
}

break;
}
}
}
}

También podría gustarte