Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1612 | dongfang | 1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Copyright (c) 04.2007 Holger Buss |
||
3 | // + Nur für den privaten Gebrauch |
||
4 | // + www.MikroKopter.com |
||
5 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
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. |
||
8 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
||
9 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
||
10 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
||
11 | // + Verkauf von Luftbildaufnahmen, usw. |
||
12 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
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 |
||
15 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
16 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
||
17 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
||
18 | // + eindeutig als Ursprung verlinkt werden |
||
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
20 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
||
21 | // + Benutzung auf eigene Gefahr |
||
22 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
||
23 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
24 | // + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
||
25 | // + mit unserer Zustimmung zulässig |
||
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) { |
1821 | - | 88 | uint8_t i; |
89 | for (i = 0; i < DISPLAYBUFFSIZE; i++) |
||
2018 | - | 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) { |
98 | if (remoteKeys & KEY1) { |
||
99 | if (menuItem) |
||
100 | menuItem--; |
||
1821 | - | 101 | else |
2018 | - | 102 | menuItem = maxMenuItem; |
1821 | - | 103 | } |
1612 | dongfang | 104 | |
2018 | - | 105 | if (remoteKeys & KEY2) { |
106 | if (menuItem == maxMenuItem) |
||
107 | menuItem = 0; |
||
1821 | - | 108 | else |
2018 | - | 109 | menuItem++; |
1821 | - | 110 | } |
2018 | - | 111 | if ((remoteKeys & KEY1) && (remoteKeys & KEY2)) |
112 | menuItem = 0; |
||
1821 | - | 113 | |
2018 | - | 114 | LCD_clear(); |
1821 | - | 115 | |
2018 | - | 116 | if (menuItem > maxMenuItem) |
117 | menuItem = maxMenuItem; |
||
1821 | - | 118 | // print menu item number in the upper right corner |
2018 | - | 119 | if (menuItem < 10) { |
120 | LCD_printfxy(17,0,"[%i]", menuItem); |
||
1821 | - | 121 | } else { |
2018 | - | 122 | LCD_printfxy(16,0,"[%i]", menuItem); |
1821 | - | 123 | } |
124 | |||
2018 | - | 125 | switch (menuItem) { |
1821 | - | 126 | case 0:// Version Info Menu Item |
127 | LCD_printfxy(0,0,"+ MikroKopter +") |
||
128 | ; |
||
1960 | - | 129 | LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",boardRelease/10,boardRelease%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a') |
1821 | - | 130 | ; |
1960 | - | 131 | LCD_printfxy(0,2,"Setting: %d %s", getActiveParamSet(), mixerMatrix.name) |
1821 | - | 132 | ; |
133 | if (I2CTimeout < 6) { |
||
134 | LCD_printfxy(0,3,"I2C Error!!!"); |
||
135 | } else if (missingMotor) { |
||
136 | LCD_printfxy(0,3,"Missing BL-Ctrl:%d", missingMotor); |
||
137 | } else LCD_printfxy(0,3,"(c) Holger Buss"); |
||
138 | break; |
||
139 | /* |
||
140 | case 1:// Height Control Menu Item |
||
141 | if(staticParams.GlobalConfig & CFG_HEIGHT_CONTROL) { |
||
142 | LCD_printfxy(0,0,"Height: %5i",ReadingHeight); |
||
143 | LCD_printfxy(0,1,"Set Point: %5i",SetPointHeight); |
||
144 | LCD_printfxy(0,2,"Air Press.:%5i",0); |
||
145 | LCD_printfxy(0,3,"Offset :%5i",0); |
||
146 | } |
||
147 | else |
||
148 | { |
||
149 | LCD_printfxy(0,1,"No "); |
||
150 | LCD_printfxy(0,2,"Height Control"); |
||
151 | } |
||
152 | break; |
||
153 | */ |
||
154 | case 2:// Attitude Menu Item |
||
155 | LCD_printfxy(0,0,"Attitude"); |
||
156 | LCD_printfxy(0,1,"Nick: %5i", angle[PITCH] / GYRO_DEG_FACTOR_PITCHROLL); |
||
157 | LCD_printfxy(0,2,"Roll: %5i", angle[ROLL ] / GYRO_DEG_FACTOR_PITCHROLL); |
||
158 | LCD_printfxy(0,3,"Heading: %5i", compassHeading); |
||
159 | break; |
||
160 | case 3:// Remote Control Channel Menu Item |
||
161 | LCD_printfxy(0,0,"C1:%4i C2:%4i ",PPM_in[1],PPM_in[2]); |
||
162 | LCD_printfxy(0,1,"C3:%4i C4:%4i ",PPM_in[3],PPM_in[4]); |
||
163 | LCD_printfxy(0,2,"C5:%4i C6:%4i ",PPM_in[5],PPM_in[6]); |
||
164 | LCD_printfxy(0,3,"C7:%4i C8:%4i ",PPM_in[7],PPM_in[8]); |
||
165 | break; |
||
166 | case 4:// Remote Control Mapping Menu Item |
||
1960 | - | 167 | LCD_printfxy(0,0,"Ni:%4i Ro:%4i ",PPM_in[channelMap.channels[CH_PITCH]], PPM_in[channelMap.channels[CH_ROLL]]); |
168 | LCD_printfxy(0,1,"Gs:%4i Ya:%4i ",PPM_in[channelMap.channels[CH_THROTTLE]],PPM_in[channelMap.channels[CH_YAW]]); |
||
169 | LCD_printfxy(0,2,"P1:%4i P2:%4i ",PPM_in[channelMap.channels[CH_POTS]], PPM_in[channelMap.channels[CH_POTS+1]]); |
||
170 | LCD_printfxy(0,3,"P3:%4i P4:%4i ",PPM_in[channelMap.channels[CH_POTS+2]], PPM_in[channelMap.channels[CH_POTS+3]]); |
||
1821 | - | 171 | break; |
172 | /* |
||
173 | case 5:// Gyro Sensor Menu Item |
||
174 | LCD_printfxy(0,0,"Gyro - Sensor"); |
||
175 | switch(BoardRelease) { |
||
176 | case 10: |
||
177 | LCD_printfxy(0,1,"Nick %4i (%3i.%i)", AdValueGyroNick - HiResNickOffset / HIRES_GYRO_AMPLIFY, HiResNickOffset / HIRES_GYRO_AMPLIFY, HiResNickOffset % HIRES_GYRO_AMPLIFY); |
||
178 | LCD_printfxy(0,2,"Roll %4i (%3i.%i)", AdValueGyroRoll - HiResRollOffset / HIRES_GYRO_AMPLIFY, HiResRollOffset / HIRES_GYRO_AMPLIFY, HiResRollOffset % HIRES_GYRO_AMPLIFY); |
||
179 | LCD_printfxy(0,3,"Yaw %4i (%3i)", AdValueGyroYaw , YawOffset); |
||
180 | break; |
||
181 | case 11: |
||
182 | case 12: |
||
183 | case 20: // divice Offests by 2 becuse 2 samples are added in adc isr |
||
184 | 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) |
||
185 | 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) |
||
186 | LCD_printfxy(0,3,"Yaw %4i (%3i)",YawOffset - AdValueGyroYaw , YawOffset/2); |
||
187 | break; |
||
188 | |||
189 | case 13: |
||
190 | default: // divice Offests by 2 becuse 2 samples are added in adc isr |
||
191 | 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) |
||
192 | 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) |
||
193 | LCD_printfxy(0,3,"Yaw %4i (%3i)(%3i)",YawOffset - AdValueGyroYaw , YawOffset/2, 0); |
||
194 | break; |
||
195 | } |
||
196 | break; |
||
197 | case 6:// Acceleration Sensor Menu Item |
||
198 | LCD_printfxy(0,0,"ACC - Sensor"); |
||
199 | LCD_printfxy(0,1,"Nick %4i (%3i)",0,0); // factor 2 because of adding 2 samples in ADC ISR |
||
200 | LCD_printfxy(0,2,"Roll %4i (%3i)",0,0); // factor 2 because of adding 2 samples in ADC ISR |
||
201 | LCD_printfxy(0,3,"Height %4i (%3i)",0,0); |
||
202 | break; |
||
203 | */ |
||
204 | case 7:// Battery Voltage / Remote Control Level |
||
205 | LCD_printfxy(0,1,"Voltage: %3i.%1iV",UBat/10, UBat%10); |
||
206 | LCD_printfxy(0,2,"RC-Level: %5i",RC_Quality); |
||
207 | break; |
||
208 | case 8:// Compass Menu Item |
||
209 | LCD_printfxy(0,0,"Compass "); |
||
210 | LCD_printfxy(0,1,"Course: %5i", compassCourse); |
||
211 | LCD_printfxy(0,2,"Heading: %5i", compassHeading); |
||
212 | LCD_printfxy(0,3,"OffCourse: %5i", ((540 + compassHeading - compassCourse) % 360) - 180); |
||
213 | break; |
||
214 | case 9:// Poti Menu Item |
||
215 | LCD_printfxy(0,0,"Po1: %3i Po5: %3i" ,variables[0], variables[4]); //PPM24-Extesion |
||
216 | LCD_printfxy(0,1,"Po2: %3i Po6: %3i" ,variables[1], variables[5]); //PPM24-Extesion |
||
217 | LCD_printfxy(0,2,"Po3: %3i Po7: %3i" ,variables[2], variables[6]); //PPM24-Extesion |
||
218 | LCD_printfxy(0,3,"Po4: %3i Po8: %3i" ,variables[3], variables[7]); //PPM24-Extesion |
||
219 | break; |
||
220 | /* |
||
221 | case 10:// Servo Menu Item |
||
222 | LCD_printfxy(0,0,"Servo " ); |
||
223 | LCD_printfxy(0,1,"Setpoint %3i",dynamicParams.ServoNickControl); |
||
224 | LCD_printfxy(0,2,"Position: %3i",ServoNickValue); |
||
225 | LCD_printfxy(0,3,"Range:%3i-%3i",staticParams.ServoNickMin, staticParams.ServoNickMax); |
||
226 | break; |
||
227 | */ |
||
228 | case 11://Extern Control |
||
229 | LCD_printfxy(0,0,"ExternControl " ); |
||
230 | LCD_printfxy(0,1,"Ni:%4i Ro:%4i ", externalControl.pitch, externalControl.roll); |
||
231 | LCD_printfxy(0,2,"Gs:%4i Ya:%4i ", externalControl.throttle, externalControl.yaw); |
||
232 | LCD_printfxy(0,3,"Hi:%4i Cf:%4i ", externalControl.height, externalControl.config); |
||
233 | break; |
||
234 | |||
235 | case 12://BL Communication errors |
||
236 | LCD_printfxy(0,0,"BL-Ctrl Errors " ); |
||
237 | LCD_printfxy(0,1," %3d %3d %3d %3d ",motor[0].Error,motor[1].Error,motor[2].Error,motor[3].Error); |
||
238 | LCD_printfxy(0,2," %3d %3d %3d %3d ",motor[4].Error,motor[5].Error,motor[6].Error,motor[7].Error); |
||
239 | LCD_printfxy(0,3," %3d %3d %3d %3d ",motor[8].Error,motor[9].Error,motor[10].Error,motor[11].Error); |
||
240 | break; |
||
241 | |||
242 | case 13://BL Overview |
||
243 | LCD_printfxy(0,0,"BL-Ctrl found " ); |
||
244 | LCD_printfxy(0,1," %c %c %c %c ",motor[0].Present + '-',motor[1].Present + '-',motor[2].Present + '-',motor[3].Present + '-'); |
||
245 | LCD_printfxy(0,2," %c %c %c %c ",motor[4].Present + '-',motor[5].Present + '-',motor[6].Present + '-',motor[7].Present + '-'); |
||
246 | LCD_printfxy(0,3," %c - - - ",motor[8].Present + '-'); |
||
247 | if (motor[9].Present) |
||
248 | LCD_printfxy(4,3,"10"); |
||
249 | if (motor[10].Present) |
||
250 | LCD_printfxy(8,3,"11"); |
||
251 | if (motor[11].Present) |
||
252 | LCD_printfxy(12,3,"12"); |
||
253 | break; |
||
254 | |||
1805 | - | 255 | #if (defined (USE_NAVICTRL)) |
1821 | - | 256 | case 14://GPS Lat/Lon coords |
257 | if (GPSInfo.status == INVALID) { |
||
258 | LCD_printfxy(0,0,"No GPS data!"); |
||
259 | } else { |
||
260 | switch (GPSInfo.satfix) |
||
261 | { |
||
262 | case SATFIX_NONE: |
||
263 | LCD_printfxy(0,0,"Sats: %d Fix: No", GPSInfo.satnum); |
||
264 | break; |
||
265 | case SATFIX_2D: |
||
266 | LCD_printfxy(0,0,"Sats: %d Fix: 2D", GPSInfo.satnum); |
||
267 | break; |
||
268 | case SATFIX_3D: |
||
269 | LCD_printfxy(0,0,"Sats: %d Fix: 3D", GPSInfo.satnum); |
||
270 | break; |
||
271 | default: |
||
272 | LCD_printfxy(0,0,"Sats: %d Fix: ??", GPSInfo.satnum); |
||
273 | break; |
||
274 | } |
||
275 | int16_t i1,i2,i3; |
||
276 | i1 = (int16_t)(GPSInfo.longitude/10000000L); |
||
277 | i2 = abs((int16_t)((GPSInfo.longitude%10000000L)/10000L)); |
||
278 | i3 = abs((int16_t)(((GPSInfo.longitude%10000000L)%10000L)/10L)); |
||
279 | LCD_printfxy(0,1,"Lon: %d.%03d%03d deg",i1, i2, i3); |
||
280 | i1 = (int16_t)(GPSInfo.latitude/10000000L); |
||
281 | i2 = abs((int16_t)((GPSInfo.latitude%10000000L)/10000L)); |
||
282 | i3 = abs((int16_t)(((GPSInfo.latitude%10000000L)%10000L)/10L)); |
||
283 | LCD_printfxy(0,2,"Lat: %d.%03d%03d deg",i1, i2, i3); |
||
284 | i1 = (int16_t)(GPSInfo.altitude/1000L); |
||
285 | i2 = abs((int16_t)(GPSInfo.altitude%1000L)); |
||
286 | LCD_printfxy(0,3,"Alt: %d.%03d m",i1, i2); |
||
287 | } |
||
288 | break; |
||
289 | #endif |
||
290 | |||
1612 | dongfang | 291 | default: |
2018 | - | 292 | maxMenuItem = menuItem - 1; |
293 | menuItem = 0; |
||
1821 | - | 294 | break; |
1612 | dongfang | 295 | } |
2018 | - | 296 | remoteKeys = 0; |
1612 | dongfang | 297 | } |