Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
231 | 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" |
||
274 | killagreg | 13 | #include "timer0.h" |
231 | killagreg | 14 | |
274 | killagreg | 15 | uint8_t MaxMenuItem = 3; |
231 | killagreg | 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 | { |
||
274 | killagreg | 48 | int32_t i1,i2; |
49 | uint8_t sign; |
||
50 | |||
231 | killagreg | 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; |
||
274 | killagreg | 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) |
||
231 | killagreg | 100 | { |
274 | killagreg | 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; |
||
231 | killagreg | 113 | } |
274 | killagreg | 114 | if(GPSData.Position.Longitude < 0) sign = '-'; |
115 | else sign = '+'; |
||
116 | i1 = abs(GPSData.Position.Longitude)/10000000L; |
||
117 | i2 = abs(GPSData.Position.Longitude)%10000000L; |
||
118 | LCD_printfxy(0,1,"Lon:%c%03ld.%07ld deg",sign, i1, i2); |
||
119 | if(GPSData.Position.Latitude < 0) sign = '-'; |
||
120 | else sign = '+'; |
||
121 | i1 = abs(GPSData.Position.Latitude)/10000000L; |
||
122 | i2 = abs(GPSData.Position.Latitude)%10000000L; |
||
123 | LCD_printfxy(0,2,"Lat:%c%03ld.%07ld deg",sign, i1, i2); |
||
124 | if(GPSData.Position.Altitude < 0) sign = '-'; |
||
125 | else sign = '+'; |
||
126 | i1 = abs(GPSData.Position.Altitude)/1000L; |
||
127 | i2 = abs(GPSData.Position.Altitude)%1000L; |
||
128 | LCD_printfxy(0,3,"Alt:%c%04ld.%03ld m", sign, i1, i2); |
||
129 | } |
||
130 | break; |
||
131 | case 2: |
||
132 | if (GPSData.Status == INVALID) |
||
133 | { |
||
134 | LCD_printfxy(0,0,"No GPS data"); |
||
135 | LCD_printfxy(0,1,"Speed N: "); |
||
136 | LCD_printfxy(0,2,"Speed E: "); |
||
137 | LCD_printfxy(0,3,"Speed T: "); |
||
138 | } |
||
139 | else // newdata or processed |
||
140 | { |
||
141 | switch (GPSData.SatFix) |
||
231 | killagreg | 142 | { |
274 | killagreg | 143 | case SATFIX_NONE: |
144 | LCD_printfxy(0,0,"Sats:%02d Fix:None", GPSData.NumOfSats); |
||
145 | break; |
||
146 | case SATFIX_2D: |
||
147 | LCD_printfxy(0,0,"Sats:%02d Fix:2D ", GPSData.NumOfSats); |
||
148 | break; |
||
149 | case SATFIX_3D: |
||
150 | LCD_printfxy(0,0,"Sats:%02d Fix:3D ", GPSData.NumOfSats); |
||
151 | break; |
||
152 | default: |
||
153 | LCD_printfxy(0,0,"Sats:%02d Fix:?? ", GPSData.NumOfSats); |
||
154 | break; |
||
231 | killagreg | 155 | } |
274 | killagreg | 156 | LCD_printfxy(0,1,"Speed N: %+4ld cm/s",GPSData.Speed_North); |
157 | LCD_printfxy(0,2,"Speed E: %+4ld cm/s",GPSData.Speed_East); |
||
158 | LCD_printfxy(0,3,"Speed T: %+4ld cm/s",GPSData.Speed_Top); |
||
159 | } |
||
160 | break; |
||
161 | case 3: |
||
162 | LCD_printfxy(0,0,"GPS UTC Time"); |
||
163 | if (!SystemTime.Valid) |
||
164 | { |
||
165 | LCD_printfxy(0,1," "); |
||
166 | LCD_printfxy(0,2," No time data! "); |
||
167 | LCD_printfxy(0,3," "); |
||
168 | } |
||
169 | else // newdata or processed |
||
170 | { |
||
171 | LCD_printfxy(0,1," "); |
||
172 | LCD_printfxy(0,2,"Date: %02i/%02i/%04i",SystemTime.Month, SystemTime.Day, SystemTime.Year); |
||
173 | LCD_printfxy(0,3,"Time: %02i:%02i:%02i.%03i", SystemTime.Hour, SystemTime.Min, SystemTime.Sec, SystemTime.mSec); |
||
174 | } |
||
175 | break; |
||
231 | killagreg | 176 | |
177 | default: MaxMenuItem = MenuItem - 1; |
||
178 | MenuItem = 0; |
||
179 | break; |
||
180 | } |
||
181 | RemoteKeys = 0; |
||
182 | } |