Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1612 | dongfang | 1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Copyright (c) 04.2007 Holger Buss |
||
2035 | - | 3 | // + Nur f�r den privaten Gebrauch |
1612 | dongfang | 4 | // + www.MikroKopter.com |
5 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
2035 | - | 6 | // + Es gilt f�r das gesamte Projekt (Hardware, Software, Bin�rfiles, Sourcecode und Dokumentation), |
7 | // + dass eine Nutzung (auch auszugsweise) nur f�r den privaten (nicht-kommerziellen) Gebrauch zul�ssig ist. |
||
1612 | dongfang | 8 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
9 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
||
2035 | - | 10 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Best�ckung und Verkauf von Platinen oder Baus�tzen, |
1612 | dongfang | 11 | // + Verkauf von Luftbildaufnahmen, usw. |
12 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
2035 | - | 13 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder ver�ffentlicht, |
14 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright m�ssen dann beiliegen |
||
1612 | dongfang | 15 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
16 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
||
2035 | - | 17 | // + auf anderen Webseiten oder sonstigen Medien ver�ffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
1612 | dongfang | 18 | // + eindeutig als Ursprung verlinkt werden |
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
2035 | - | 20 | // + Keine Gew�hr auf Fehlerfreiheit, Vollst�ndigkeit oder Funktion |
1612 | dongfang | 21 | // + Benutzung auf eigene Gefahr |
2035 | - | 22 | // + Wir �bernehmen keinerlei Haftung f�r direkte oder indirekte Personen- oder Sachsch�den |
1612 | dongfang | 23 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
24 | // + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
||
2035 | - | 25 | // + mit unserer Zustimmung zul�ssig |
1612 | dongfang | 26 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
27 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
||
28 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
29 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
||
30 | // + this list of conditions and the following disclaimer. |
||
31 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
||
32 | // + from this software without specific prior written permission. |
||
33 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
||
34 | // + for non-commercial use (directly or indirectly) |
||
1868 | - | 35 | // + Commercial use (for example: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
1612 | dongfang | 36 | // + with our written permission |
37 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
||
38 | // + clearly linked as origin |
||
39 | // + * porting to systems other than hardware from www.mikrokopter.de is not allowed |
||
40 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
41 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
42 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
43 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
||
44 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||
45 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||
46 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||
47 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||
48 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
49 | // + POSSIBILITY OF SUCH DAMAGE. |
||
50 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
51 | #include <stdlib.h> |
||
52 | #include <inttypes.h> |
||
53 | #include "eeprom.h" |
||
54 | #include "timer2.h" |
||
55 | #include "rc.h" |
||
56 | #include "externalControl.h" |
||
57 | #include "uart0.h" |
||
58 | #include "printf_P.h" |
||
59 | #include "analog.h" |
||
60 | #include "twimaster.h" |
||
61 | #include "attitude.h" |
||
62 | |||
1805 | - | 63 | #if (!defined (USE_NAVICTRL)) |
2018 | - | 64 | uint8_t maxMenuItem = 13; |
1612 | dongfang | 65 | #else |
1805 | - | 66 | #ifdef USE_NAVICTRL |
67 | #include "gps.c" |
||
2018 | - | 68 | uint8_t maxMenuItem = 14; |
1612 | dongfang | 69 | #endif |
70 | #endif |
||
2018 | - | 71 | uint8_t menuItem = 0; |
72 | uint8_t remoteKeys = 0; |
||
1612 | dongfang | 73 | |
74 | #define KEY1 0x01 |
||
75 | #define KEY2 0x02 |
||
76 | #define KEY3 0x04 |
||
77 | #define KEY4 0x08 |
||
78 | #define KEY5 0x10 |
||
79 | |||
80 | #define DISPLAYBUFFSIZE 80 |
||
2018 | - | 81 | int8_t displayBuff[DISPLAYBUFFSIZE] = "Hello World"; |
82 | uint8_t dispPtr = 0; |
||
1612 | dongfang | 83 | |
84 | /************************************/ |
||
85 | /* Clear LCD Buffer */ |
||
86 | /************************************/ |
||
2018 | - | 87 | void LCD_clear(void) { |
2048 | - | 88 | uint8_t i; |
89 | for (i = 0; i < DISPLAYBUFFSIZE; i++) |
||
90 | displayBuff[i] = ' '; |
||
1612 | dongfang | 91 | } |
92 | |||
93 | /************************************/ |
||
94 | /* Update Menu on LCD */ |
||
95 | /************************************/ |
||
96 | // Display with 20 characters in 4 lines |
||
2018 | - | 97 | void LCD_printMenu(void) { |
2048 | - | 98 | if (remoteKeys & KEY1) { |
99 | if (menuItem) |
||
100 | menuItem--; |
||
101 | else |
||
102 | menuItem = maxMenuItem; |
||
103 | } |
||
1612 | dongfang | 104 | |
2048 | - | 105 | if (remoteKeys & KEY2) { |
106 | if (menuItem == maxMenuItem) |
||
107 | menuItem = 0; |
||
108 | else |
||
109 | menuItem++; |
||
110 | } |
||
111 | if ((remoteKeys & KEY1) && (remoteKeys & KEY2)) |
||
112 | menuItem = 0; |
||
1821 | - | 113 | |
2048 | - | 114 | LCD_clear(); |
1821 | - | 115 | |
2048 | - | 116 | if (menuItem > maxMenuItem) |
117 | menuItem = maxMenuItem; |
||
118 | // print menu item number in the upper right corner |
||
119 | if (menuItem < 10) { |
||
120 | LCD_printfxy(17, 0, "[%i]", menuItem); |
||
121 | } else { |
||
122 | LCD_printfxy(16, 0, "[%i]", menuItem); |
||
123 | } |
||
1821 | - | 124 | |
2048 | - | 125 | switch (menuItem) { |
126 | case 0: // Version Info Menu Item |
||
127 | LCD_printfxy(0, 0, "+ MikroKopter +"); |
||
128 | LCD_printfxy( |
||
129 | 0, |
||
130 | 1, |
||
131 | "HW:V%d.%d SW:%d.%d%c", |
||
132 | boardRelease/10, boardRelease%10, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a'); |
||
133 | LCD_printfxy(0, 2, "Setting: %d %s", getActiveParamSet(), mixerMatrix.name); |
||
134 | if (I2CTimeout < 6) { |
||
135 | LCD_printfxy(0, 3, "I2C Error!!!"); |
||
136 | } else if (missingMotor) { |
||
137 | LCD_printfxy(0, 3, "Missing BL-Ctrl:%d", missingMotor); |
||
138 | } else |
||
139 | LCD_printfxy(0, 3, "(c) Holger Buss"); |
||
140 | break; |
||
141 | /* |
||
142 | case 1:// Height Control Menu Item |
||
143 | if(staticParams.GlobalConfig & CFG_HEIGHT_CONTROL) { |
||
144 | LCD_printfxy(0,0,"Height: %5i",ReadingHeight); |
||
145 | LCD_printfxy(0,1,"Set Point: %5i",SetPointHeight); |
||
146 | LCD_printfxy(0,2,"Air Press.:%5i",0); |
||
147 | LCD_printfxy(0,3,"Offset :%5i",0); |
||
148 | } |
||
149 | else |
||
150 | { |
||
151 | LCD_printfxy(0,1,"No "); |
||
152 | LCD_printfxy(0,2,"Height Control"); |
||
153 | } |
||
154 | break; |
||
155 | */ |
||
156 | case 2: // Attitude Menu Item |
||
157 | LCD_printfxy(0, 0, "Attitude"); |
||
158 | LCD_printfxy(0, 1, "Nick: %5i", |
||
159 | attitude[PITCH] / GYRO_DEG_FACTOR_PITCHROLL); |
||
160 | LCD_printfxy(0, 2, "Roll: %5i", |
||
161 | attitude[ROLL ] / GYRO_DEG_FACTOR_PITCHROLL); |
||
162 | LCD_printfxy(0, 3, "Heading(M):%5i", magneticHeading); |
||
163 | break; |
||
164 | case 3: // Remote Control Channel Menu Item |
||
165 | LCD_printfxy(0, 0, "C1:%4i C2:%4i ", PPM_in[1], PPM_in[2]); |
||
166 | LCD_printfxy(0, 1, "C3:%4i C4:%4i ", PPM_in[3], PPM_in[4]); |
||
167 | LCD_printfxy(0, 2, "C5:%4i C6:%4i ", PPM_in[5], PPM_in[6]); |
||
168 | LCD_printfxy(0, 3, "C7:%4i C8:%4i ", PPM_in[7], PPM_in[8]); |
||
169 | break; |
||
170 | case 4: // Remote Control Mapping Menu Item |
||
171 | LCD_printfxy( |
||
172 | 0, |
||
173 | 0, |
||
174 | "Ni:%4i Ro:%4i ", |
||
175 | PPM_in[channelMap.channels[CH_PITCH]], PPM_in[channelMap.channels[CH_ROLL]]); |
||
176 | LCD_printfxy( |
||
177 | 0, |
||
178 | 1, |
||
179 | "Gs:%4i Ya:%4i ", |
||
180 | PPM_in[channelMap.channels[CH_THROTTLE]], PPM_in[channelMap.channels[CH_YAW]]); |
||
181 | LCD_printfxy( |
||
182 | 0, |
||
183 | 2, |
||
184 | "P1:%4i P2:%4i ", |
||
185 | PPM_in[channelMap.channels[CH_POTS]], PPM_in[channelMap.channels[CH_POTS+1]]); |
||
186 | LCD_printfxy( |
||
187 | 0, |
||
188 | 3, |
||
189 | "P3:%4i P4:%4i ", |
||
190 | PPM_in[channelMap.channels[CH_POTS+2]], PPM_in[channelMap.channels[CH_POTS+3]]); |
||
191 | break; |
||
192 | /* |
||
193 | case 5:// Gyro Sensor Menu Item |
||
194 | LCD_printfxy(0,0,"Gyro - Sensor"); |
||
195 | switch(BoardRelease) { |
||
196 | case 10: |
||
197 | LCD_printfxy(0,1,"Nick %4i (%3i.%i)", AdValueGyroNick - HiResNickOffset / HIRES_GYRO_AMPLIFY, HiResNickOffset / HIRES_GYRO_AMPLIFY, HiResNickOffset % HIRES_GYRO_AMPLIFY); |
||
198 | LCD_printfxy(0,2,"Roll %4i (%3i.%i)", AdValueGyroRoll - HiResRollOffset / HIRES_GYRO_AMPLIFY, HiResRollOffset / HIRES_GYRO_AMPLIFY, HiResRollOffset % HIRES_GYRO_AMPLIFY); |
||
199 | LCD_printfxy(0,3,"Yaw %4i (%3i)", AdValueGyroYaw , YawOffset); |
||
200 | break; |
||
201 | case 11: |
||
202 | case 12: |
||
203 | case 20: // divice Offests by 2 becuse 2 samples are added in adc isr |
||
204 | LCD_printfxy(0,1,"Nick %4i (%3i.%i)",0, HiResNickOffset / (HIRES_GYRO_AMPLIFY * 2), (HiResNickOffset % (HIRES_GYRO_AMPLIFY * 2)) / 2); // division by 2 to push the reminder below 10 (15/2 = 7) |
||
205 | LCD_printfxy(0,2,"Roll %4i (%3i.%i)",0, HiResRollOffset / (HIRES_GYRO_AMPLIFY * 2), (HiResRollOffset % (HIRES_GYRO_AMPLIFY * 2)) / 2); // division by 2 to push the reminder below 10 (15/2 = 7) |
||
206 | LCD_printfxy(0,3,"Yaw %4i (%3i)",YawOffset - AdValueGyroYaw , YawOffset/2); |
||
207 | break; |
||
1821 | - | 208 | |
2048 | - | 209 | case 13: |
210 | default: // divice Offests by 2 becuse 2 samples are added in adc isr |
||
211 | LCD_printfxy(0,1,"Nick %4i (%3i.%i)(%3i)",0, HiResNickOffset / (HIRES_GYRO_AMPLIFY * 2), (HiResNickOffset % (HIRES_GYRO_AMPLIFY * 2))/2, 0); // division by 2 to push the reminder below 10 (15/2 = 7) |
||
212 | LCD_printfxy(0,2,"Roll %4i (%3i.%i)(%3i)",0, HiResRollOffset / (HIRES_GYRO_AMPLIFY * 2), (HiResRollOffset % (HIRES_GYRO_AMPLIFY * 2))/2, 0); // division by 2 to push the reminder below 10 (15/2 = 7) |
||
213 | LCD_printfxy(0,3,"Yaw %4i (%3i)(%3i)",YawOffset - AdValueGyroYaw , YawOffset/2, 0); |
||
214 | break; |
||
215 | } |
||
216 | break; |
||
217 | case 6:// Acceleration Sensor Menu Item |
||
218 | LCD_printfxy(0,0,"ACC - Sensor"); |
||
219 | LCD_printfxy(0,1,"Nick %4i (%3i)",0,0); // factor 2 because of adding 2 samples in ADC ISR |
||
220 | LCD_printfxy(0,2,"Roll %4i (%3i)",0,0); // factor 2 because of adding 2 samples in ADC ISR |
||
221 | LCD_printfxy(0,3,"Height %4i (%3i)",0,0); |
||
222 | break; |
||
223 | */ |
||
224 | case 7: // Battery Voltage / Remote Control Level |
||
225 | LCD_printfxy(0, 1, "Voltage: %3i.%1iV", UBat/10, UBat%10); |
||
226 | LCD_printfxy(0, 2, "RC-Level: %5i", RCQuality); |
||
227 | break; |
||
228 | case 8: // Compass Menu Item |
||
229 | LCD_printfxy(0, 0, "Compass "); |
||
230 | LCD_printfxy(0, 0, "TODO: Impl. "); |
||
231 | break; |
||
232 | case 9: // Poti Menu Item |
||
233 | LCD_printfxy(0, 0, "Variables "); |
||
234 | LCD_printfxy(0, 0, "TODO: Impl. "); |
||
235 | break; |
||
236 | case 10: // Servo Menu Item |
||
237 | LCD_printfxy(0, 0, "Servos "); |
||
238 | LCD_printfxy(0, 0, "TODO: Impl. "); |
||
239 | break; |
||
240 | case 11: //Extern Control |
||
241 | LCD_printfxy(0, 0, "ExternControl "); |
||
242 | LCD_printfxy(0, 1, "Ni:%4i Ro:%4i ", |
||
243 | externalControl.pitch, externalControl.roll); |
||
244 | LCD_printfxy(0, 2, "Gs:%4i Ya:%4i ", |
||
245 | externalControl.throttle, externalControl.yaw); |
||
246 | LCD_printfxy(0, 3, "Hi:%4i Cf:%4i ", |
||
247 | externalControl.height, externalControl.config); |
||
248 | break; |
||
1821 | - | 249 | |
2048 | - | 250 | case 12: //BL Communication errors |
251 | LCD_printfxy(0, 0, "BL-Ctrl Errors "); |
||
252 | LCD_printfxy(0, 1, " %3d %3d %3d %3d ", |
||
253 | motor[0].error, motor[1].error, motor[2].error, motor[3].error); |
||
254 | LCD_printfxy(0, 2, " %3d %3d %3d %3d ", |
||
255 | motor[4].error, motor[5].error, motor[6].error, motor[7].error); |
||
256 | LCD_printfxy(0, 3, " %3d %3d %3d %3d ", |
||
257 | motor[8].error, motor[9].error, motor[10].error, motor[11].error); |
||
258 | break; |
||
1821 | - | 259 | |
2048 | - | 260 | case 13: //BL Overview |
261 | LCD_printfxy(0, 0, "BL-Ctrl found "); |
||
262 | LCD_printfxy( |
||
263 | 0, |
||
264 | 1, |
||
265 | " %c %c %c %c ", |
||
266 | motor[0].present + '-', motor[1].present + '-', motor[2].present + '-', motor[3].present + '-'); |
||
267 | LCD_printfxy( |
||
268 | 0, |
||
269 | 2, |
||
270 | " %c %c %c %c ", |
||
271 | motor[4].present + '-', motor[5].present + '-', motor[6].present + '-', motor[7].present + '-'); |
||
272 | LCD_printfxy(0, 3, " %c - - - ", motor[8].present + '-'); |
||
273 | if (motor[9].present) |
||
274 | LCD_printfxy(4, 3, "10"); |
||
275 | if (motor[10].present) |
||
276 | LCD_printfxy(8, 3, "11"); |
||
277 | if (motor[11].present) |
||
278 | LCD_printfxy(12, 3, "12"); |
||
279 | break; |
||
1821 | - | 280 | |
1805 | - | 281 | #if (defined (USE_NAVICTRL)) |
2048 | - | 282 | case 14: //GPS Lat/Lon coords |
283 | if (GPSInfo.status == INVALID) { |
||
284 | LCD_printfxy(0,0,"No GPS data!"); |
||
285 | } else { |
||
286 | switch (GPSInfo.satfix) |
||
287 | { |
||
288 | case SATFIX_NONE: |
||
289 | LCD_printfxy(0,0,"Sats: %d Fix: No", GPSInfo.satnum); |
||
290 | break; |
||
291 | case SATFIX_2D: |
||
292 | LCD_printfxy(0,0,"Sats: %d Fix: 2D", GPSInfo.satnum); |
||
293 | break; |
||
294 | case SATFIX_3D: |
||
295 | LCD_printfxy(0,0,"Sats: %d Fix: 3D", GPSInfo.satnum); |
||
296 | break; |
||
297 | default: |
||
298 | LCD_printfxy(0,0,"Sats: %d Fix: ??", GPSInfo.satnum); |
||
299 | break; |
||
300 | } |
||
301 | int16_t i1,i2,i3; |
||
302 | i1 = (int16_t)(GPSInfo.longitude/10000000L); |
||
303 | i2 = abs((int16_t)((GPSInfo.longitude%10000000L)/10000L)); |
||
304 | i3 = abs((int16_t)(((GPSInfo.longitude%10000000L)%10000L)/10L)); |
||
305 | LCD_printfxy(0,1,"Lon: %d.%03d%03d deg",i1, i2, i3); |
||
306 | i1 = (int16_t)(GPSInfo.latitude/10000000L); |
||
307 | i2 = abs((int16_t)((GPSInfo.latitude%10000000L)/10000L)); |
||
308 | i3 = abs((int16_t)(((GPSInfo.latitude%10000000L)%10000L)/10L)); |
||
309 | LCD_printfxy(0,2,"Lat: %d.%03d%03d deg",i1, i2, i3); |
||
310 | i1 = (int16_t)(GPSInfo.altitude/1000L); |
||
311 | i2 = abs((int16_t)(GPSInfo.altitude%1000L)); |
||
312 | LCD_printfxy(0,3,"Alt: %d.%03d m",i1, i2); |
||
313 | } |
||
314 | break; |
||
1821 | - | 315 | #endif |
316 | |||
2048 | - | 317 | default: |
318 | maxMenuItem = menuItem - 1; |
||
319 | menuItem = 0; |
||
320 | break; |
||
321 | } |
||
322 | remoteKeys = 0; |
||
1612 | dongfang | 323 | } |