Subversion Repositories NaviCtrl

Rev

Rev 355 | Rev 380 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 355 Rev 357
1
/*#######################################################################################*/
1
/*#######################################################################################*/
2
/* !!! THIS IS NOT FREE SOFTWARE !!!                                                     */
2
/* !!! THIS IS NOT FREE SOFTWARE !!!                                                     */
3
/*#######################################################################################*/
3
/*#######################################################################################*/
4
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5
// + Copyright (c) 2008 Ingo Busker, Holger Buss
5
// + Copyright (c) 2008 Ingo Busker, Holger Buss
6
// + Nur für den privaten Gebrauch / NON-COMMERCIAL USE ONLY
6
// + Nur für den privaten Gebrauch / NON-COMMERCIAL USE ONLY
7
// + FOR NON COMMERCIAL USE ONLY
7
// + FOR NON COMMERCIAL USE ONLY
8
// + www.MikroKopter.com
8
// + www.MikroKopter.com
9
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation),
10
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation),
11
// + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist.
11
// + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist.
12
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
12
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
13
// + bzgl. der Nutzungsbedingungen aufzunehmen.
13
// + bzgl. der Nutzungsbedingungen aufzunehmen.
14
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen,
14
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen,
15
// + Verkauf von Luftbildaufnahmen, usw.
15
// + Verkauf von Luftbildaufnahmen, usw.
16
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
16
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
17
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht,
17
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht,
18
// + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen
18
// + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen
19
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20
// + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts
20
// + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts
21
// + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de"
21
// + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de"
22
// + eindeutig als Ursprung verlinkt werden
22
// + eindeutig als Ursprung verlinkt werden
23
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24
// + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion
24
// + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion
25
// + Benutzung auf eigene Gefahr
25
// + Benutzung auf eigene Gefahr
26
// + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden
26
// + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden
27
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
28
// + Die Portierung oder Nutzung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur
28
// + Die Portierung oder Nutzung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur
29
// + mit unserer Zustimmung zulässig
29
// + mit unserer Zustimmung zulässig
30
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen
31
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen
32
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33
// + Redistributions of source code (with or without modifications) must retain the above copyright notice,
33
// + Redistributions of source code (with or without modifications) must retain the above copyright notice,
34
// + this list of conditions and the following disclaimer.
34
// + this list of conditions and the following disclaimer.
35
// +   * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived
35
// +   * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived
36
// +     from this software without specific prior written permission.
36
// +     from this software without specific prior written permission.
37
// +   * The use of this project (hardware, software, binary files, sources and documentation) is only permitted
37
// +   * The use of this project (hardware, software, binary files, sources and documentation) is only permitted
38
// +     for non-commercial use (directly or indirectly)
38
// +     for non-commercial use (directly or indirectly)
39
// +     Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted
39
// +     Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted
40
// +     with our written permission
40
// +     with our written permission
41
// +   * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be
41
// +   * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be
42
// +     clearly linked as origin
42
// +     clearly linked as origin
43
// +   * porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed
43
// +   * porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed
44
//
44
//
45
// +  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
45
// +  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
46
// +  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46
// +  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47
// +  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47
// +  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48
// +  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
48
// +  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
49
// +  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
49
// +  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
50
// +  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
50
// +  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
51
// +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
51
// +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
52
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
52
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
53
// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53
// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
54
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
55
// +  POSSIBILITY OF SUCH DAMAGE.
55
// +  POSSIBILITY OF SUCH DAMAGE.
56
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
56
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
57
#include <stdlib.h>
57
#include <stdlib.h>
58
#include "91x_lib.h"
58
#include "91x_lib.h"
59
#include "main.h"
59
#include "main.h"
60
#include "led.h"
60
#include "led.h"
61
#include "ubx.h"
61
#include "ubx.h"
62
#include "GPS.h"
62
#include "GPS.h"
63
#include "timer1.h"
63
#include "timer1.h"
64
#include "compass.h"
64
#include "compass.h"
65
#include "spi_slave.h"
65
#include "spi_slave.h"
66
#include "menu.h"
66
#include "menu.h"
67
#include "uart1.h"
67
#include "uart1.h"
68
#include "ncmag.h"
68
#include "ncmag.h"
69
 
69
 
70
u8 DispPtr = 0;
70
u8 DispPtr = 0;
71
s8 DisplayBuff[DISPLAYBUFFSIZE];
71
s8 DisplayBuff[DISPLAYBUFFSIZE];
72
 
72
 
73
 
73
 
74
u8 MenuItem = 0;
74
u8 MenuItem = 0;
75
u8 MaxMenuItem = 18;
75
u8 MaxMenuItem = 18;
76
 
76
 
77
void Menu_Putchar(char c)
77
void Menu_Putchar(char c)
78
{
78
{
79
   if(DispPtr < DISPLAYBUFFSIZE) DisplayBuff[DispPtr++] = c; ;
79
   if(DispPtr < DISPLAYBUFFSIZE) DisplayBuff[DispPtr++] = c; ;
80
}
80
}
81
 
81
 
82
void Menu_Clear(void)
82
void Menu_Clear(void)
83
{
83
{
84
        u8 i;
84
        u8 i;
85
        for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' ';
85
        for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' ';
86
}
86
}
87
 
87
 
88
 
88
 
89
// Display with 20 characters in 4 lines
89
// Display with 20 characters in 4 lines
90
void Menu_Update(u8 Keys)
90
void Menu_Update(u8 Keys)
91
{
91
{
92
        s32 i1,i2;
92
        s32 i1,i2;
93
        u8 sign;
93
        u8 sign;
94
 
94
 
95
        if(Keys & KEY1) { if(MenuItem > 0) MenuItem--; else MenuItem = MaxMenuItem;}
95
        if(Keys & KEY1) { if(MenuItem > 0) MenuItem--; else MenuItem = MaxMenuItem;}
96
        if(Keys & KEY2) { if(MenuItem == MaxMenuItem) MenuItem = 0; else MenuItem++;}
96
        if(Keys & KEY2) { if(MenuItem == MaxMenuItem) MenuItem = 0; else MenuItem++;}
97
        if((Keys & KEY1) && (Keys & KEY2)) MenuItem = 0;
97
        if((Keys & KEY1) && (Keys & KEY2)) MenuItem = 0;
98
        if(MenuItem > MaxMenuItem) MenuItem = MaxMenuItem;
98
        if(MenuItem > MaxMenuItem) MenuItem = MaxMenuItem;
99
        Menu_Clear();
99
        Menu_Clear();
100
        // print menu item number in the upper right corner
100
        // print menu item number in the upper right corner
101
        if(MenuItem < 10)
101
        if(MenuItem < 10)
102
        {
102
        {
103
                LCD_printfxy(17,0,"[%i]",MenuItem);
103
                LCD_printfxy(17,0,"[%i]",MenuItem);
104
        }
104
        }
105
        else // Menuitem >= 10
105
        else // Menuitem >= 10
106
        {
106
        {
107
                LCD_printfxy(16,0,"[%i]",MenuItem);
107
                LCD_printfxy(16,0,"[%i]",MenuItem);
108
        }
108
        }
109
 
109
 
110
        switch(MenuItem)
110
        switch(MenuItem)
111
        {
111
        {
112
                // Version Info
112
                // Version Info
113
                case 0:
113
                case 0:
114
                        LCD_printfxy(0,0,"++  Navi-Ctrl  ++");
114
                        LCD_printfxy(0,0,"++  Navi-Ctrl  ++");
115
                        LCD_printfxy(0,1,"HW V%d.%d SW V%d.%d%c", Version_HW/10, Version_HW%10, VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH);
115
                        LCD_printfxy(0,1,"HW V%d.%d SW V%d.%d%c", Version_HW/10, Version_HW%10, VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH);
116
 
116
 
117
            if(ErrorCode)
117
            if(ErrorCode)
118
                        {
118
                        {
119
                                LCD_printfxy(0,2,"Error: %d",ErrorCode);
119
                                LCD_printfxy(0,2,"Error: %d",ErrorCode);
120
                LCD_printfxy(0,3,"%s",ErrorMSG);
120
                LCD_printfxy(0,3,"%s",ErrorMSG);
121
                        }
121
                        }
122
                        else
122
                        else
123
                        {
123
                        {
124
                         LCD_printfxy(0,3,"(c) Buss, Busker");
124
                         LCD_printfxy(0,3,"(c) Buss, Busker");
125
                         LCD_printfxy(0,2,"%s",ErrorMSG);
125
                         LCD_printfxy(0,2,"%s",ErrorMSG);
126
                        }
126
                        }
127
                        break;
127
                        break;
128
                case 1:
128
                case 1:
129
                        if (GPSData.Status == INVALID)
129
                        if (GPSData.Status == INVALID)
130
                        {
130
                        {
131
                                LCD_printfxy(0,0,"No GPS data");
131
                                LCD_printfxy(0,0,"No GPS data");
132
                                LCD_printfxy(0,1,"Lon:                ");
132
                                LCD_printfxy(0,1,"Lon:                ");
133
                                LCD_printfxy(0,2,"Lat:                ");
133
                                LCD_printfxy(0,2,"Lat:                ");
134
                                LCD_printfxy(0,3,"Alt:                ");
134
                                LCD_printfxy(0,3,"Alt:                ");
135
                        }
135
                        }
136
                        else // newdata or processed
136
                        else // newdata or processed
137
                        {
137
                        {
138
                                LCD_printfxy(0,0,"Sat:%02d ", GPSData.NumOfSats);
138
                                LCD_printfxy(0,0,"Sat:%02d ", GPSData.NumOfSats);
139
                                switch (GPSData.SatFix)
139
                                switch (GPSData.SatFix)
140
                                {
140
                                {
141
                                case SATFIX_NONE:
141
                                case SATFIX_NONE:
142
                                        LCD_printfxy(7,0,"NoFix");
142
                                        LCD_printfxy(7,0,"NoFix");
143
                                        break;
143
                                        break;
144
                                case SATFIX_2D:
144
                                case SATFIX_2D:
145
                                        LCD_printfxy(7,0,"2DFix");
145
                                        LCD_printfxy(7,0,"2DFix");
146
                                        break;
146
                                        break;
147
                                case SATFIX_3D:
147
                                case SATFIX_3D:
148
                                        LCD_printfxy(7,0,"3DFix");
148
                                        LCD_printfxy(7,0,"3DFix");
149
                                        break;
149
                                        break;
150
                                default:
150
                                default:
151
                                        LCD_printfxy(7,0,"??Fix");
151
                                        LCD_printfxy(7,0,"??Fix");
152
                                        break;
152
                                        break;
153
                                }
153
                                }
154
                                if(GPSData.Flags & FLAG_DIFFSOLN)
154
                                if(GPSData.Flags & FLAG_DIFFSOLN)
155
                                {
155
                                {
156
                                        LCD_printfxy(12,0,"/DGPS");
156
                                        LCD_printfxy(12,0,"/DGPS");
157
                                }
157
                                }
158
                                else
158
                                else
159
                                {
159
                                {
160
                                        LCD_printfxy(12,0,"     ");
160
                                        LCD_printfxy(12,0,"     ");
161
                                }
161
                                }
162
 
162
 
163
                                if(GPSData.Position.Longitude < 0) sign = '-';
163
                                if(GPSData.Position.Longitude < 0) sign = '-';
164
                                else sign = '+';
164
                                else sign = '+';
165
                                i1 = abs(GPSData.Position.Longitude)/10000000L;
165
                                i1 = abs(GPSData.Position.Longitude)/10000000L;
166
                                i2 = abs(GPSData.Position.Longitude)%10000000L;
166
                                i2 = abs(GPSData.Position.Longitude)%10000000L;
167
                                LCD_printfxy(0,1,"Lon:%c%03ld.%07ld deg",sign, i1, i2);
167
                                LCD_printfxy(0,1,"Lon:%c%03ld.%07ld deg",sign, i1, i2);
168
                                if(GPSData.Position.Latitude < 0) sign = '-';
168
                                if(GPSData.Position.Latitude < 0) sign = '-';
169
                                else sign = '+';
169
                                else sign = '+';
170
                                i1 = abs(GPSData.Position.Latitude)/10000000L;
170
                                i1 = abs(GPSData.Position.Latitude)/10000000L;
171
                                i2 = abs(GPSData.Position.Latitude)%10000000L;
171
                                i2 = abs(GPSData.Position.Latitude)%10000000L;
172
                                LCD_printfxy(0,2,"Lat:%c%03ld.%07ld deg",sign, i1, i2);
172
                                LCD_printfxy(0,2,"Lat:%c%03ld.%07ld deg",sign, i1, i2);
173
                                if(GPSData.Position.Altitude < 0) sign = '-';
173
                                if(GPSData.Position.Altitude < 0) sign = '-';
174
                                else sign = '+';
174
                                else sign = '+';
175
                                i1 = abs(GPSData.Position.Altitude)/1000L;
175
                                i1 = abs(GPSData.Position.Altitude)/1000L;
176
                                i2 = abs(GPSData.Position.Altitude)%1000L;
176
                                i2 = abs(GPSData.Position.Altitude)%1000L;
177
                                LCD_printfxy(0,3,"Alt:%c%04ld.%03ld m", sign, i1, i2);
177
                                LCD_printfxy(0,3,"Alt:%c%04ld.%03ld m", sign, i1, i2);
178
                        }
178
                        }
179
                        break;
179
                        break;
180
                case 2:
180
                case 2:
181
                        if (GPSData.Status == INVALID)
181
                        if (GPSData.Status == INVALID)
182
                        {
182
                        {
183
                                LCD_printfxy(0,0,"No GPS data");
183
                                LCD_printfxy(0,0,"No GPS data");
184
                                LCD_printfxy(0,1,"Speed N:            ");
184
                                LCD_printfxy(0,1,"Speed N:            ");
185
                                LCD_printfxy(0,2,"Speed E:            ");
185
                                LCD_printfxy(0,2,"Speed E:            ");
186
                                LCD_printfxy(0,3,"Speed T:            ");
186
                                LCD_printfxy(0,3,"Speed T:            ");
187
                        }
187
                        }
188
                        else // newdata or processed
188
                        else // newdata or processed
189
                        {
189
                        {
190
                                LCD_printfxy(0,0,"Sat:%02d ", GPSData.NumOfSats);
190
                                LCD_printfxy(0,0,"Sat:%02d ", GPSData.NumOfSats);
191
                                switch (GPSData.SatFix)
191
                                switch (GPSData.SatFix)
192
                                {
192
                                {
193
                                case SATFIX_NONE:
193
                                case SATFIX_NONE:
194
                                        LCD_printfxy(7,0,"NoFix");
194
                                        LCD_printfxy(7,0,"NoFix");
195
                                        break;
195
                                        break;
196
                                case SATFIX_2D:
196
                                case SATFIX_2D:
197
                                        LCD_printfxy(7,0,"2DFix");
197
                                        LCD_printfxy(7,0,"2DFix");
198
                                        break;
198
                                        break;
199
                                case SATFIX_3D:
199
                                case SATFIX_3D:
200
                                        LCD_printfxy(7,0,"3DFix");
200
                                        LCD_printfxy(7,0,"3DFix");
201
                                        break;
201
                                        break;
202
                                default:
202
                                default:
203
                                        LCD_printfxy(7,0,"??Fix");
203
                                        LCD_printfxy(7,0,"??Fix");
204
                                        break;
204
                                        break;
205
                                }
205
                                }
206
                                if(GPSData.Flags & FLAG_DIFFSOLN)
206
                                if(GPSData.Flags & FLAG_DIFFSOLN)
207
                                {
207
                                {
208
                                        LCD_printfxy(12,0,"/DGPS");
208
                                        LCD_printfxy(12,0,"/DGPS");
209
                                }
209
                                }
210
                                else
210
                                else
211
                                {
211
                                {
212
                                        LCD_printfxy(12,0,"     ");
212
                                        LCD_printfxy(12,0,"     ");
213
                                }
213
                                }
214
 
214
 
215
                                LCD_printfxy(0,1,"Speed N: %+4ld cm/s",GPSData.Speed_North);
215
                                LCD_printfxy(0,1,"Speed N: %+4ld cm/s",GPSData.Speed_North);
216
                                LCD_printfxy(0,2,"Speed E: %+4ld cm/s",GPSData.Speed_East);
216
                                LCD_printfxy(0,2,"Speed E: %+4ld cm/s",GPSData.Speed_East);
217
                                LCD_printfxy(0,3,"Speed T: %+4ld cm/s",GPSData.Speed_Top);
217
                                LCD_printfxy(0,3,"Speed T: %+4ld cm/s",GPSData.Speed_Top);
218
                        }
218
                        }
219
                        break;
219
                        break;
220
                case 3:
220
                case 3:
221
                        LCD_printfxy(0,0,"GPS UTC Time");
221
                        LCD_printfxy(0,0,"GPS UTC Time");
222
                        if (!SystemTime.Valid)
222
                        if (!SystemTime.Valid)
223
                        {
223
                        {
224
                                LCD_printfxy(0,1,"                    ");
224
                                LCD_printfxy(0,1,"                    ");
225
                                LCD_printfxy(0,2,"  No time data!     ");
225
                                LCD_printfxy(0,2,"  No time data!     ");
226
                                LCD_printfxy(0,3,"                    ");
226
                                LCD_printfxy(0,3,"                    ");
227
                        }
227
                        }
228
                        else // newdata or processed
228
                        else // newdata or processed
229
                        {
229
                        {
230
                                LCD_printfxy(0,1,"                    ");
230
                                LCD_printfxy(0,1,"                    ");
231
                                LCD_printfxy(0,2,"Date: %02i/%02i/%04i",SystemTime.Month, SystemTime.Day, SystemTime.Year);
231
                                LCD_printfxy(0,2,"Date: %02i/%02i/%04i",SystemTime.Month, SystemTime.Day, SystemTime.Year);
232
                                LCD_printfxy(0,3,"Time: %02i:%02i:%02i.%03i", SystemTime.Hour, SystemTime.Min, SystemTime.Sec, SystemTime.mSec);
232
                                LCD_printfxy(0,3,"Time: %02i:%02i:%02i.%03i", SystemTime.Hour, SystemTime.Min, SystemTime.Sec, SystemTime.mSec);
233
                        }
233
                        }
234
                        break;
234
                        break;
235
                case 4: // Navi Params 1 from FC
235
                case 4: // Navi Params 1 from FC
236
                        LCD_printfxy(0,0,"NaviMode: %3i" ,  Parameter.NaviGpsModeControl);
236
                        LCD_printfxy(0,0,"NaviMode: %3i" ,  Parameter.NaviGpsModeControl);
237
            LCD_printfxy(0,1,"G  :%3i P  :%3i ",Parameter.NaviGpsGain, Parameter.NaviGpsP);
237
            LCD_printfxy(0,1,"G  :%3i P  :%3i ",Parameter.NaviGpsGain, Parameter.NaviGpsP);
238
            LCD_printfxy(0,2,"I  :%3i D  :%3i ",Parameter.NaviGpsI, Parameter.NaviGpsD);
238
            LCD_printfxy(0,2,"I  :%3i D  :%3i ",Parameter.NaviGpsI, Parameter.NaviGpsD);
239
                    LCD_printfxy(0,3,"ACC:%3i SAT:%3i ",Parameter.NaviGpsACC, Parameter.NaviGpsMinSat);
239
                    LCD_printfxy(0,3,"ACC:%3i SAT:%3i ",Parameter.NaviGpsACC, Parameter.NaviGpsMinSat);
240
                        break;
240
                        break;
241
                case 5: // Navi Params 2 from FC
241
                case 5: // Navi Params 2 from FC
242
                        LCD_printfxy(0,0,"Stick TS:  %3i", Parameter.NaviStickThreshold);
242
                        LCD_printfxy(0,0,"Stick TS:  %3i", Parameter.NaviStickThreshold);
243
            LCD_printfxy(0,1,"MaxRadius: %3im", DebugOut.Analog[4]);
243
            LCD_printfxy(0,1,"MaxRadius: %3im", DebugOut.Analog[4]);
244
            LCD_printfxy(0,2,"WindCorr:  %3i", Parameter.NaviWindCorrection);
244
            LCD_printfxy(0,2,"WindCorr:  %3i", Parameter.NaviWindCorrection);
245
                    LCD_printfxy(0,3,"AccComp:   %3i", Parameter.NaviSpeedCompensation);
245
                    LCD_printfxy(0,3,"AccComp:   %3i", Parameter.NaviSpeedCompensation);
246
                        break;
246
                        break;
247
                case 6: // Navi Params 3 from FC
247
                case 6: // Navi Params 3 from FC
248
                        LCD_printfxy(0,0,"Angle-Limit: %3i", Parameter.NaviAngleLimitation);
248
                        LCD_printfxy(0,0,"Angle-Limit: %3i", Parameter.NaviAngleLimitation);
249
            LCD_printfxy(0,1,"    P-Limit: %3i", Parameter.NaviGpsPLimit);
249
            LCD_printfxy(0,1,"    P-Limit: %3i", Parameter.NaviGpsPLimit);
250
            LCD_printfxy(0,2,"    I-Limit: %3i", Parameter.NaviGpsILimit);
250
            LCD_printfxy(0,2,"    I-Limit: %3i", Parameter.NaviGpsILimit);
251
                    LCD_printfxy(0,3,"    D-Limit: %3i", Parameter.NaviGpsDLimit);
251
                    LCD_printfxy(0,3,"    D-Limit: %3i", Parameter.NaviGpsDLimit);
252
                        break;
252
                        break;
253
                case 7: // Max Ranges
253
                case 7: // Max Ranges
254
                        LCD_printfxy(0,0,"Maximum flying  ");
254
                        LCD_printfxy(0,0,"Maximum flying  ");
255
            LCD_printfxy(0,1,"Range:   %4im ", AbsoluteFlyingRange);
255
            LCD_printfxy(0,1,"Range:   %4im ", AbsoluteFlyingRange);
256
            LCD_printfxy(0,2,"Descend :%4im ", AutoDescendRange);
256
            LCD_printfxy(0,2,"Descend: %4im ", AutoDescendRange);
257
            LCD_printfxy(0,3,"Altitude:%4im ", AbsoluteFlyingAltitude);
257
            LCD_printfxy(0,3,"Altitude:%4im ", AbsoluteFlyingAltitude);
258
                        if(!AbsoluteFlyingRange) LCD_printfxy(9,1,"disabled");
258
                        if(!AbsoluteFlyingRange) LCD_printfxy(9,1,"disabled");
259
                        if(!AutoDescendRange)    LCD_printfxy(9,2,"disabled");
259
                        if(!AutoDescendRange)    LCD_printfxy(9,2,"disabled");
260
                        if(!AbsoluteFlyingAltitude) LCD_printfxy(9,3,"disabled");
260
                        if(!AbsoluteFlyingAltitude) LCD_printfxy(9,3,"disabled");
261
                        break;
261
                        break;
262
                case 8:
262
                case 8:
263
                        LCD_printfxy(0,0,"Home Position");
263
                        LCD_printfxy(0,0,"Home Position");
264
                        if(NaviData.HomePosition.Status == INVALID)
264
                        if(NaviData.HomePosition.Status == INVALID)
265
                        {
265
                        {
266
                                LCD_printfxy(0,1,"                     ");
266
                                LCD_printfxy(0,1,"                     ");
267
                                LCD_printfxy(0,2,"    Is not set.      ");
267
                                LCD_printfxy(0,2,"    Is not set.      ");
268
                                LCD_printfxy(0,3,"                     ");
268
                                LCD_printfxy(0,3,"                     ");
269
                        }
269
                        }
270
                        else
270
                        else
271
                        {
271
                        {
272
                                if(NaviData.HomePosition.Longitude < 0) sign = '-';
272
                                if(NaviData.HomePosition.Longitude < 0) sign = '-';
273
                                else sign = '+';
273
                                else sign = '+';
274
                                i1 = abs(NaviData.HomePosition.Longitude)/10000000L;
274
                                i1 = abs(NaviData.HomePosition.Longitude)/10000000L;
275
                                i2 = abs(NaviData.HomePosition.Longitude)%10000000L;
275
                                i2 = abs(NaviData.HomePosition.Longitude)%10000000L;
276
                                LCD_printfxy(0,1,"Lon:%c%03ld.%07ld deg",sign, i1, i2);
276
                                LCD_printfxy(0,1,"Lon:%c%03ld.%07ld deg",sign, i1, i2);
277
                                if(NaviData.HomePosition.Latitude < 0) sign = '-';
277
                                if(NaviData.HomePosition.Latitude < 0) sign = '-';
278
                                else sign = '+';
278
                                else sign = '+';
279
                                i1 = abs(NaviData.HomePosition.Latitude)/10000000L;
279
                                i1 = abs(NaviData.HomePosition.Latitude)/10000000L;
280
                                i2 = abs(NaviData.HomePosition.Latitude)%10000000L;
280
                                i2 = abs(NaviData.HomePosition.Latitude)%10000000L;
281
                                LCD_printfxy(0,2,"Lat:%c%03ld.%07ld deg",sign, i1, i2);
281
                                LCD_printfxy(0,2,"Lat:%c%03ld.%07ld deg",sign, i1, i2);
282
                                if(NaviData.HomePosition.Altitude < 0) sign = '-';
282
                                if(NaviData.HomePosition.Altitude < 0) sign = '-';
283
                                else sign = '+';
283
                                else sign = '+';
284
                                i1 = abs(NaviData.HomePosition.Altitude)/1000L;
284
                                i1 = abs(NaviData.HomePosition.Altitude)/1000L;
285
                                i2 = abs(NaviData.HomePosition.Altitude)%1000L;
285
                                i2 = abs(NaviData.HomePosition.Altitude)%1000L;
286
                                LCD_printfxy(0,3,"Alt:%c%04ld.%03ld m",sign, i1, i2);
286
                                LCD_printfxy(0,3,"Alt:%c%04ld.%03ld m",sign, i1, i2);
287
                        }
287
                        }
288
                        break;
288
                        break;
289
                case 9:
289
                case 9:
290
                        LCD_printfxy(0,0,"Target Position");
290
                        LCD_printfxy(0,0,"Target Position");
291
                        if(NaviData.TargetPosition.Status == INVALID)
291
                        if(NaviData.TargetPosition.Status == INVALID)
292
                        {
292
                        {
293
                                LCD_printfxy(0,1,"                     ");
293
                                LCD_printfxy(0,1,"                     ");
294
                                LCD_printfxy(0,2,"    Is not set.      ");
294
                                LCD_printfxy(0,2,"    Is not set.      ");
295
                                LCD_printfxy(0,3,"                     ");
295
                                LCD_printfxy(0,3,"                     ");
296
                        }
296
                        }
297
                        else
297
                        else
298
                        {
298
                        {
299
                                if(NaviData.TargetPosition.Longitude < 0) sign = '-';
299
                                if(NaviData.TargetPosition.Longitude < 0) sign = '-';
300
                                else sign = '+';
300
                                else sign = '+';
301
                                i1 = abs(NaviData.TargetPosition.Longitude)/10000000L;
301
                                i1 = abs(NaviData.TargetPosition.Longitude)/10000000L;
302
                                i2 = abs(NaviData.TargetPosition.Longitude)%10000000L;
302
                                i2 = abs(NaviData.TargetPosition.Longitude)%10000000L;
303
                                LCD_printfxy(0,1,"Lon:%c%03ld.%07ld deg",sign, i1, i2);
303
                                LCD_printfxy(0,1,"Lon:%c%03ld.%07ld deg",sign, i1, i2);
304
                                if(NaviData.TargetPosition.Latitude < 0) sign = '-';
304
                                if(NaviData.TargetPosition.Latitude < 0) sign = '-';
305
                                else sign = '+';
305
                                else sign = '+';
306
                                i1 = abs(NaviData.TargetPosition.Latitude)/10000000L;
306
                                i1 = abs(NaviData.TargetPosition.Latitude)/10000000L;
307
                                i2 = abs(NaviData.TargetPosition.Latitude)%10000000L;
307
                                i2 = abs(NaviData.TargetPosition.Latitude)%10000000L;
308
                                LCD_printfxy(0,2,"Lat:%c%03ld.%07ld deg",sign, i1, i2);
308
                                LCD_printfxy(0,2,"Lat:%c%03ld.%07ld deg",sign, i1, i2);
309
                                if(NaviData.HomePosition.Altitude < 0) sign = '-';
309
                                if(NaviData.HomePosition.Altitude < 0) sign = '-';
310
                                else sign = '+';
310
                                else sign = '+';
311
                                i1 = abs(NaviData.TargetPosition.Altitude)/1000L;
311
                                i1 = abs(NaviData.TargetPosition.Altitude)/1000L;
312
                                i2 = abs(NaviData.TargetPosition.Altitude)%1000L;
312
                                i2 = abs(NaviData.TargetPosition.Altitude)%1000L;
313
                                LCD_printfxy(0,3,"Alt:%c%04ld.%03ld m",sign, i1, i2);
313
                                LCD_printfxy(0,3,"Alt:%c%04ld.%03ld m",sign, i1, i2);
314
                        }
314
                        }
315
                        break;
315
                        break;
316
                case 10: // RC stick controls from FC
316
                case 10: // RC stick controls from FC
317
                        LCD_printfxy(0,0,"RC-Sticks" );
317
                        LCD_printfxy(0,0,"RC-Sticks" );
318
            LCD_printfxy(0,1,"Ni:%4i  Ro:%4i ",FC.StickNick, FC.StickRoll);
318
            LCD_printfxy(0,1,"Ni:%4i  Ro:%4i ",FC.StickNick, FC.StickRoll);
319
            LCD_printfxy(0,2,"Gs:%4i  Ya:%4i ",FC.StickGas, FC.StickYaw);
319
            LCD_printfxy(0,2,"Gs:%4i  Ya:%4i ",FC.StickGas, FC.StickYaw);
320
                        break;
320
                        break;
321
                case 11: // RC poti controls from FC
321
                case 11: // RC poti controls from FC
322
                        LCD_printfxy(0,0,"RC-Potis 1" );
322
                        LCD_printfxy(0,0,"RC-Potis 1" );
323
            LCD_printfxy(0,1,"Po1:%3i  Po2:%3i ",FC.Poti[0], FC.Poti[1]);
323
            LCD_printfxy(0,1,"Po1:%3i  Po2:%3i ",FC.Poti[0], FC.Poti[1]);
324
            LCD_printfxy(0,2,"Po3:%3i  Po4:%3i ",FC.Poti[2], FC.Poti[3]);
324
            LCD_printfxy(0,2,"Po3:%3i  Po4:%3i ",FC.Poti[2], FC.Poti[3]);
325
                        break;
325
                        break;
326
                case 12: // RC poti controls from FC
326
                case 12: // RC poti controls from FC
327
                        LCD_printfxy(0,0,"RC-Potis 2" );
327
                        LCD_printfxy(0,0,"RC-Potis 2" );
328
            LCD_printfxy(0,1,"Po5:%3i  Po6:%3i ",FC.Poti[4], FC.Poti[5]);
328
            LCD_printfxy(0,1,"Po5:%3i  Po6:%3i ",FC.Poti[4], FC.Poti[5]);
329
            LCD_printfxy(0,2,"Po7:%3i  Po8:%3i ",FC.Poti[6], FC.Poti[7]);
329
            LCD_printfxy(0,2,"Po7:%3i  Po8:%3i ",FC.Poti[6], FC.Poti[7]);
330
                        break;
330
                        break;
331
                case 13: // attitude from FC
331
                case 13: // attitude from FC
332
                        if(FromFlightCtrl.AngleNick < 0) sign = '-';
332
                        if(FromFlightCtrl.AngleNick < 0) sign = '-';
333
                        else sign = '+';
333
                        else sign = '+';
334
                        i1 = abs(FromFlightCtrl.AngleNick)/10;
334
                        i1 = abs(FromFlightCtrl.AngleNick)/10;
335
                        i2 = abs(FromFlightCtrl.AngleNick)%10;
335
                        i2 = abs(FromFlightCtrl.AngleNick)%10;
336
                        LCD_printfxy(0,0,"GyroNick:%c%03ld.%01ld", sign, i1, i2);
336
                        LCD_printfxy(0,0,"GyroNick:%c%03ld.%01ld", sign, i1, i2);
337
                        if(FromFlightCtrl.AngleRoll < 0) sign = '-';
337
                        if(FromFlightCtrl.AngleRoll < 0) sign = '-';
338
                        else sign = '+';
338
                        else sign = '+';
339
                        i1 = abs(FromFlightCtrl.AngleRoll)/10;
339
                        i1 = abs(FromFlightCtrl.AngleRoll)/10;
340
                        i2 = abs(FromFlightCtrl.AngleRoll)%10;
340
                        i2 = abs(FromFlightCtrl.AngleRoll)%10;
341
            LCD_printfxy(0,1,"GyroRoll:%c%03ld.%01ld", sign, i1, i2);
341
            LCD_printfxy(0,1,"GyroRoll:%c%03ld.%01ld", sign, i1, i2);
342
                        if(FromFlightCtrl.AccNick < 0) sign = '-';
342
                        if(FromFlightCtrl.AccNick < 0) sign = '-';
343
                        else sign = '+';
343
                        else sign = '+';
344
                        i1 = abs(FromFlightCtrl.AccNick)/10;
344
                        i1 = abs(FromFlightCtrl.AccNick)/10;
345
                        i2 = abs(FromFlightCtrl.AccNick)%10;
345
                        i2 = abs(FromFlightCtrl.AccNick)%10;
346
                        LCD_printfxy(0,2," AccNick:%c%03ld.%01ld", sign, i1, i2);
346
                        LCD_printfxy(0,2," AccNick:%c%03ld.%01ld", sign, i1, i2);
347
                        if(FromFlightCtrl.AccRoll < 0) sign = '-';
347
                        if(FromFlightCtrl.AccRoll < 0) sign = '-';
348
                        else sign = '+';
348
                        else sign = '+';
349
                        i1 = abs(FromFlightCtrl.AccRoll)/10;
349
                        i1 = abs(FromFlightCtrl.AccRoll)/10;
350
                        i2 = abs(FromFlightCtrl.AccRoll)%10;
350
                        i2 = abs(FromFlightCtrl.AccRoll)%10;
351
            LCD_printfxy(0,3," AccRoll:%c%03ld.%01ld", sign, i1, i2);
351
            LCD_printfxy(0,3," AccRoll:%c%03ld.%01ld", sign, i1, i2);
352
                        break;
352
                        break;
353
                case 14: // gyros from FC
353
                case 14: // gyros from FC
354
                        LCD_printfxy(0,0,"GyroNick:  %4i", FromFlightCtrl.GyroNick);
354
                        LCD_printfxy(0,0,"GyroNick:  %4i", FromFlightCtrl.GyroNick);
355
            LCD_printfxy(0,1,"GyroRoll:  %4i", FromFlightCtrl.GyroRoll);
355
            LCD_printfxy(0,1,"GyroRoll:  %4i", FromFlightCtrl.GyroRoll);
356
                        LCD_printfxy(0,2,"GyroYaw:   %4i", FromFlightCtrl.GyroYaw);
356
                        LCD_printfxy(0,2,"GyroYaw:   %4i", FromFlightCtrl.GyroYaw);
357
                        break;
357
                        break;
358
                case 15: // Remote Control Level from FC
358
                case 15: // Remote Control Level from FC
359
            LCD_printfxy(0,0,"RC-Level:    %3i", FC.RC_Quality);
359
            LCD_printfxy(0,0,"RC-Level:    %3i", FC.RC_Quality);
360
                        LCD_printfxy(0,1,"Ubat:        %2i.%1i V", FC.BAT_Voltage/10, FC.BAT_Voltage%10);
360
                        LCD_printfxy(0,1,"Ubat:        %2i.%1i V", FC.BAT_Voltage/10, FC.BAT_Voltage%10);
361
                        LCD_printfxy(0,2,"CompHeading: %3i", Compass_Heading);
361
                        LCD_printfxy(0,2,"CompHeading: %3i", Compass_Heading);
362
                        if(GeoMagDec < 0) sign = '-';
362
                        if(GeoMagDec < 0) sign = '-';
363
                        else sign = '+';
363
                        else sign = '+';
364
                        LCD_printfxy(0,3,"GeoMagDec:  %c%i.%1i", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
364
                        LCD_printfxy(0,3,"GeoMagDec:  %c%i.%1i", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
365
            break;
365
            break;
366
                case 16: // User Parameter
366
                case 16: // User Parameter
367
                        LCD_printfxy(0,0,"UP1:%3i  UP2:%3i",Parameter.User1,Parameter.User2);
367
                        LCD_printfxy(0,0,"UP1:%3i  UP2:%3i",Parameter.User1,Parameter.User2);
368
                        LCD_printfxy(0,1,"UP3:%3i  UP4:%3i",Parameter.User3,Parameter.User4);
368
                        LCD_printfxy(0,1,"UP3:%3i  UP4:%3i",Parameter.User3,Parameter.User4);
369
                        LCD_printfxy(0,2,"UP5:%3i  UP6:%3i",Parameter.User5,Parameter.User6);
369
                        LCD_printfxy(0,2,"UP5:%3i  UP6:%3i",Parameter.User5,Parameter.User6);
370
                        LCD_printfxy(0,3,"UP7:%3i  UP8:%3i",Parameter.User7,Parameter.User8);
370
                        LCD_printfxy(0,3,"UP7:%3i  UP8:%3i",Parameter.User7,Parameter.User8);
371
                        break;
371
                        break;
372
                case 17: // magnetic field
372
                case 17: // magnetic field
373
                        if(Compass_CalState)
373
                        if(Compass_CalState)
374
                        {
374
                        {
375
                                LCD_printfxy(0,0,"Calibration:");
375
                                LCD_printfxy(0,0,"Calibration:");
376
                                LCD_printfxy(0,1,"Step %d/", Compass_CalState);
376
                                LCD_printfxy(0,1,"Step %d/", Compass_CalState);
377
                                LCD_printfxy(0,2,"X %4i Y %4i Z %4i",MagVector.X,MagVector.Y,MagVector.Z);
377
                                LCD_printfxy(0,2,"X %4i Y %4i Z %4i",MagVector.X,MagVector.Y,MagVector.Z);
378
                                LCD_printfxy(9,3,"(ESC)(NEXT)");
378
                                LCD_printfxy(9,3,"(ESC)(NEXT)");
379
                                switch(Compass_CalState)
379
                                switch(Compass_CalState)
380
                                {
380
                                {
381
                                        case 1:
381
                                        case 1:
382
                                        case 3:
382
                                        case 3:
383
                                                LCD_printfxy(7,1,"pause");
383
                                                LCD_printfxy(7,1,"pause");
384
                                                break;
384
                                                break;
385
 
385
 
386
                                        case 2:
386
                                        case 2:
387
                                                LCD_printfxy(7,1,"horizontal");
387
                                                LCD_printfxy(7,1,"horizontal");
388
                                                break;
388
                                                break;
389
 
389
 
390
                                        case 4:
390
                                        case 4:
391
                                                LCD_printfxy(7,1,"vertical");
391
                                                LCD_printfxy(7,1,"vertical");
392
                                                break;
392
                                                break;
393
 
393
 
394
                                        case 5:
394
                                        case 5:
395
                                                LCD_printfxy(7,1,"data saved");
395
                                                LCD_printfxy(7,1,"data saved");
396
                                                LCD_printfxy(8,3,"      (END) ");
396
                                                LCD_printfxy(8,3,"      (END) ");
397
                                                break;
397
                                                break;
398
                                       
398
                                       
399
                                        default:
399
                                        default:
400
                                                break;
400
                                                break;
401
                                }
401
                                }
402
                        }
402
                        }
403
                        else
403
                        else
404
                        {
404
                        {
405
                                if(GeoMagDec < 0) sign = '-';
405
                                if(GeoMagDec < 0) sign = '-';
406
                                else sign = '+';
406
                                else sign = '+';
407
                                LCD_printfxy(0,0,"Magnetic Field");
407
                                LCD_printfxy(0,0,"Magnetic Field");
408
                                LCD_printfxy(0,1,"X:%5i",MagVector.X);
408
                                LCD_printfxy(0,1,"X:%5i",MagVector.X);
409
                                LCD_printfxy(0,2,"Y:%5i",MagVector.Y);
409
                                LCD_printfxy(0,2,"Y:%5i",MagVector.Y);
410
                                LCD_printfxy(0,3,"Z:%5i",MagVector.Z);
410
                                LCD_printfxy(0,3,"Z:%5i",MagVector.Z);
411
                                LCD_printfxy(8,1,"Field:%3i",EarthMagneticField/5);
411
                                LCD_printfxy(8,1,"Field:%3i",EarthMagneticField/5);
412
//                              LCD_printfxy(8,2,"Dec:%c%i.%1i", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
412
//                              LCD_printfxy(8,2,"Dec:%c%i.%1i", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
413
//                              LCD_printfxy(8,3,"Inc:%2i", EarthMagneticInclination);
413
//                              LCD_printfxy(8,3,"Inc:%2i", EarthMagneticInclination);
414
                                LCD_printfxy(15,3,"(CAL)");
414
                                LCD_printfxy(15,3,"(CAL)");
415
                        }
415
                        }
416
                        if(Keys & KEY4) //  next step
416
                        if(Keys & KEY4) //  next step
417
                        {
417
                        {
418
                                if(Compass_CalState <5) Compass_SetCalState(Compass_CalState+1);
418
                                if(Compass_CalState <5) Compass_SetCalState(Compass_CalState+1);
419
                                else Compass_SetCalState(0);
419
                                else Compass_SetCalState(0);
420
                        }
420
                        }
421
                        if(Keys & KEY3)Compass_SetCalState(0);  // cancel
421
                        if(Keys & KEY3)Compass_SetCalState(0);  // cancel
422
                        break;
422
                        break;
423
                case 18:
423
                case 18:
424
                        if(GeoMagDec < 0) sign = '-';
424
                        if(GeoMagDec < 0) sign = '-';
425
                        else sign = '+';
425
                        else sign = '+';
426
                                LCD_printfxy(0,0,"Magnetic Field");
426
                                LCD_printfxy(0,0,"Magnetic Field");
427
                                LCD_printfxy(0,1,"Field:%3i (Percent)",EarthMagneticField/5);
427
                                LCD_printfxy(0,1,"Field:%3i (Percent)",EarthMagneticField/5);
428
                                LCD_printfxy(0,2,"Declination:%c%i.%1i ", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
428
                                LCD_printfxy(0,2,"Declination:%c%i.%1i ", sign, abs(GeoMagDec)/10,abs(GeoMagDec)%10);
429
                                LCD_printfxy(0,3,"Inclination:%2i (%2i)", EarthMagneticInclination,     EarthMagneticInclinationTheoretic);
429
                                LCD_printfxy(0,3,"Inclination:%2i (%2i)", EarthMagneticInclination,     EarthMagneticInclinationTheoretic);
430
                        break;
430
                        break;
431
                default:
431
                default:
432
                        //MaxMenuItem = MenuItem - 1;
432
                        //MaxMenuItem = MenuItem - 1;
433
                        MenuItem = 0;
433
                        MenuItem = 0;
434
                        break;
434
                        break;
435
    }
435
    }
436
}
436
}
437
 
437