Rev Author Line No. Line
1269 kakl 1 /*! \file gps.c \brief GPS position storage and processing library. */
2 //*****************************************************************************
3 //
4 // File Name : 'gps.c'
5 // Title : GPS position storage and processing function library
6 // Author : Pascal Stang - Copyright (C) 2002-2005
7 // Created : 2005.01.14
8 // Revised : 2002.07.17
9 // Version : 0.1
10 // Target MCU : Atmel AVR Series
11 // Editor Tabs : 4
12 //
13 // NOTE: This code is currently below version 1.0, and therefore is considered
14 // to be lacking in some functionality or documentation, or may not be fully
15 // tested. Nonetheless, you can expect most functions to work.
16 //
17 // This code is distributed under the GNU Public License
18 // which can be found at http://www.gnu.org/licenses/gpl.txt
19 //
20 //*****************************************************************************
21  
22 #ifndef WIN32
23 #include <avr/io.h>
24 #include <avr/interrupt.h>
25 #include <avr/pgmspace.h>
26 #include <math.h>
27 #include <stdlib.h>
28 #endif
29  
30 #include <stdio.h>
31  
32 #include "global.h"
33 #include "rprintf.h"
34 #include "gps.h"
35 #include "lcd_hd44780.h"
36 #include "utm.h" // Lat Lon to UTM conversion
37  
38 // Global variables
39 GpsInfoType GpsInfo;
40  
41 // Functions
42 void gpsInit(void)
43 {
44  
45 }
46  
47 GpsInfoType* gpsGetInfo(void)
48 {
49 return &GpsInfo;
50 }
51  
52 void gpsInfoPrint(void)
53 {
54 /*
55 rprintfProgStrM("TOW: "); rprintfFloat(8, GpsInfo.TimeOfWeek.f); rprintfCRLF();
56 rprintfProgStrM("WkNum: "); rprintfNum(10,4,0,' ',GpsInfo.WeekNum); rprintfCRLF();
57 rprintfProgStrM("UTCoffset:"); rprintfFloat(8, GpsInfo.UtcOffset.f); rprintfCRLF();
58 rprintfProgStrM("Num SVs: "); rprintfNum(10,4,0,' ',GpsInfo.numSVs); rprintfCRLF();
59  
60 rprintfProgStrM("X_ECEF: "); rprintfFloat(8, GpsInfo.PosECEF.x.f); rprintfCRLF();
61 rprintfProgStrM("Y_ECEF: "); rprintfFloat(8, GpsInfo.PosECEF.y.f); rprintfCRLF();
62 rprintfProgStrM("Z_ECEF: "); rprintfFloat(8, GpsInfo.PosECEF.z.f); rprintfCRLF();
63 rprintfProgStrM("TOF: "); rprintfFloat(8, GpsInfo.PosECEF.TimeOfFix.f); rprintfCRLF();
64 rprintfProgStrM("Updates: "); rprintfNum(10,6,0,' ',GpsInfo.PosECEF.updates); rprintfCRLF();
65  
66 //u08 str[20];
67 //rprintfProgStrM(" PosLat: "); rprintfStr(dtostrf(GpsInfo.PosLat.f, 10, 5, str));
68 rprintfProgStrM("PosLat: "); rprintfFloat(8, 180*(GpsInfo.PosLLA.lat.f/PI)); rprintfCRLF();
69 rprintfProgStrM("PosLon: "); rprintfFloat(8, 180*(GpsInfo.PosLLA.lon.f/PI)); rprintfCRLF();
70 rprintfProgStrM("PosAlt: "); rprintfFloat(8, GpsInfo.PosLLA.alt.f); rprintfCRLF();
71 rprintfProgStrM("TOF: "); rprintfFloat(8, GpsInfo.PosLLA.TimeOfFix.f); rprintfCRLF();
72 // rprintfProgStrM("Updates: "); rprintfNum(10,6,0,' ',GpsInfo.PosLLA.updates); rprintfCRLF();
73 //*/
74 /*
75 rprintfProgStrM("Vel East: "); rprintfFloat(8, GpsInfo.VelENU.east.f); rprintfCRLF();
76 rprintfProgStrM("Vel North:"); rprintfFloat(8, GpsInfo.VelENU.north.f); rprintfCRLF();
77 rprintfProgStrM("Vel Up: "); rprintfFloat(8, GpsInfo.VelENU.up.f); rprintfCRLF();
78 // rprintfProgStrM("TOF: "); rprintfFloat(8, GpsInfo.VelENU.TimeOfFix.f); rprintfCRLF();
79 rprintfProgStrM("Updates: "); rprintfNum(10,6,0,' ',GpsInfo.VelENU.updates); rprintfCRLF();
80  
81 rprintfProgStrM("Vel Head: "); rprintfFloat(8, GpsInfo.VelHS.heading.f); rprintfCRLF();
82 rprintfProgStrM("Vel Speed:"); rprintfFloat(8, GpsInfo.VelHS.speed.f); rprintfCRLF();
83 // rprintfProgStrM("TOF: "); rprintfFloat(8, GpsInfo.VelHS.TimeOfFix.f); rprintfCRLF();
84 //*/
85 rprintfProgStrM("PosLat: "); rprintfFloat(8, GpsInfo.PosLLA.lat.f); rprintfCRLF();
86 rprintfProgStrM("PosLon: "); rprintfFloat(8, GpsInfo.PosLLA.lon.f); rprintfCRLF();
87 rprintfProgStrM("PosAlt: "); rprintfFloat(8, GpsInfo.PosLLA.alt.f); rprintfCRLF();
88 rprintfProgStrM("TOF: "); rprintfFloat(8, GpsInfo.PosLLA.TimeOfFix.f); rprintfCRLF();
89  
90 rprintfProgStrM("Updates: "); rprintfNum(10,6,0,' ',GpsInfo.VelHS.updates); rprintfCRLF();
91  
92 }
93  
94 void gpsInfoPrintLCD(void)
95 {
96 lcd_gotoxy(1,1);
97 rprintfStr(GPSlat);
98 // rprintfFloatMy(2, GpsInfo.PosLLA.lat.f);
99 // rprintfFloatMy(6, (GpsInfo.PosLLA.lat.f-trunc(GpsInfo.PosLLA.lat.f))*60);
100 rprintfCRLF();
101 lcd_gotoxy(12,1);
102 rprintfFloat(4, GpsInfo.PosLLA.alt.f);
103 lcd_gotoxy(10,2);
104 // rprintfFloat(6, GpsInfo.PosLLA.TimeOfFix.f+20000);
105 rprintfFloat(6, GpsInfo.PosLLA.TimeOfFix.f+10000);
106 lcd_gotoxy(1,2);
107 rprintfStr(GPSlon);
108 // rprintfFloatMy(2, GpsInfo.PosLLA.lon.f);
109 // rprintfFloatMy(6, (GpsInfo.PosLLA.lon.f-trunc(GpsInfo.PosLLA.lon.f))*60);
110 rprintfCRLF();
111 lcd_gotoxy(10,1);
112 rprintfNum(10,2,0,'*',GpsInfo.numSVs);
113 rprintfCRLF();
114 }
115  
116 void gpsInfoPrintLCD2(void)
117 {
118 int utmXZone;
119 char utmYZone;
120 double easting;
121 double northing;
122  
123 lcd_gotoxy(1,1);
124  
125 LatLonToUtmWGS84(&utmXZone, &utmYZone, &easting, &northing, GpsInfo.PosLLA.lat.f, GpsInfo.PosLLA.lon.f);
126  
127 rprintfFloatMy(7, northing);
128 rprintfProgStrM(" ");
129 // rprintfCRLF();
130 lcd_gotoxy(12,1);
131 rprintfFloat(4, GpsInfo.PosLLA.alt.f);
132 lcd_gotoxy(10,2);
133 // rprintfFloat(6, GpsInfo.PosLLA.TimeOfFix.f+20000);
134 rprintfFloat(6, GpsInfo.PosLLA.TimeOfFix.f+10000);
135 lcd_gotoxy(1,2);
136 rprintfNum(10,2,0,'*',utmXZone);
137 rprintfChar(utmYZone);
138 rprintfFloatMy(6, easting);
139 rprintfProgStrM(" ");
140 // rprintfCRLF();
141 lcd_gotoxy(9,1);
142 rprintfNum(10,3,0,'*',GpsInfo.numSVs);
143 rprintfCRLF();
144 }