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