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