Subversion Repositories FlightCtrl

Rev

Rev 2041 | Go to most recent revision | Only display areas with differences | Regard 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) {
98
        if (remoteKeys & KEY1) {
98
  if (remoteKeys & KEY1) {
99
                if (menuItem)
99
    if (menuItem)
100
                        menuItem--;
100
      menuItem--;
101
                else
101
    else
102
                        menuItem = maxMenuItem;
102
      menuItem = maxMenuItem;
103
        }
103
  }
104
 
104
 
105
        if (remoteKeys & KEY2) {
105
  if (remoteKeys & KEY2) {
106
                if (menuItem == maxMenuItem)
106
    if (menuItem == maxMenuItem)
107
                        menuItem = 0;
107
      menuItem = 0;
108
                else
108
    else
109
                        menuItem++;
109
      menuItem++;
110
        }
110
  }
111
        if ((remoteKeys & KEY1) && (remoteKeys & KEY2))
111
  if ((remoteKeys & KEY1) && (remoteKeys & KEY2))
112
                menuItem = 0;
112
    menuItem = 0;
113
 
113
 
114
        LCD_clear();
114
  LCD_clear();
115
 
115
 
116
        if (menuItem > maxMenuItem)
116
  if (menuItem > maxMenuItem)
117
                menuItem = maxMenuItem;
117
    menuItem = maxMenuItem;
118
        // print menu item number in the upper right corner
118
  // print menu item number in the upper right corner
119
        if (menuItem < 10) {
119
  if (menuItem < 10) {
120
                LCD_printfxy(17,0,"[%i]", menuItem);
120
    LCD_printfxy(17, 0, "[%i]", menuItem);
121
        } else {
121
  } else {
122
                LCD_printfxy(16,0,"[%i]", menuItem);
122
    LCD_printfxy(16, 0, "[%i]", menuItem);
123
        }
123
  }
124
 
124
 
125
        switch (menuItem) {
125
  switch (menuItem) {
126
        case 0:// Version Info Menu Item
126
  case 0: // Version Info Menu Item
127
                LCD_printfxy(0,0,"+ MikroKopter +")
127
    LCD_printfxy(0, 0, "+ MikroKopter +");
-
 
128
    LCD_printfxy(
-
 
129
        0,
128
                ;
130
        1,
-
 
131
        "HW:V%d.%d SW:%d.%d%c",
129
                LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",boardRelease/10,boardRelease%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a')
132
        boardRelease/10, boardRelease%10, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a');
130
                ;
-
 
131
                LCD_printfxy(0,2,"Setting: %d %s", getActiveParamSet(), mixerMatrix.name)
133
    LCD_printfxy(0, 2, "Setting: %d %s", getActiveParamSet(), mixerMatrix.name);
132
                ;
-
 
133
                if (I2CTimeout < 6) {
134
    if (I2CTimeout < 6) {
134
                        LCD_printfxy(0,3,"I2C Error!!!");
135
      LCD_printfxy(0, 3, "I2C Error!!!");
135
                } else if (missingMotor) {
136
    } else if (missingMotor) {
136
                        LCD_printfxy(0,3,"Missing BL-Ctrl:%d", missingMotor);
137
      LCD_printfxy(0, 3, "Missing BL-Ctrl:%d", missingMotor);
-
 
138
    } else
137
                } else LCD_printfxy(0,3,"(c) Holger Buss");
139
      LCD_printfxy(0, 3, "(c) Holger Buss");
138
                break;
140
    break;
139
                /*
141
    /*
140
                 case 1:// Height Control Menu Item
142
     case 1:// Height Control Menu Item
141
                 if(staticParams.GlobalConfig & CFG_HEIGHT_CONTROL) {
143
     if(staticParams.GlobalConfig & CFG_HEIGHT_CONTROL) {
142
                 LCD_printfxy(0,0,"Height:    %5i",ReadingHeight);
144
     LCD_printfxy(0,0,"Height:    %5i",ReadingHeight);
143
                 LCD_printfxy(0,1,"Set Point: %5i",SetPointHeight);
145
     LCD_printfxy(0,1,"Set Point: %5i",SetPointHeight);
144
                 LCD_printfxy(0,2,"Air Press.:%5i",0);
146
     LCD_printfxy(0,2,"Air Press.:%5i",0);
145
                 LCD_printfxy(0,3,"Offset    :%5i",0);
147
     LCD_printfxy(0,3,"Offset    :%5i",0);
146
                 }
148
     }
147
                 else
149
     else
148
                 {
150
     {
149
                 LCD_printfxy(0,1,"No ");
151
     LCD_printfxy(0,1,"No ");
150
                 LCD_printfxy(0,2,"Height Control");
152
     LCD_printfxy(0,2,"Height Control");
151
                 }
153
     }
152
                 break;
154
     break;
153
                 */
155
     */
154
        case 2:// Attitude Menu Item
156
  case 2: // Attitude Menu Item
155
                LCD_printfxy(0,0,"Attitude");
157
    LCD_printfxy(0, 0, "Attitude");
-
 
158
    LCD_printfxy(0, 1, "Nick:      %5i",
156
                LCD_printfxy(0,1,"Nick:      %5i", angle[PITCH] / GYRO_DEG_FACTOR_PITCHROLL);
159
        attitude[PITCH] / GYRO_DEG_FACTOR_PITCHROLL);
-
 
160
    LCD_printfxy(0, 2, "Roll:      %5i",
157
                LCD_printfxy(0,2,"Roll:      %5i", angle[ROLL ] / GYRO_DEG_FACTOR_PITCHROLL);
161
        attitude[ROLL ] / GYRO_DEG_FACTOR_PITCHROLL);
158
                LCD_printfxy(0,3,"Heading(M):%5i", magneticHeading);
162
    LCD_printfxy(0, 3, "Heading(M):%5i", magneticHeading);
159
                break;
163
    break;
160
        case 3:// Remote Control Channel Menu Item
164
  case 3: // Remote Control Channel Menu Item
161
                LCD_printfxy(0,0,"C1:%4i  C2:%4i ",PPM_in[1],PPM_in[2]);
165
    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]);
166
    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]);
167
    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]);
168
    LCD_printfxy(0, 3, "C7:%4i  C8:%4i ", PPM_in[7], PPM_in[8]);
165
                break;
169
    break;
166
        case 4:// Remote Control Mapping Menu Item
170
  case 4: // Remote Control Mapping Menu Item
-
 
171
    LCD_printfxy(
-
 
172
        0,
-
 
173
        0,
-
 
174
        "Ni:%4i  Ro:%4i ",
167
                LCD_printfxy(0,0,"Ni:%4i  Ro:%4i ",PPM_in[channelMap.channels[CH_PITCH]],   PPM_in[channelMap.channels[CH_ROLL]]);
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 ",
168
                LCD_printfxy(0,1,"Gs:%4i  Ya:%4i ",PPM_in[channelMap.channels[CH_THROTTLE]],PPM_in[channelMap.channels[CH_YAW]]);
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 ",
169
                LCD_printfxy(0,2,"P1:%4i  P2:%4i ",PPM_in[channelMap.channels[CH_POTS]],    PPM_in[channelMap.channels[CH_POTS+1]]);
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 ",
170
                LCD_printfxy(0,3,"P3:%4i  P4:%4i ",PPM_in[channelMap.channels[CH_POTS+2]],  PPM_in[channelMap.channels[CH_POTS+3]]);
190
        PPM_in[channelMap.channels[CH_POTS+2]], PPM_in[channelMap.channels[CH_POTS+3]]);
171
                break;
191
    break;
172
                /*
192
    /*
173
                 case 5:// Gyro Sensor Menu Item
193
     case 5:// Gyro Sensor Menu Item
174
                 LCD_printfxy(0,0,"Gyro - Sensor");
194
     LCD_printfxy(0,0,"Gyro - Sensor");
175
                 switch(BoardRelease) {
195
     switch(BoardRelease) {
176
                 case 10:
196
     case 10:
177
                 LCD_printfxy(0,1,"Nick %4i (%3i.%i)", AdValueGyroNick - HiResNickOffset / HIRES_GYRO_AMPLIFY, HiResNickOffset / HIRES_GYRO_AMPLIFY, HiResNickOffset % HIRES_GYRO_AMPLIFY);
197
     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);
198
     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);
199
     LCD_printfxy(0,3,"Yaw  %4i (%3i)", AdValueGyroYaw , YawOffset);
180
                 break;
200
     break;
181
                 case 11:
201
     case 11:
182
                 case 12:
202
     case 12:
183
                 case 20: // divice Offests by 2 becuse 2 samples are added in adc isr
203
     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)
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)
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)
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)
186
                 LCD_printfxy(0,3,"Yaw  %4i (%3i)",YawOffset  - AdValueGyroYaw , YawOffset/2);
206
     LCD_printfxy(0,3,"Yaw  %4i (%3i)",YawOffset  - AdValueGyroYaw , YawOffset/2);
187
                 break;
207
     break;
188
 
208
 
189
                 case 13:
209
     case 13:
190
                 default: // divice Offests by 2 becuse 2 samples are added in adc isr
210
     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)
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)
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)
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)
193
                 LCD_printfxy(0,3,"Yaw  %4i (%3i)(%3i)",YawOffset  - AdValueGyroYaw , YawOffset/2, 0);
213
     LCD_printfxy(0,3,"Yaw  %4i (%3i)(%3i)",YawOffset  - AdValueGyroYaw , YawOffset/2, 0);
194
                 break;
214
     break;
195
                 }
215
     }
196
                 break;
216
     break;
197
                 case 6:// Acceleration Sensor Menu Item
217
     case 6:// Acceleration Sensor Menu Item
198
                 LCD_printfxy(0,0,"ACC - Sensor");
218
     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
219
     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
220
     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);
221
     LCD_printfxy(0,3,"Height %4i (%3i)",0,0);
202
                 break;
222
     break;
203
                 */
223
     */
204
        case 7:// Battery Voltage / Remote Control Level
224
  case 7: // Battery Voltage / Remote Control Level
205
                LCD_printfxy(0,1,"Voltage:  %3i.%1iV",UBat/10, UBat%10);
225
    LCD_printfxy(0, 1, "Voltage:  %3i.%1iV", UBat/10, UBat%10);
206
                LCD_printfxy(0,2,"RC-Level: %5i",RCQuality);
226
    LCD_printfxy(0, 2, "RC-Level: %5i", RCQuality);
207
                break;
227
    break;
208
        case 8:// Compass Menu Item
228
  case 8: // Compass Menu Item
209
                LCD_printfxy(0,0,"Compass       ");
229
    LCD_printfxy(0, 0, "Compass       ");
210
                LCD_printfxy(0,1,"Course:    %5i", compassCourse);
230
    LCD_printfxy(0, 0, "TODO: Impl.   ");
211
                LCD_printfxy(0,2,"Heading:   %5i", magneticHeading);
-
 
212
                LCD_printfxy(0,3,"OffCourse: %5i", ((540 + magneticHeading - compassCourse) % 360) - 180);
-
 
213
                break;
231
    break;
214
        case 9:// Poti Menu Item
232
  case 9: // Poti Menu Item
215
                LCD_printfxy(0,0,"Po1: %3i Po5: %3i" ,variables[0], variables[4]); //PPM24-Extesion
233
    LCD_printfxy(0, 0, "Variables     ");
216
                LCD_printfxy(0,1,"Po2: %3i Po6: %3i" ,variables[1], variables[5]); //PPM24-Extesion
234
    LCD_printfxy(0, 0, "TODO: Impl.   ");
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;
235
    break;
220
                /*
-
 
221
                 case 10:// Servo Menu Item
236
  case 10: // Servo Menu Item
222
                 LCD_printfxy(0,0,"Servo  " );
237
    LCD_printfxy(0, 0, "Servos        ");
223
                 LCD_printfxy(0,1,"Setpoint  %3i",dynamicParams.ServoNickControl);
-
 
224
                 LCD_printfxy(0,2,"Position: %3i",ServoNickValue);
238
    LCD_printfxy(0, 0, "TODO: Impl.   ");
225
                 LCD_printfxy(0,3,"Range:%3i-%3i",staticParams.ServoNickMin, staticParams.ServoNickMax);
-
 
226
                 break;
239
    break;
227
                 */
-
 
228
        case 11://Extern Control
240
  case 11: //Extern Control
229
                LCD_printfxy(0,0,"ExternControl  " );
241
    LCD_printfxy(0, 0, "ExternControl  ");
-
 
242
    LCD_printfxy(0, 1, "Ni:%4i  Ro:%4i ",
230
                LCD_printfxy(0,1,"Ni:%4i  Ro:%4i ", externalControl.pitch, externalControl.roll);
243
        externalControl.pitch, externalControl.roll);
-
 
244
    LCD_printfxy(0, 2, "Gs:%4i  Ya:%4i ",
231
                LCD_printfxy(0,2,"Gs:%4i  Ya:%4i ", externalControl.throttle, externalControl.yaw);
245
        externalControl.throttle, externalControl.yaw);
-
 
246
    LCD_printfxy(0, 3, "Hi:%4i  Cf:%4i ",
232
                LCD_printfxy(0,3,"Hi:%4i  Cf:%4i ", externalControl.height, externalControl.config);
247
        externalControl.height, externalControl.config);
233
                break;
248
    break;
234
 
249
 
235
        case 12://BL Communication errors
250
  case 12: //BL Communication errors
236
                LCD_printfxy(0,0,"BL-Ctrl Errors " );
251
    LCD_printfxy(0, 0, "BL-Ctrl Errors ");
-
 
252
    LCD_printfxy(0, 1, " %3d  %3d  %3d  %3d ",
237
                LCD_printfxy(0,1," %3d  %3d  %3d  %3d ",motor[0].error,motor[1].error,motor[2].error,motor[3].error);
253
        motor[0].error, motor[1].error, motor[2].error, motor[3].error);
-
 
254
    LCD_printfxy(0, 2, " %3d  %3d  %3d  %3d ",
238
                LCD_printfxy(0,2," %3d  %3d  %3d  %3d ",motor[4].error,motor[5].error,motor[6].error,motor[7].error);
255
        motor[4].error, motor[5].error, motor[6].error, motor[7].error);
-
 
256
    LCD_printfxy(0, 3, " %3d  %3d  %3d  %3d ",
239
                LCD_printfxy(0,3," %3d  %3d  %3d  %3d ",motor[8].error,motor[9].error,motor[10].error,motor[11].error);
257
        motor[8].error, motor[9].error, motor[10].error, motor[11].error);
240
                break;
258
    break;
241
 
259
 
242
        case 13://BL Overview
260
  case 13: //BL Overview
243
                LCD_printfxy(0,0,"BL-Ctrl found " );
261
    LCD_printfxy(0, 0, "BL-Ctrl found ");
-
 
262
    LCD_printfxy(
-
 
263
        0,
-
 
264
        1,
-
 
265
        " %c   %c   %c   %c ",
244
                LCD_printfxy(0,1," %c   %c   %c   %c ",motor[0].present + '-',motor[1].present + '-',motor[2].present + '-',motor[3].present + '-');
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 ",
245
                LCD_printfxy(0,2," %c   %c   %c   %c ",motor[4].present + '-',motor[5].present + '-',motor[6].present + '-',motor[7].present + '-');
271
        motor[4].present + '-', motor[5].present + '-', motor[6].present + '-', motor[7].present + '-');
246
                LCD_printfxy(0,3," %c   -   -   - ",motor[8].present + '-');
272
    LCD_printfxy(0, 3, " %c   -   -   - ", motor[8].present + '-');
247
                if (motor[9].present)
273
    if (motor[9].present)
248
                        LCD_printfxy(4,3,"10");
274
      LCD_printfxy(4, 3, "10");
249
                if (motor[10].present)
275
    if (motor[10].present)
250
                        LCD_printfxy(8,3,"11");
276
      LCD_printfxy(8, 3, "11");
251
                if (motor[11].present)
277
    if (motor[11].present)
252
                        LCD_printfxy(12,3,"12");
278
      LCD_printfxy(12, 3, "12");
253
                break;
279
    break;
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