Rev 2041 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2041 | Rev 2048 | ||
---|---|---|---|
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Copyright (c) 04.2007 Holger Buss |
2 | // + Copyright (c) 04.2007 Holger Buss |
3 | // + Nur f�r den privaten Gebrauch |
3 | // + Nur f�r den privaten Gebrauch |
4 | // + www.MikroKopter.com |
4 | // + www.MikroKopter.com |
5 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
5 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
6 | // + Es gilt f�r das gesamte Projekt (Hardware, Software, Bin�rfiles, Sourcecode und Dokumentation), |
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. |
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 |
8 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
9 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
9 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
10 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Best�ckung und Verkauf von Platinen oder Baus�tzen, |
10 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Best�ckung und Verkauf von Platinen oder Baus�tzen, |
11 | // + Verkauf von Luftbildaufnahmen, usw. |
11 | // + Verkauf von Luftbildaufnahmen, usw. |
12 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
12 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
13 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder ver�ffentlicht, |
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 |
14 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright m�ssen dann beiliegen |
15 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
15 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
16 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
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" |
17 | // + auf anderen Webseiten oder sonstigen Medien ver�ffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
18 | // + eindeutig als Ursprung verlinkt werden |
18 | // + eindeutig als Ursprung verlinkt werden |
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
20 | // + Keine Gew�hr auf Fehlerfreiheit, Vollst�ndigkeit oder Funktion |
20 | // + Keine Gew�hr auf Fehlerfreiheit, Vollst�ndigkeit oder Funktion |
21 | // + Benutzung auf eigene Gefahr |
21 | // + Benutzung auf eigene Gefahr |
22 | // + Wir �bernehmen keinerlei Haftung f�r direkte oder indirekte Personen- oder Sachsch�den |
22 | // + Wir �bernehmen keinerlei Haftung f�r direkte oder indirekte Personen- oder Sachsch�den |
23 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
23 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
24 | // + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
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 |
25 | // + mit unserer Zustimmung zul�ssig |
26 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
26 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
27 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
27 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
28 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
28 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
29 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
29 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
30 | // + this list of conditions and the following disclaimer. |
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 |
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. |
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 |
33 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
34 | // + for non-commercial use (directly or indirectly) |
34 | // + for non-commercial use (directly or indirectly) |
35 | // + Commercial use (for example: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
35 | // + Commercial use (for example: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
36 | // + with our written permission |
36 | // + with our written permission |
37 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
37 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
38 | // + clearly linked as origin |
38 | // + clearly linked as origin |
39 | // + * porting to systems other than hardware from www.mikrokopter.de is not allowed |
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" |
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 |
41 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
42 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
42 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
43 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
43 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
44 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
44 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
45 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
45 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
46 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
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) |
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 |
48 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
49 | // + POSSIBILITY OF SUCH DAMAGE. |
49 | // + POSSIBILITY OF SUCH DAMAGE. |
50 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
50 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
51 | #include <stdlib.h> |
51 | #include <stdlib.h> |
52 | #include <inttypes.h> |
52 | #include <inttypes.h> |
53 | #include "eeprom.h" |
53 | #include "eeprom.h" |
54 | #include "timer2.h" |
54 | #include "timer2.h" |
55 | #include "rc.h" |
55 | #include "rc.h" |
56 | #include "externalControl.h" |
56 | #include "externalControl.h" |
57 | #include "uart0.h" |
57 | #include "uart0.h" |
58 | #include "printf_P.h" |
58 | #include "printf_P.h" |
59 | #include "analog.h" |
59 | #include "analog.h" |
60 | #include "twimaster.h" |
60 | #include "twimaster.h" |
61 | #include "attitude.h" |
61 | #include "attitude.h" |
62 | 62 | ||
63 | #if (!defined (USE_NAVICTRL)) |
63 | #if (!defined (USE_NAVICTRL)) |
64 | uint8_t maxMenuItem = 13; |
64 | uint8_t maxMenuItem = 13; |
65 | #else |
65 | #else |
66 | #ifdef USE_NAVICTRL |
66 | #ifdef USE_NAVICTRL |
67 | #include "gps.c" |
67 | #include "gps.c" |
68 | uint8_t maxMenuItem = 14; |
68 | uint8_t maxMenuItem = 14; |
69 | #endif |
69 | #endif |
70 | #endif |
70 | #endif |
71 | uint8_t menuItem = 0; |
71 | uint8_t menuItem = 0; |
72 | uint8_t remoteKeys = 0; |
72 | uint8_t remoteKeys = 0; |
73 | 73 | ||
74 | #define KEY1 0x01 |
74 | #define KEY1 0x01 |
75 | #define KEY2 0x02 |
75 | #define KEY2 0x02 |
76 | #define KEY3 0x04 |
76 | #define KEY3 0x04 |
77 | #define KEY4 0x08 |
77 | #define KEY4 0x08 |
78 | #define KEY5 0x10 |
78 | #define KEY5 0x10 |
79 | 79 | ||
80 | #define DISPLAYBUFFSIZE 80 |
80 | #define DISPLAYBUFFSIZE 80 |
81 | int8_t displayBuff[DISPLAYBUFFSIZE] = "Hello World"; |
81 | int8_t displayBuff[DISPLAYBUFFSIZE] = "Hello World"; |
82 | uint8_t dispPtr = 0; |
82 | uint8_t dispPtr = 0; |
83 | 83 | ||
84 | /************************************/ |
84 | /************************************/ |
85 | /* Clear LCD Buffer */ |
85 | /* Clear LCD Buffer */ |
86 | /************************************/ |
86 | /************************************/ |
87 | void LCD_clear(void) { |
87 | void LCD_clear(void) { |
88 | uint8_t i; |
88 | uint8_t i; |
89 | for (i = 0; i < DISPLAYBUFFSIZE; i++) |
89 | for (i = 0; i < DISPLAYBUFFSIZE; i++) |
90 | displayBuff[i] = ' '; |
90 | displayBuff[i] = ' '; |
91 | } |
91 | } |
92 | 92 | ||
93 | /************************************/ |
93 | /************************************/ |
94 | /* Update Menu on LCD */ |
94 | /* Update Menu on LCD */ |
95 | /************************************/ |
95 | /************************************/ |
96 | // Display with 20 characters in 4 lines |
96 | // Display with 20 characters in 4 lines |
97 | void LCD_printMenu(void) { |
97 | void LCD_printMenu(void) { |
254 | 280 | ||
255 | #if (defined (USE_NAVICTRL)) |
281 | #if (defined (USE_NAVICTRL)) |
256 | case 14://GPS Lat/Lon coords |
282 | case 14: //GPS Lat/Lon coords |
257 | if (GPSInfo.status == INVALID) { |
283 | if (GPSInfo.status == INVALID) { |
258 | LCD_printfxy(0,0,"No GPS data!"); |
284 | LCD_printfxy(0,0,"No GPS data!"); |
259 | } else { |
285 | } else { |
260 | switch (GPSInfo.satfix) |
286 | switch (GPSInfo.satfix) |
261 | { |
287 | { |
262 | case SATFIX_NONE: |
288 | case SATFIX_NONE: |
263 | LCD_printfxy(0,0,"Sats: %d Fix: No", GPSInfo.satnum); |
289 | LCD_printfxy(0,0,"Sats: %d Fix: No", GPSInfo.satnum); |
264 | break; |
290 | break; |
265 | case SATFIX_2D: |
291 | case SATFIX_2D: |
266 | LCD_printfxy(0,0,"Sats: %d Fix: 2D", GPSInfo.satnum); |
292 | LCD_printfxy(0,0,"Sats: %d Fix: 2D", GPSInfo.satnum); |
267 | break; |
293 | break; |
268 | case SATFIX_3D: |
294 | case SATFIX_3D: |
269 | LCD_printfxy(0,0,"Sats: %d Fix: 3D", GPSInfo.satnum); |
295 | LCD_printfxy(0,0,"Sats: %d Fix: 3D", GPSInfo.satnum); |
270 | break; |
296 | break; |
271 | default: |
297 | default: |
272 | LCD_printfxy(0,0,"Sats: %d Fix: ??", GPSInfo.satnum); |
298 | LCD_printfxy(0,0,"Sats: %d Fix: ??", GPSInfo.satnum); |
273 | break; |
299 | break; |
274 | } |
300 | } |
275 | int16_t i1,i2,i3; |
301 | int16_t i1,i2,i3; |
276 | i1 = (int16_t)(GPSInfo.longitude/10000000L); |
302 | i1 = (int16_t)(GPSInfo.longitude/10000000L); |
277 | i2 = abs((int16_t)((GPSInfo.longitude%10000000L)/10000L)); |
303 | i2 = abs((int16_t)((GPSInfo.longitude%10000000L)/10000L)); |
278 | i3 = abs((int16_t)(((GPSInfo.longitude%10000000L)%10000L)/10L)); |
304 | i3 = abs((int16_t)(((GPSInfo.longitude%10000000L)%10000L)/10L)); |
279 | LCD_printfxy(0,1,"Lon: %d.%03d%03d deg",i1, i2, i3); |
305 | LCD_printfxy(0,1,"Lon: %d.%03d%03d deg",i1, i2, i3); |
280 | i1 = (int16_t)(GPSInfo.latitude/10000000L); |
306 | i1 = (int16_t)(GPSInfo.latitude/10000000L); |
281 | i2 = abs((int16_t)((GPSInfo.latitude%10000000L)/10000L)); |
307 | i2 = abs((int16_t)((GPSInfo.latitude%10000000L)/10000L)); |
282 | i3 = abs((int16_t)(((GPSInfo.latitude%10000000L)%10000L)/10L)); |
308 | i3 = abs((int16_t)(((GPSInfo.latitude%10000000L)%10000L)/10L)); |
283 | LCD_printfxy(0,2,"Lat: %d.%03d%03d deg",i1, i2, i3); |
309 | LCD_printfxy(0,2,"Lat: %d.%03d%03d deg",i1, i2, i3); |
284 | i1 = (int16_t)(GPSInfo.altitude/1000L); |
310 | i1 = (int16_t)(GPSInfo.altitude/1000L); |
285 | i2 = abs((int16_t)(GPSInfo.altitude%1000L)); |
311 | i2 = abs((int16_t)(GPSInfo.altitude%1000L)); |
286 | LCD_printfxy(0,3,"Alt: %d.%03d m",i1, i2); |
312 | LCD_printfxy(0,3,"Alt: %d.%03d m",i1, i2); |
287 | } |
313 | } |
288 | break; |
314 | break; |
289 | #endif |
315 | #endif |
290 | 316 | ||
291 | default: |
317 | default: |
292 | maxMenuItem = menuItem - 1; |
318 | maxMenuItem = menuItem - 1; |
293 | menuItem = 0; |
319 | menuItem = 0; |
294 | break; |
320 | break; |
295 | } |
321 | } |
296 | remoteKeys = 0; |
322 | remoteKeys = 0; |
297 | } |
323 | } |
298 | 324 |