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 "main.h" |
||
11 | #include "uart0.h" |
||
12 | #include "printf_P.h" |
||
13 | #include "ubx.h" |
||
14 | |||
15 | uint8_t MaxMenuItem = 1; |
||
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 | { |
||
48 | if(RemoteKeys & KEY1) |
||
49 | { |
||
50 | if(MenuItem) MenuItem--; |
||
51 | else MenuItem = MaxMenuItem; |
||
52 | } |
||
53 | if(RemoteKeys & KEY2) |
||
54 | { |
||
55 | if(MenuItem == MaxMenuItem) MenuItem = 0; |
||
56 | else MenuItem++; |
||
57 | } |
||
58 | if((RemoteKeys & KEY1) && (RemoteKeys & KEY2)) MenuItem = 0; |
||
59 | |||
60 | LCD_Clear(); |
||
61 | |||
62 | if(MenuItem > MaxMenuItem) MenuItem = MaxMenuItem; |
||
63 | // print menu item number in the upper right corner |
||
64 | if(MenuItem < 10) |
||
65 | { |
||
66 | LCD_printfxy(17,0,"[%i]",MenuItem); |
||
67 | } |
||
68 | else |
||
69 | { |
||
70 | LCD_printfxy(16,0,"[%i]",MenuItem); |
||
71 | } |
||
72 | |||
73 | switch(MenuItem) |
||
74 | { |
||
75 | case 0:// Version Info Menu Item |
||
76 | LCD_printfxy(0,0,"+ Follow Me +"); |
||
77 | #ifdef USE_SDLOGGER |
||
78 | LCD_printfxy(0,1,"HW: SD-Logger"); |
||
79 | #endif |
||
80 | #ifdef USE_FOLLOWME |
||
81 | LCD_printfxy(0,1,"HW: Follow-Me"); |
||
82 | #endif |
||
83 | LCD_printfxy(0,2,"SW: %d.%d%c", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a'); |
||
84 | LCD_printfxy(0,3," "); |
||
85 | break; |
||
86 | |||
87 | case 1://GPS Lat/Lon coords |
||
88 | if (GPSInfo.status == INVALID) |
||
89 | { |
||
90 | LCD_printfxy(0,0,"No GPS data!"); |
||
91 | } |
||
92 | else |
||
93 | { |
||
94 | switch (GPSInfo.satfix) |
||
95 | { |
||
96 | case SATFIX_NONE: |
||
97 | LCD_printfxy(0,0,"Sats: %d Fix: No", GPSInfo.satnum); |
||
98 | break; |
||
99 | case SATFIX_2D: |
||
100 | LCD_printfxy(0,0,"Sats: %d Fix: 2D", GPSInfo.satnum); |
||
101 | break; |
||
102 | case SATFIX_3D: |
||
103 | LCD_printfxy(0,0,"Sats: %d Fix: 3D", GPSInfo.satnum); |
||
104 | break; |
||
105 | default: |
||
106 | LCD_printfxy(0,0,"Sats: %d Fix: ??", GPSInfo.satnum); |
||
107 | break; |
||
108 | } |
||
109 | int16_t i1,i2,i3; |
||
110 | i1 = (int16_t)(GPSInfo.longitude/10000000L); |
||
111 | i2 = abs((int16_t)((GPSInfo.longitude%10000000L)/10000L)); |
||
112 | i3 = abs((int16_t)(((GPSInfo.longitude%10000000L)%10000L)/10L)); |
||
113 | LCD_printfxy(0,1,"Lon: %d.%.3d%.3d deg",i1, i2, i3); |
||
114 | i1 = (int16_t)(GPSInfo.latitude/10000000L); |
||
115 | i2 = abs((int16_t)((GPSInfo.latitude%10000000L)/10000L)); |
||
116 | i3 = abs((int16_t)(((GPSInfo.latitude%10000000L)%10000L)/10L)); |
||
117 | LCD_printfxy(0,2,"Lat: %d.%.3d%.3d deg",i1, i2, i3); |
||
118 | i1 = (int16_t)(GPSInfo.altitude/1000L); |
||
119 | i2 = abs((int16_t)(GPSInfo.altitude%1000L)); |
||
120 | LCD_printfxy(0,3,"Alt: %d.%.3d m",i1, i2); |
||
121 | } |
||
122 | break; |
||
123 | |||
124 | default: MaxMenuItem = MenuItem - 1; |
||
125 | MenuItem = 0; |
||
126 | break; |
||
127 | } |
||
128 | RemoteKeys = 0; |
||
129 | } |