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