Ok I'm using gps to retrieve data, storing the latitude data into special buffer "str1[15]", it displays fine inside the GPS(), but retrieving it outside the GPS() i get 15 black boxes on my lcd, guessing that means empty spots so where did the data go and how can I correct this issue? Reason being I am going to send the str1 value by SMS() once it leaves the GPS() mode. This is debugging mode because my SMS not giving me the str1 data. First things first how can I display str1 data from inside the while(). For simplicity I removed the unnec portions of code (LCD info, Rx/Tx) thanks!!!
Code:
char str1[15]; // LATITUDE data to be saved for displaying on LCD (gps()) and through SMS()
unsigned char ch, i;
char gpstime[7];
char gpsdate[7];
char buffer[7];
char gps_header[]="GPRMC,";
int main(){
ADCON1 = 0b00001111; // sets A to digital only
OSCCON = 0x76; // Sets internal oscillator to 8MHz
TRISA = 0b00111100; // LED A0 (r),A1 (g)
TRISB = 0b11111111; // Interrupts B0,B1
TRISD = 0b01100000; // LCD: E-D7,RS-D4, Data-3:0
TRISC = 0b11111111;
Delay_Ms(10);
LCDinit(), UART_Init(9600);
LCDcmd(0x01);
while(1){
GPS_get();
LCDcmd(0xD4); // LINE 4
LCDdata(str1[0]),LCDdata(str1[1]),LCDdata(str1[2]);
LCDdata(str1[3]),LCDdata(str1[4]),LCDdata(str1[5]),LCDdata(str1[6]);
LCDdata(str1[7]),LCDdata(str1[8]),LCDdata(str1[9]),LCDdata(str1[10]);
LCDdata(str1[11]),LCDdata(str1[12]),LCDdata(str1[13]),LCDdata(str1[14]);
Delay_Ms(1000);
}
return 0;
}
void GPS_get(void){
ch = UART_Read();
if (ch == '$'){
for (i=0;i<6;i++){
ch = UART_Read(); // read one char at a time (6 characters total)
buffer[i] = ch;}
if (strcmp(buffer, gps_header)==0){
for (i=0;i<6;i++){ // These simply go through and store parts of string data into // separate buffers
ch = UART_Read();}
for (i=0;i<7;i++){
ch = UART_Read();}
for (i=0;i<9;i++){
ch = UART_Read();
str1[i] = ch;} // SAVE THIS LONGITUDE data into str1 to recall later
for (i=0;i<3;i++){
ch = UART_Read();}
for (i=0;i<11;i++){
ch = UART_Read();
for (i=0;i<14;i++){
ch = UART_Read();}
for (i=0;i<6;i++){
ch = UART_Read();}
for (i=0;i<10;i++){
ch = UART_Read()}
LCDcmd(0x80),LCDstring("LAT: "); // Displays latitude data on LCD just fine LAT: xxxx.xxxx
if (str1[0] == ','){notvalidlat();}
LCDstring(""),LCDdata(str1[0]),LCDdata(str1[1]),LCDdata(str1[2]);
LCDdata(str1[3]),LCDdata(str1[4]),LCDdata(str1[5]),LCDdata(str1[6]);
LCDdata(str1[7]),LCDdata(str1[8]);
}
}
}