/Designs/GPSRL01B/SW/gpsrl.c
20,21 → 20,8
#define TL2 PIN_C1
#define TL3 PIN_C2
 
// NMEA
#define TIME 6 // For NMEA parsing
#define TIME_LEN 10
#define LATDEG 19
#define LATMIN 21
#define LONDEG 32
#define LONMIN 34
#define SAT 36
#define DEG_LEN 2
#define MIN_LEN 7
#define AZIMUTH 46
#define NMEA_LINESIZE 79
 
//$GPRMC,105815.503,V,4915.5877,N,01442.3896,E,0.0,0.00,060108,,,N*44
 
//$GPGGA,000415.000,4915.6225,N,01442.3608,E,1,03,50.0,409.6,M,45.2,M,0.0,0000*48
void main()
{
 
54,57 → 41,99
printf(lcd_putc,"(c) Kaklik 2008");
delay_ms(300);
printf(lcd_putc,"\f");
 
set_adc_channel(SCINTILAK);
 
while(TRUE)
{
 
auto char line[NMEA_LINESIZE];
char item[16];
char *ptr;
 
char tab1[20];
char tab2[20];
char tab3[20];
char tab4[20];
char tab5[20];
 
int8 n;
int16 intensity;
char c;
 
tab1[19]=0;
tab2[19]=0;
tab3[19]=0;
tab4[19]=0;
tab5[19]=0;
 
// line=malloc(NMEA_LINESIZE); // Space for one line
// if (line==NULL) {printf(lcd_putc,"Error"); sleep();};
line[NMEA_LINESIZE-1]=0;
while(fgetc(NMEA)!='$'); // Waiting for start character
 
while(fgetc(NMEA)!='$'); // Waiting for start character
for(n=0;n<(NMEA_LINESIZE-1);n++) // Read line up to checksum
intensity=read_adc();
tab1[0]='$';
for(n=1;n<(19);n++)
{
tab1[n]=fgetc(NMEA);
};
 
for(n=0;n<(19);n++)
{
tab2[n]=fgetc(NMEA);
};
 
for(n=0;n<(19);n++)
{
tab3[n]=fgetc(NMEA);
};
 
for(n=0;n<(19);n++)
{
c=fgetc(NMEA);
if(c=='*')
{
line[n]=0;
tab4[n]=0;
tab5[0]=c;
tab5[1]=fgetc(NMEA);
tab5[2]=fgetc(NMEA);
tab5[3]=0;
goto tisk;
};
tab4[n]=c;
};
 
for(n=0;n<(19);n++) // Read line up to checksum
{
c=fgetc(NMEA);
if(c=='*')
{
tab5[n]=c;
tab5[n+1]=fgetc(NMEA);
tab5[n+2]=fgetc(NMEA);
tab5[n+3]=0;
break;
};
line[n]=c;
tab5[n]=c;
};
 
tisk:
 
printf(lcd_putc,"\f");
 
if(!input(TL1))
{
lcd_gotoxy(1,1);
strncpy(item,&line[LATDEG],DEG_LEN+MIN_LEN); item[DEG_LEN+MIN_LEN]=0;
printf(lcd_putc,"%s \n",item);
 
strncpy(item,&line[LONDEG],DEG_LEN+MIN_LEN); item[DEG_LEN+MIN_LEN]=0;
printf(lcd_putc,"%s",item);
 
printf(lcd_putc,"%s\n",tab1);
printf(lcd_putc,"%s",tab2);
}
else
{
lcd_gotoxy(1,1);
printf(lcd_putc,"Time %06.0g \n",strtod(&line[TIME],&ptr));
printf(lcd_putc,"sats %06.0g ",strtod(&line[SAT],&ptr));
printf(lcd_putc,"%s\n",tab3);
printf(lcd_putc,"%s",tab4);
}
 
puts(line,PC);
puts(strcat(tab1,strcat(tab2,tab3)),PC);
puts(strcat(tab4,tab5),PC);
printf(" /%u/%Lu\n\r",input(RANGE), intensity);
 
// free(line);
}
}