Rev 436 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
426 | killagreg | 1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Copyright (c) 04.2007 Holger Buss |
||
3 | // + only for non-profit use |
||
4 | // + www.MikroKopter.com |
||
5 | // + see the File "License.txt" for further Informations |
||
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
7 | |||
8 | #include <stdlib.h> |
||
9 | #include <inttypes.h> |
||
10 | #include "uart0.h" |
||
11 | #include "printf_P.h" |
||
12 | #include "ubx.h" |
||
13 | #include "timer0.h" |
||
14 | |||
15 | uint8_t MaxMenuItem = 3; |
||
16 | uint8_t MenuItem = 0; |
||
17 | uint8_t RemoteKeys = 0; |
||
18 | |||
19 | #define KEY1 0x01 |
||
20 | #define KEY2 0x02 |
||
21 | #define KEY3 0x04 |
||
22 | #define KEY4 0x08 |
||
23 | #define KEY5 0x10 |
||
24 | |||
25 | |||
26 | |||
27 | #define DISPLAYBUFFSIZE 80 |
||
28 | int8_t DisplayBuff[DISPLAYBUFFSIZE] = "Hello World"; |
||
29 | uint8_t DispPtr = 0; |
||
30 | |||
31 | |||
32 | /************************************/ |
||
33 | /* Clear LCD Buffer */ |
||
34 | /************************************/ |
||
35 | void LCD_Clear(void) |
||
36 | { |
||
37 | uint8_t i; |
||
38 | for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' '; |
||
39 | } |
||
40 | |||
41 | |||
42 | /************************************/ |
||
43 | /* Update Menu on LCD */ |
||
44 | /************************************/ |
||
45 | // Display with 20 characters in 4 lines |
||
46 | void LCD_PrintMenu(void) |
||
47 | { |
||
48 | int16_t i1,i2,i3; |
||
49 | uint8_t sign; |
||
50 | |||
51 | if(RemoteKeys & KEY1) |
||
52 | { |
||
53 | if(MenuItem) MenuItem--; |
||
54 | else MenuItem = MaxMenuItem; |
||
55 | } |
||
56 | if(RemoteKeys & KEY2) |
||
57 | { |
||
58 | if(MenuItem == MaxMenuItem) MenuItem = 0; |
||
59 | else MenuItem++; |
||
60 | } |
||
61 | if((RemoteKeys & KEY1) && (RemoteKeys & KEY2)) MenuItem = 0; |
||
62 | |||
63 | LCD_Clear(); |
||
64 | |||
65 | if(MenuItem > MaxMenuItem) MenuItem = MaxMenuItem; |
||
66 | // print menu item number in the upper right corner |
||
67 | if(MenuItem < 10) |
||
68 | { |
||
69 | LCD_printfxy(17,0,"[%i]",MenuItem); |
||
70 | } |
||
71 | else |
||
72 | { |
||
73 | LCD_printfxy(16,0,"[%i]",MenuItem); |
||
74 | } |
||
75 | |||
76 | switch(MenuItem) |
||
77 | { |
||
78 | case 0:// Version Info Menu Item |
||
79 | LCD_printfxy(0,0,"+ Follow Me +"); |
||
80 | #ifdef USE_SDLOGGER |
||
81 | LCD_printfxy(0,1,"HW: SD-Logger"); |
||
82 | #endif |
||
83 | #ifdef USE_FOLLOWME |
||
84 | LCD_printfxy(0,1,"HW: Follow-Me"); |
||
85 | #endif |
||
86 | LCD_printfxy(0,2,"SW: %d.%d%c", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a'); |
||
87 | LCD_printfxy(0,3," "); |
||
88 | break; |
||
89 | case 1: |
||
90 | if (GPSData.Status == INVALID) |
||
91 | { |
||
92 | LCD_printfxy(0,0,"No GPS data"); |
||
93 | LCD_printfxy(0,1,"Lon: "); |
||
94 | LCD_printfxy(0,2,"Lat: "); |
||
95 | LCD_printfxy(0,3,"Alt: "); |
||
96 | } |
||
97 | else // newdata or processed |
||
98 | { |
||
99 | switch (GPSData.SatFix) |
||
100 | { |
||
101 | case SATFIX_NONE: |
||
102 | LCD_printfxy(0,0,"Sats:%02d Fix:None", GPSData.NumOfSats); |
||
103 | break; |
||
104 | case SATFIX_2D: |
||
105 | LCD_printfxy(0,0,"Sats:%02d Fix:2D ", GPSData.NumOfSats); |
||
106 | break; |
||
107 | case SATFIX_3D: |
||
108 | LCD_printfxy(0,0,"Sats:%02d Fix:3D ", GPSData.NumOfSats); |
||
109 | break; |
||
110 | default: |
||
111 | LCD_printfxy(0,0,"Sats:%02d Fix:?? ", GPSData.NumOfSats); |
||
112 | break; |
||
113 | } |
||
114 | if(GPSData.Position.Longitude < 0) sign = '-'; |
||
115 | else sign = '+'; |
||
116 | i1 = abs((int16_t)(GPSData.Position.Longitude/10000000L)); |
||
117 | i2 = abs((int16_t)((GPSData.Position.Longitude%10000000L)/10000L)); |
||
118 | i3 = abs((int16_t)(((GPSData.Position.Longitude%10000000L)%10000L)/10L)); |
||
119 | LCD_printfxy(0,1,"Lon: %c%d.%.3d%.3d deg",sign, i1, i2, i3); |
||
120 | if(GPSData.Position.Latitude < 0) sign = '-'; |
||
121 | else sign = '+'; |
||
122 | i1 = abs((int16_t)(GPSData.Position.Latitude/10000000L)); |
||
123 | i2 = abs((int16_t)((GPSData.Position.Latitude%10000000L)/10000L)); |
||
124 | i3 = abs((int16_t)(((GPSData.Position.Latitude%10000000L)%10000L)/10L)); |
||
125 | LCD_printfxy(0,2,"Lat: %c%d.%.3d%.3d deg",sign, i1, i2, i3); |
||
126 | if(GPSData.Position.Altitude < 0) sign = '-'; |
||
127 | else sign = '+'; |
||
128 | i1 = abs((int16_t)(GPSData.Position.Altitude/1000L)); |
||
129 | i2 = abs((int16_t)(GPSData.Position.Altitude%1000L)); |
||
130 | LCD_printfxy(0,3,"Alt: %c%04d.%.03d m",sign, i1, i2); |
||
131 | } |
||
132 | break; |
||
133 | case 2: |
||
134 | if (GPSData.Status == INVALID) |
||
135 | { |
||
136 | LCD_printfxy(0,0,"No GPS data"); |
||
137 | LCD_printfxy(0,1,"Speed N: "); |
||
138 | LCD_printfxy(0,2,"Speed E: "); |
||
139 | LCD_printfxy(0,3,"Speed T: "); |
||
140 | } |
||
141 | else // newdata or processed |
||
142 | { |
||
143 | switch (GPSData.SatFix) |
||
144 | { |
||
145 | case SATFIX_NONE: |
||
146 | LCD_printfxy(0,0,"Sats:%02d Fix:None", GPSData.NumOfSats); |
||
147 | break; |
||
148 | case SATFIX_2D: |
||
149 | LCD_printfxy(0,0,"Sats:%02d Fix:2D ", GPSData.NumOfSats); |
||
150 | break; |
||
151 | case SATFIX_3D: |
||
152 | LCD_printfxy(0,0,"Sats:%02d Fix:3D ", GPSData.NumOfSats); |
||
153 | break; |
||
154 | default: |
||
155 | LCD_printfxy(0,0,"Sats:%02d Fix:?? ", GPSData.NumOfSats); |
||
156 | break; |
||
157 | } |
||
158 | LCD_printfxy(0,1,"Speed N: %+4d cm/s",(int16_t)GPSData.Speed_North); |
||
159 | LCD_printfxy(0,2,"Speed E: %+4d cm/s",(int16_t)GPSData.Speed_East); |
||
160 | LCD_printfxy(0,3,"Speed T: %+4d cm/s",(int16_t)GPSData.Speed_Top); |
||
161 | } |
||
162 | break; |
||
163 | case 3: |
||
164 | LCD_printfxy(0,0,"GPS UTC Time"); |
||
165 | if (!SystemTime.Valid) |
||
166 | { |
||
167 | LCD_printfxy(0,1," "); |
||
168 | LCD_printfxy(0,2," No time data! "); |
||
169 | LCD_printfxy(0,3," "); |
||
170 | } |
||
171 | else // newdata or processed |
||
172 | { |
||
173 | LCD_printfxy(0,1," "); |
||
174 | LCD_printfxy(0,2,"Date: %02i/%02i/%04i",SystemTime.Month, SystemTime.Day, SystemTime.Year); |
||
175 | LCD_printfxy(0,3,"Time: %02i:%02i:%02i.%03i", SystemTime.Hour, SystemTime.Min, SystemTime.Sec, SystemTime.mSec); |
||
176 | } |
||
177 | break; |
||
178 | |||
179 | default: MaxMenuItem = MenuItem - 1; |
||
180 | MenuItem = 0; |
||
181 | break; |
||
182 | } |
||
183 | RemoteKeys = 0; |
||
184 | } |