AtomSoft
Well-Known Member
heh, i cant seem to get anything on the LCD period!
Code i was testing
Code i was testing
Code:
#include <16F877A.h>
#fuses NOWDT,NOLVP,NODEBUG,NOPUT,HS
#use delay(clock=40000000)
#use rs232(baud=9600,rcv=PIN_C7,xmit=PIN_C6)
#include <flexlcd.c>
int loop=0;
char cmd[26];
char ch;
volatile char data[20] ;
void serial(void)
{
char commaCount = 0;
char done = 0;
char count=0;
char LL;
for(LL=0;LL<2;LL++) //Loop 2 times for Longitude and Latitude strings
{
while(!done) //Wait until beginning of new printf
{
data[0] = getch();
if(data[0] == '$') done = 1;
}
done = 0;
data[0] = 0;
while(!done) //wait until we get out first comma
{
data[0] = getch();
if(data[0] == 0x2C) done = 1;
}
done = 0;
data[0] = 0;
while(commaCount < 4) // This is the amount of data we need... 4 commas worth
{
count=0; //count variable for placing data in loop
while(!done) //loop getting all data possible
{
data[count] = getch(); //place data into variable
count++; //Increase count
if(data[count] = ',') //if data is a command break the loop
done = 1;
}
commaCount++; //Loop is broken so increase the comma count
}
}
}
void main(void)
{
set_tris_c(0b10000000);
set_tris_D(0x00);
lcd_init();
delay_ms(20);
while(1)
{
serial();
lcd_gotoxy(1,1);
printf(lcd_putc,"LAT=%c%c%c%c%c%c%c%c%c%c%c \n",cmd[1],cmd[2],cmd[3],cmd[4],cmd[5],cmd[6],cmd[7],cmd[8],cmd[9],cmd[10],cmd[11]);
lcd_gotoxy(1,2);
printf(lcd_putc,"LON=%c%c%c%c%c%c%c%c%c%c%c%c",cmd[13],cmd[14],cmd[15],cmd[16],cmd[17],cmd[18],cmd[19],cmd[20],cmd[21],cmd[22],cmd[23],cmd[24]);
}
}