1 |
/**** GPS skrysohledac ****/ |
1 |
/**** GPS skrysohledac ****/ |
2 |
#define ID "$Id: gps.c 984 2008-01-06 23:41:31Z kakl $" |
2 |
#define ID "$Id: gps.c 984 2008-01-06 23:41:31Z kakl $" |
3 |
|
3 |
|
4 |
#include "gpsrl.h" |
4 |
#include "gpsrl.h" |
5 |
|
5 |
|
6 |
#include <math.h> |
6 |
#include <math.h> |
7 |
#include <stdlib.h> |
7 |
#include <stdlib.h> |
8 |
#include <stdlibm.h> |
8 |
#include <stdlibm.h> |
9 |
|
9 |
|
10 |
#define SCINTILAK 1 //kanal adc pro scintilacni detektor NB3201 |
10 |
#define SCINTILAK 1 //kanal adc pro scintilacni detektor NB3201 |
11 |
#define RANGE PIN_A4 // vystup detektoru urcujici rozsah mereni. |
11 |
#define RANGE PIN_A4 // vystup detektoru urcujici rozsah mereni. |
12 |
|
12 |
|
13 |
|
13 |
|
14 |
#define LCD_RS PIN_B1 // LCD control |
14 |
#define LCD_RS PIN_B1 // LCD control |
15 |
#define LCD_E PIN_B2 // LCD enable |
15 |
#define LCD_E PIN_B2 // LCD enable |
16 |
#define LCD_DATA_LSB PIN_B4 // LSB data bit LCD |
16 |
#define LCD_DATA_LSB PIN_B4 // LSB data bit LCD |
17 |
#include "MYLCD.C" |
17 |
#include "MYLCD.C" |
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 |
//$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 |
24 |
//$GPGGA,000415.000,4915.6225,N,01442.3608,E,1,03,50.0,409.6,M,45.2,M,0.0,0000*48 |
24 |
//$GPGGA,000415.000,4915.6225,N,01442.3608,E,1,03,50.0,409.6,M,45.2,M,0.0,0000*48 |
25 |
void main() |
25 |
void main() |
26 |
{ |
26 |
{ |
27 |
|
27 |
|
28 |
setup_adc_ports(AN0); |
28 |
setup_adc_ports(AN0); |
29 |
setup_adc(ADC_CLOCK_INTERNAL); |
29 |
setup_adc(ADC_CLOCK_INTERNAL); |
30 |
setup_spi(FALSE); |
30 |
setup_spi(FALSE); |
31 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
31 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
32 |
setup_timer_1(T1_DISABLED); |
32 |
setup_timer_1(T1_DISABLED); |
33 |
setup_timer_2(T2_DISABLED,0,1); |
33 |
setup_timer_2(T2_DISABLED,0,1); |
34 |
setup_comparator(NC_NC_NC_NC); |
34 |
setup_comparator(NC_NC_NC_NC); |
35 |
setup_vref(VREF_LOW|-2); |
35 |
setup_vref(VREF_LOW|-2); |
36 |
lcd_init(); |
36 |
lcd_init(); |
37 |
|
37 |
|
38 |
delay_ms(100); |
38 |
delay_ms(100); |
39 |
lcd_gotoxy(5,1); |
39 |
lcd_gotoxy(5,1); |
40 |
printf(lcd_putc,"GPSRL01B \n"); |
40 |
printf(lcd_putc,"GPSRL01B \n"); |
41 |
printf(lcd_putc,"(c) Kaklik 2008"); |
41 |
printf(lcd_putc,"(c) Kaklik 2008"); |
42 |
delay_ms(300); |
42 |
delay_ms(300); |
43 |
printf(lcd_putc,"\f"); |
43 |
printf(lcd_putc,"\f"); |
44 |
|
44 |
|
45 |
set_adc_channel(SCINTILAK); |
45 |
set_adc_channel(SCINTILAK); |
46 |
|
46 |
|
47 |
while(TRUE) |
47 |
while(TRUE) |
48 |
{ |
48 |
{ |
49 |
|
49 |
|
50 |
|
50 |
|
51 |
char tab1[20]; |
51 |
char tab1[20]; |
52 |
char tab2[20]; |
52 |
char tab2[20]; |
53 |
char tab3[20]; |
53 |
char tab3[20]; |
54 |
char tab4[20]; |
54 |
char tab4[20]; |
55 |
char tab5[20]; |
55 |
char tab5[20]; |
56 |
|
56 |
|
57 |
int8 n; |
57 |
int8 n; |
58 |
int16 intensity; |
58 |
int16 intensity; |
59 |
char c; |
59 |
char c; |
60 |
|
60 |
|
61 |
tab1[19]=0; |
61 |
tab1[19]=0; |
62 |
tab2[19]=0; |
62 |
tab2[19]=0; |
63 |
tab3[19]=0; |
63 |
tab3[19]=0; |
64 |
tab4[19]=0; |
64 |
tab4[19]=0; |
65 |
tab5[19]=0; |
65 |
tab5[19]=0; |
66 |
|
66 |
|
67 |
while(fgetc(NMEA)!='$'); // Waiting for start character |
67 |
while(fgetc(NMEA)!='$'); // Waiting for start character |
68 |
|
68 |
|
69 |
intensity=read_adc(); |
69 |
intensity=read_adc(); |
70 |
tab1[0]='$'; |
70 |
tab1[0]='$'; |
71 |
|
71 |
|
72 |
for(n=1;n<(19);n++) |
72 |
for(n=1;n<(19);n++) |
73 |
{ |
73 |
{ |
74 |
tab1[n]=fgetc(NMEA); |
74 |
tab1[n]=fgetc(NMEA); |
75 |
}; |
75 |
}; |
76 |
|
76 |
|
77 |
for(n=0;n<(19);n++) |
77 |
for(n=0;n<(19);n++) |
78 |
{ |
78 |
{ |
79 |
tab2[n]=fgetc(NMEA); |
79 |
tab2[n]=fgetc(NMEA); |
80 |
}; |
80 |
}; |
81 |
|
81 |
|
82 |
for(n=0;n<(19);n++) |
82 |
for(n=0;n<(19);n++) |
83 |
{ |
83 |
{ |
84 |
tab3[n]=fgetc(NMEA); |
84 |
tab3[n]=fgetc(NMEA); |
85 |
}; |
85 |
}; |
86 |
|
86 |
|
87 |
for(n=0;n<(19);n++) |
87 |
for(n=0;n<(19);n++) |
88 |
{ |
88 |
{ |
89 |
c=fgetc(NMEA); |
89 |
c=fgetc(NMEA); |
90 |
if(c=='*') |
90 |
if(c=='*') |
91 |
{ |
91 |
{ |
92 |
tab4[n]=0; |
92 |
tab4[n]=0; |
93 |
tab5[0]=c; |
93 |
tab5[0]=c; |
94 |
tab5[1]=fgetc(NMEA); |
94 |
tab5[1]=fgetc(NMEA); |
95 |
tab5[2]=fgetc(NMEA); |
95 |
tab5[2]=fgetc(NMEA); |
96 |
tab5[3]=0; |
96 |
tab5[3]=0; |
97 |
goto tisk; |
97 |
goto tisk; |
98 |
}; |
98 |
}; |
99 |
tab4[n]=c; |
99 |
tab4[n]=c; |
100 |
}; |
100 |
}; |
101 |
|
101 |
|
102 |
for(n=0;n<(19);n++) // Read line up to checksum |
102 |
for(n=0;n<(19);n++) // Read line up to checksum |
103 |
{ |
103 |
{ |
104 |
c=fgetc(NMEA); |
104 |
c=fgetc(NMEA); |
105 |
if(c=='*') |
105 |
if(c=='*') |
106 |
{ |
106 |
{ |
107 |
tab5[n]=c; |
107 |
tab5[n]=c; |
108 |
tab5[n+1]=fgetc(NMEA); |
108 |
tab5[n+1]=fgetc(NMEA); |
109 |
tab5[n+2]=fgetc(NMEA); |
109 |
tab5[n+2]=fgetc(NMEA); |
110 |
tab5[n+3]=0; |
110 |
tab5[n+3]=0; |
111 |
break; |
111 |
break; |
112 |
}; |
112 |
}; |
113 |
tab5[n]=c; |
113 |
tab5[n]=c; |
114 |
}; |
114 |
}; |
115 |
|
115 |
|
116 |
tisk: |
116 |
tisk: |
117 |
|
117 |
|
118 |
printf(lcd_putc,"\f"); |
118 |
printf(lcd_putc,"\f"); |
119 |
|
119 |
|
120 |
if(!input(TL1)) |
120 |
if(!input(TL1)) |
121 |
{ |
121 |
{ |
122 |
lcd_gotoxy(1,1); |
122 |
lcd_gotoxy(1,1); |
123 |
printf(lcd_putc,"%s\n",tab1); |
123 |
printf(lcd_putc,"%s\n",tab1); |
124 |
printf(lcd_putc,"%s",tab2); |
124 |
printf(lcd_putc,"%s",tab2); |
125 |
} |
125 |
} |
126 |
else |
126 |
else |
127 |
{ |
127 |
{ |
128 |
lcd_gotoxy(1,1); |
128 |
lcd_gotoxy(1,1); |
129 |
printf(lcd_putc,"%s\n",tab3); |
129 |
printf(lcd_putc,"%s\n",tab3); |
130 |
printf(lcd_putc,"%s",tab4); |
130 |
printf(lcd_putc,"%s",tab4); |
131 |
} |
131 |
} |
132 |
|
132 |
|
133 |
puts(strcat(tab1,strcat(tab2,tab3)),PC); |
133 |
puts(strcat(tab1,strcat(tab2,tab3)),PC); |
134 |
puts(strcat(tab4,tab5),PC); |
134 |
puts(strcat(tab4,tab5),PC); |
135 |
printf(" /%u/%Lu\n\r",input(RANGE), intensity); |
135 |
printf(" /%u/%Lu\n\r",input(RANGE), intensity); |
136 |
|
136 |
|
137 |
} |
137 |
} |
138 |
} |
138 |
} |
139 |
|
139 |
|