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