You are on page 1of 4

#line 1 "C:/Documents and Settings/Mateus/Desktop/mak pic c/GPS_18F877A.

c"
char output;
char NMEA[68];
char hora[1];
char i;
char *relogio;
char *longitude;
char *localizacao_N_S;
char limpa;
char limpam;
char flag;

sbit
sbit
sbit
sbit
sbit
sbit

LCD_RS
LCD_EN
LCD_D4
LCD_D5
LCD_D6
LCD_D7

at
at
at
at
at
at

RB2_bit;
RB3_bit;
RB4_bit;
RB5_bit;
RB6_bit;
RB7_bit;

sbit
sbit
sbit
sbit
sbit
sbit

LCD_RS_Direction
LCD_EN_Direction
LCD_D4_Direction
LCD_D5_Direction
LCD_D6_Direction
LCD_D7_Direction

at
at
at
at
at
at

TRISB2_bit;
TRISB3_bit;
TRISB4_bit;
TRISB5_bit;
TRISB6_bit;
TRISB7_bit;

sbit botao at RB0_bit;


sbit botao_Direction at TRISB0_bit;
void tela1(){
Lcd_Out(1,1,"LAT:");
Lcd_Chr(1,6, NMEA[11]);
Lcd_Chr(1,7, NMEA[12]);
Lcd_Chr(1,8, NMEA[13]);
Lcd_Chr(1,9, NMEA[14]);
Lcd_Chr(1,10, NMEA[16]);
Lcd_Chr(1,11, NMEA[17]);
Lcd_Chr(1,12, NMEA[18]);
Lcd_Chr(1,13, NMEA[19]);
Lcd_Chr(1,15, NMEA[21]);
Lcd_Out(2,1,"LON:");
Lcd_Chr(2,6, NMEA[23]);
Lcd_Chr(2,7, NMEA[24]);
Lcd_Chr(2,8, NMEA[25]);
Lcd_Chr(2,9, NMEA[26]);
Lcd_Chr(2,10, NMEA[27]);
Lcd_Chr(2,11, NMEA[29]);
Lcd_Chr(2,12, NMEA[30]);
Lcd_Chr(2,13, NMEA[31]);
Lcd_Chr(2,14, NMEA[32]);
Lcd_Chr(2,16, NMEA[34]);
}
void tela2()
{

if (NMEA[0]==0x30 && NMEA[1]==0x33){hora[0]=0x30; hora[1]=0x30; }


if (NMEA[0]==0x30 && NMEA[1]==0x34){hora[0]=0x30; hora[1]=0x31; }
if (NMEA[0]==0x30 && NMEA[1]==0x35){hora[0]=0x30; hora[1]=0x32; }
if (NMEA[0]==0x32 && NMEA[1]==0x36){hora[0]=0x30; hora[1]=0x33; }
if (NMEA[0]==0x30 && NMEA[1]==0x37){hora[0]=0x30; hora[1]=0x34; }
if (NMEA[0]==0x30 && NMEA[1]==0x38){hora[0]=0x30; hora[1]=0x35; }
if (NMEA[0]==0x30 && NMEA[1]==0x39){hora[0]=0x30; hora[1]=0x36; }
if (NMEA[0]==0x31 && NMEA[1]==0x30){hora[0]=0x30; hora[1]=0x37; }
if (NMEA[0]==0x31 && NMEA[1]==0x31){hora[0]=0x30; hora[1]=0x38; }
if (NMEA[0]==0x31 && NMEA[1]==0x32){hora[0]=0x30; hora[1]=0x39; }
if (NMEA[0]==0x31 && NMEA[1]==0x33){hora[0]=0x31; hora[1]=0x30; }
if (NMEA[0]==0x31 && NMEA[1]==0x34){hora[0]=0x31; hora[1]=0x31; }
if (NMEA[0]==0x31 && NMEA[1]==0x35){hora[0]=0x31; hora[1]=0x32; }
if (NMEA[0]==0x31 && NMEA[1]==0x36){hora[0]=0x31; hora[1]=0x33; }
if (NMEA[0]==0x31 && NMEA[1]==0x37){hora[0]=0x31; hora[1]=0x34; }
if (NMEA[0]==0x31 && NMEA[1]==0x38){hora[0]=0x31; hora[1]=0x35; }
if (NMEA[0]==0x31 && NMEA[1]==0x39){hora[0]=0x31; hora[1]=0x36; }
if (NMEA[0]==0x32 && NMEA[1]==0x30){hora[0]=0x31; hora[1]=0x37; }
if (NMEA[0]==0x32 && NMEA[1]==0x31){hora[0]=0x31; hora[1]=0x38; }
if (NMEA[0]==0x32 && NMEA[1]==0x32){hora[0]=0x31; hora[1]=0x39; }
if (NMEA[0]==0x32 && NMEA[1]==0x33){hora[0]=0x32; hora[1]=0x30; }
if (NMEA[0]==0x30 && NMEA[1]==0x30){hora[0]=0x32; hora[1]=0x31; }
if (NMEA[0]==0x30 && NMEA[1]==0x31){hora[0]=0x32; hora[1]=0x32; }
if (NMEA[0]==0x30 && NMEA[1]==0x32){hora[0]=0x32; hora[1]=0x33; }
#line 91 "C:/Documents and Settings/Mateus/Desktop/mak pic c/GPS_18F877A.c"
Lcd_Out(1,1,"Hora:");
Lcd_Chr(1,7, hora[0]);
Lcd_Chr(1,8, hora[1]);
Lcd_Out(1,9,":");
Lcd_Chr(1,10, NMEA[2]);
Lcd_Chr(1,11, NMEA[3]);
Lcd_Out(1,12,":");
Lcd_Chr(1,13, NMEA[4]);
Lcd_Chr(1,14, NMEA[5]);
Lcd_Out(2,1,"ALT:");
Lcd_Chr(2,6, NMEA[45]);
Lcd_Chr(2,7, NMEA[46]);
Lcd_Chr(2,8, NMEA[47]);
Lcd_Chr(2,9, NMEA[48]);
Lcd_Chr(2,10, NMEA[49]);
Lcd_Chr(2,12, NMEA[51]);
}
void tela3()
{
Lcd_Out(1,1,"NUM SAT:");
Lcd_Chr(1,10, NMEA[38]);
Lcd_Chr(1,11, NMEA[39]);
Lcd_Out(2,1,"PRECISAO:");
Lcd_Chr(2,11, NMEA[41]);
Lcd_Chr(2,12, NMEA[42]);
Lcd_Chr(2,13, NMEA[43]);
}
void main() {

ADCON1 = 0;
TRISA = 0b11111111;
cmcon = 0B11111111;
flag=0;
limpa=0;
limpam=0;
Lcd_Init();

Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
UART1_Init(9600);
Delay_ms(100);
while (1) {
if (UART1_Data_Ready() == 1) {
output = UART1_Read();
if(output == '$'){
i = 0;
do{
if (UART1_Data_Ready() == 1){
UART1_Read_Text(NMEA, ",", 10);
i = 1;
}
} while(i == 0);
if (Button(&PORTB, 1, 40, 1)){
Lcd_Cmd(_LCD_CLEAR);
flag++;
if(flag>2){
flag=0;
}
}

if ((NMEA[2] == 'G') && (NMEA[3] == 'G') && (NMEA[4] == 'A')){


i = 0;
limpam=0;
do{
if (UART1_Data_Ready() == 1){
UART1_Read_Text(NMEA, "*", 100);
i = 1;
}
} while(i == 0);
if((NMEA[38] != 0x30) || (NMEA[39] != 0x30) ||(botao==1)){
if (limpa==0){
Lcd_Cmd(_LCD_CLEAR);
limpa=1;

}
#line 241 "C:/Documents and Settings/Mateus/Desktop/mak pic c/GPS_18F877A.c"
switch (flag) {
case 0: tela1(); break;
case 1: tela2(); break;
case 2: tela3(); break;
}
}
else{
if(limpam==0){
Lcd_Cmd(_LCD_CLEAR);
limpam=1;
}
Lcd_Out(1,3,"Sem satelite");
limpa=0;
}
}
}
}
}
}

You might also like