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