Line 18... |
Line 18... |
18 |
|
18 |
|
19 |
#define TL1 PIN_C0 |
19 |
#define TL1 PIN_C0 |
20 |
#define TL2 PIN_C1 |
20 |
#define TL2 PIN_C1 |
21 |
#define TL3 PIN_C2 |
21 |
#define TL3 PIN_C2 |
22 |
|
22 |
|
23 |
// NMEA |
- |
|
24 |
#define TIME 6 // For NMEA parsing |
- |
|
25 |
#define TIME_LEN 10 |
- |
|
26 |
#define LATDEG 19 |
- |
|
27 |
#define LATMIN 21 |
- |
|
28 |
#define LONDEG 32 |
- |
|
29 |
#define LONMIN 34 |
- |
|
30 |
#define SAT 36 |
- |
|
31 |
#define DEG_LEN 2 |
- |
|
32 |
#define MIN_LEN 7 |
- |
|
33 |
#define AZIMUTH 46 |
- |
|
34 |
#define NMEA_LINESIZE 79 |
- |
|
35 |
|
- |
|
36 |
//$GPRMC,105815.503,V,4915.5877,N,01442.3896,E,0.0,0.00,060108,,,N*44 |
23 |
//$GPRMC,105815.503,V,4915.5877,N,01442.3896,E,0.0,0.00,060108,,,N*44 |
37 |
|
- |
|
- |
|
24 |
//$GPGGA,000415.000,4915.6225,N,01442.3608,E,1,03,50.0,409.6,M,45.2,M,0.0,0000*48 |
38 |
void main() |
25 |
void main() |
39 |
{ |
26 |
{ |
40 |
|
27 |
|
41 |
setup_adc_ports(AN0); |
28 |
setup_adc_ports(AN0); |
42 |
setup_adc(ADC_CLOCK_INTERNAL); |
29 |
setup_adc(ADC_CLOCK_INTERNAL); |
Line 52... |
Line 39... |
52 |
lcd_gotoxy(5,1); |
39 |
lcd_gotoxy(5,1); |
53 |
printf(lcd_putc,"GPSRL01B \n"); |
40 |
printf(lcd_putc,"GPSRL01B \n"); |
54 |
printf(lcd_putc,"(c) Kaklik 2008"); |
41 |
printf(lcd_putc,"(c) Kaklik 2008"); |
55 |
delay_ms(300); |
42 |
delay_ms(300); |
56 |
printf(lcd_putc,"\f"); |
43 |
printf(lcd_putc,"\f"); |
57 |
|
44 |
|
58 |
set_adc_channel(SCINTILAK); |
45 |
set_adc_channel(SCINTILAK); |
59 |
|
46 |
|
60 |
while(TRUE) |
47 |
while(TRUE) |
61 |
{ |
48 |
{ |
62 |
|
49 |
|
- |
|
50 |
|
63 |
auto char line[NMEA_LINESIZE]; |
51 |
char tab1[20]; |
64 |
char item[16]; |
52 |
char tab2[20]; |
- |
|
53 |
char tab3[20]; |
- |
|
54 |
char tab4[20]; |
65 |
char *ptr; |
55 |
char tab5[20]; |
- |
|
56 |
|
66 |
int8 n; |
57 |
int8 n; |
- |
|
58 |
int16 intensity; |
67 |
char c; |
59 |
char c; |
68 |
|
60 |
|
69 |
|
- |
|
- |
|
61 |
tab1[19]=0; |
70 |
// line=malloc(NMEA_LINESIZE); // Space for one line |
62 |
tab2[19]=0; |
71 |
// if (line==NULL) {printf(lcd_putc,"Error"); sleep();}; |
63 |
tab3[19]=0; |
72 |
line[NMEA_LINESIZE-1]=0; |
64 |
tab4[19]=0; |
- |
|
65 |
tab5[19]=0; |
73 |
|
66 |
|
74 |
while(fgetc(NMEA)!='$'); // Waiting for start character |
67 |
while(fgetc(NMEA)!='$'); // Waiting for start character |
- |
|
68 |
|
- |
|
69 |
intensity=read_adc(); |
- |
|
70 |
tab1[0]='$'; |
- |
|
71 |
|
- |
|
72 |
for(n=1;n<(19);n++) |
- |
|
73 |
{ |
- |
|
74 |
tab1[n]=fgetc(NMEA); |
- |
|
75 |
}; |
- |
|
76 |
|
75 |
for(n=0;n<(NMEA_LINESIZE-1);n++) // Read line up to checksum |
77 |
for(n=0;n<(19);n++) |
- |
|
78 |
{ |
- |
|
79 |
tab2[n]=fgetc(NMEA); |
- |
|
80 |
}; |
- |
|
81 |
|
- |
|
82 |
for(n=0;n<(19);n++) |
- |
|
83 |
{ |
- |
|
84 |
tab3[n]=fgetc(NMEA); |
- |
|
85 |
}; |
- |
|
86 |
|
- |
|
87 |
for(n=0;n<(19);n++) |
76 |
{ |
88 |
{ |
77 |
c=fgetc(NMEA); |
89 |
c=fgetc(NMEA); |
78 |
if(c=='*') |
90 |
if(c=='*') |
79 |
{ |
91 |
{ |
80 |
line[n]=0; |
92 |
tab4[n]=0; |
- |
|
93 |
tab5[0]=c; |
- |
|
94 |
tab5[1]=fgetc(NMEA); |
- |
|
95 |
tab5[2]=fgetc(NMEA); |
- |
|
96 |
tab5[3]=0; |
- |
|
97 |
goto tisk; |
- |
|
98 |
}; |
- |
|
99 |
tab4[n]=c; |
- |
|
100 |
}; |
- |
|
101 |
|
- |
|
102 |
for(n=0;n<(19);n++) // Read line up to checksum |
- |
|
103 |
{ |
- |
|
104 |
c=fgetc(NMEA); |
- |
|
105 |
if(c=='*') |
- |
|
106 |
{ |
- |
|
107 |
tab5[n]=c; |
- |
|
108 |
tab5[n+1]=fgetc(NMEA); |
- |
|
109 |
tab5[n+2]=fgetc(NMEA); |
- |
|
110 |
tab5[n+3]=0; |
81 |
break; |
111 |
break; |
82 |
}; |
112 |
}; |
83 |
line[n]=c; |
113 |
tab5[n]=c; |
84 |
}; |
114 |
}; |
85 |
|
115 |
|
- |
|
116 |
tisk: |
- |
|
117 |
|
86 |
printf(lcd_putc,"\f"); |
118 |
printf(lcd_putc,"\f"); |
87 |
|
119 |
|
88 |
if(!input(TL1)) |
120 |
if(!input(TL1)) |
89 |
{ |
121 |
{ |
90 |
lcd_gotoxy(1,1); |
122 |
lcd_gotoxy(1,1); |
91 |
strncpy(item,&line[LATDEG],DEG_LEN+MIN_LEN); item[DEG_LEN+MIN_LEN]=0; |
- |
|
92 |
printf(lcd_putc,"%s \n",item); |
123 |
printf(lcd_putc,"%s\n",tab1); |
93 |
|
- |
|
94 |
strncpy(item,&line[LONDEG],DEG_LEN+MIN_LEN); item[DEG_LEN+MIN_LEN]=0; |
- |
|
95 |
printf(lcd_putc,"%s",item); |
124 |
printf(lcd_putc,"%s",tab2); |
96 |
|
- |
|
97 |
} |
125 |
} |
98 |
else |
126 |
else |
99 |
{ |
127 |
{ |
100 |
lcd_gotoxy(1,1); |
128 |
lcd_gotoxy(1,1); |
101 |
printf(lcd_putc,"Time %06.0g \n",strtod(&line[TIME],&ptr)); |
129 |
printf(lcd_putc,"%s\n",tab3); |
102 |
printf(lcd_putc,"sats %06.0g ",strtod(&line[SAT],&ptr)); |
130 |
printf(lcd_putc,"%s",tab4); |
103 |
} |
131 |
} |
104 |
|
132 |
|
- |
|
133 |
puts(strcat(tab1,strcat(tab2,tab3)),PC); |
105 |
puts(line,PC); |
134 |
puts(strcat(tab4,tab5),PC); |
- |
|
135 |
printf(" /%u/%Lu\n\r",input(RANGE), intensity); |
106 |
|
136 |
|
107 |
// free(line); |
- |
|
108 |
} |
137 |
} |
109 |
} |
138 |
} |
110 |
|
139 |
|