Subversion Repositories FlightCtrl

Rev

Rev 839 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 839 Rev 966
1
/*
1
/*
2
Copyright 2008, by Michael Walter
2
Copyright 2008, by Michael Walter
3
 
3
 
4
All functions written by Michael Walter are free software and can be redistributed and/or modified under the terms of the GNU Lesser
4
All functions written by Michael Walter are free software and can be redistributed and/or modified under the terms of the GNU Lesser
5
General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but
5
General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but
6
WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
6
WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public
7
See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public
8
License along with this program. If not, see <http://www.gnu.org/licenses/>.
8
License along with this program. If not, see <http://www.gnu.org/licenses/>.
9
 
9
 
10
Please note: The software is based on the framework provided by H. Buss and I. Busker in their Mikrokopter projekt. All functions that
10
Please note: The software is based on the framework provided by H. Buss and I. Busker in their Mikrokopter projekt. All functions that
11
are not written by Michael Walter are under the license by H. Buss and I. Busker (license_buss.txt) published by www.mikrokopter.de
11
are not written by Michael Walter are under the license by H. Buss and I. Busker (license_buss.txt) published by www.mikrokopter.de
12
unless it is stated otherwise.
12
unless it is stated otherwise.
13
*/
13
*/
14
 
14
 
15
#include "main.h"
15
#include "main.h"
16
#include "kafi.h"
16
#include "kafi.h"
-
 
17
#include "mymath.h"
-
 
18
 
-
 
19
#define sin45 -0.707106
-
 
20
#define cos45 0.707106
17
 
21
 
18
extern void UART2Print(void);
22
extern void UART2Print(void);
19
void InitOSD(void);
23
void InitOSD(void);
20
void SendOSD(void);
24
void SendOSD(void);
21
 
25
 
22
extern  gpsInfo_t       actualPos;                      // measured position (last gps record)
26
extern  gpsInfo_t actualPos;// measured position (last gps record)
23
extern  gpsInfo_t       targetPos;                      // measured position (last gps record)
27
extern  gpsInfo_t targetPos;// measured position (last gps record)
24
 
28
 
25
extern signed int GPS_Nick;
29
extern signed int GPS_Nick;
26
extern signed int GPS_Roll;
30
extern signed int GPS_Roll;
27
 
31
 
28
extern int CurrentAltitude,  LastAltitude, targetPosValid, RCQuality;
32
extern int CurrentAltitude,  LastAltitude, targetPosValid, RCQuality;
29
extern int nick_gain_p, nick_gain_d, roll_gain_p, roll_gain_d; 
33
extern int nick_gain_p, nick_gain_d, roll_gain_p, roll_gain_d;
30
extern int Override, TargetGier, DeltaAltitude, Theta45, Phi45;
34
extern int Override, TargetGier, DeltaAltitude, Theta45, Phi45;
31
extern  f32_t sinPhi_P,  cosPhi_P, sinTheta_P, cosTheta_P;
35
extern f32_t sinPhi_P,  cosPhi_P, sinTheta_P, cosTheta_P;
32
extern unsigned long maxDistance;
36
extern unsigned long maxDistance;
-
 
37
 
-
 
38
int Theta45;
-
 
39
int Phi45;
33
 
40
 
34
unsigned char UART2PrintAbgeschlossen = 1;
41
unsigned char UART2PrintAbgeschlossen = 1;
35
void UART2Print(void);
42
void UART2Print(void);
36
 
43
 
37
char DisplayBuff[80] = "";
44
char DisplayBuff[80] = "";
38
unsigned char DispPtr = 0;
45
unsigned char DispPtr = 0;
39
 
46
 
40
char OSDBuff[80] = "";
47
char OSDBuff[80] = "";
41
unsigned char OSDPtr = 0;
48
unsigned char OSDPtr = 0;
42
 
49
 
43
 
50
 
44
#define OSD_printf(format, args...)  { OSDPtr = 0;  _printf_P(OUT_OSD,PSTR(format) , ## args);UART2Print();}
51
#define OSD_printf(format, args...)  { OSDPtr = 0;  _printf_P(OUT_OSD,PSTR(format) , ## args);UART2Print();}
45
#define OSD_printf_(format, args...)  { _printf_P(OUT_OSD,PSTR(format) , ## args);}
52
#define OSD_printf_(format, args...)  { _printf_P(OUT_OSD,PSTR(format) , ## args);}
46
 
53
 
47
 
54
 
48
/* For OSD_printf to work, Putchar() has to be extendet as follows.
55
/* For OSD_printf to work, Putchar() has to be extendet as follows.
49
char Putchar(char zeichen)
56
char Putchar(char zeichen)
50
{
57
{
51
  if(PrintZiel == OUT_LCD)
58
if(PrintZiel == OUT_LCD)
52
  {
59
{
53
        DisplayBuff[DispPtr++] = zeichen; return(1);
60
DisplayBuff[DispPtr++] = zeichen; return(1);
54
  }
61
}
55
  else if (PrintZiel == OUT_OSD)
62
else if (PrintZiel == OUT_OSD)
56
  {
63
{
57
        OSDBuff[OSDPtr++] = zeichen; return(1);
64
OSDBuff[OSDPtr++] = zeichen; return(1);
58
  }
65
}
59
  else
66
else
60
  {
67
{
61
        return(uart_putchar(zeichen));
68
return(uart_putchar(zeichen));
62
  }
69
}
63
}
70
}
64
*/
71
*/
65
 
72
 
66
 
73
 
67
/* ****************************************************************************
74
/* ****************************************************************************
68
  Functionname:     OsdClear                      */ /*!
75
  Functionname:     OsdClear                      */ /*!
69
  Description:        
76
  Description:        
70
 
77
 
71
  @param[in]        
78
  @param[in]        
72
 
79
 
73
  @return           void
80
  @return           void
74
  @pre              -
81
  @pre              -
75
  @post             -
82
  @post             -
76
  @author           Michael Walter
83
  @author           Michael Walter
77
**************************************************************************** */
84
**************************************************************************** */
78
void OsdClear(void)
85
void OsdClear(void)
79
{
86
{
80
        unsigned char i;
87
  unsigned char i;
81
        for(i=0;i<80;i++) OSDBuff[i] = ' ';
88
  for(i=0;i<80;i++) OSDBuff[i] = ' ';
82
}
89
}
83
 
90
 
84
/* ****************************************************************************
91
/* ****************************************************************************
85
  Functionname:     LcdClear                      */ /*!
92
  Functionname:     LcdClear                      */ /*!
86
  Description:        
93
  Description:        
87
 
94
 
88
  @param[in]        
95
  @param[in]        
89
 
96
 
90
  @return           void
97
  @return           void
91
  @pre              -
98
  @pre              -
92
  @post             -
99
  @post             -
93
  @author          
100
  @author          
94
**************************************************************************** */
101
**************************************************************************** */
95
void LcdClear(void)
102
void LcdClear(void)
96
{
103
{
97
        unsigned char i;
104
  unsigned char i;
98
        for(i=0;i<80;i++) DisplayBuff[i] = ' ';
105
  for(i=0;i<80;i++) DisplayBuff[i] = ' ';
99
}
106
}
100
 
107
 
101
 
108
 
102
/* ****************************************************************************
109
/* ****************************************************************************
103
  Functionname:     InitOSD                      */ /*!
110
  Functionname:     InitOSD                      */ /*!
104
  Description:         Init the Bob-4H OSD
111
  Description:         Init the Bob-4H OSD
105
 
112
 
106
  @param[in]        
113
  @param[in]        
107
 
114
 
108
  @return           void
115
  @return           void
109
  @pre              -
116
  @pre              -
110
  @post             -
117
  @post             -
111
  @author           Michael Walter
118
  @author           Michael Walter
112
**************************************************************************** */
119
**************************************************************************** */
113
void InitOSD()
120
void InitOSD()
114
{
121
{
115
        /* Clear OSD */
122
  /* Clear OSD */
116
        OSD_printf ("\33[2J");                         
123
  OSD_printf ("\33[2J");
117
        Delay_ms_Mess(300);
124
  Delay_ms_Mess(300);
118
        OSD_printf ("\33[2J");                         
125
  OSD_printf ("\33[2J");
119
       
126
 
120
    /* Set OSD Pixel Clock */
127
  /* Set OSD Pixel Clock */
121
        Delay_ms_Mess(300);
128
  Delay_ms_Mess(300);
122
        OSD_printf ("\33[23;6v");              
129
  OSD_printf ("\33[23;6v");
123
       
130
 
124
        /* Set OSD Pixel Width */
131
  /* Set OSD Pixel Width */
125
        Delay_ms_Mess(300);
132
  Delay_ms_Mess(300);
126
        OSD_printf ("\33[25;448v");            
133
  OSD_printf ("\33[25;448v");
127
       
134
 
128
    /* Set OSD Font */
135
  /* Set OSD Font */
129
        Delay_ms_Mess(300);
136
  Delay_ms_Mess(300);
130
        OSD_printf ("\33[0z");         
137
  OSD_printf ("\33[0z");
131
}
138
}
132
 
139
 
133
 
140
 
134
 
141
 
135
/* ****************************************************************************
142
/* ****************************************************************************
136
Functionname:     UART2Print                      */ /*!
143
Functionname:     UART2Print                      */ /*!
137
Description:          Send OSD Data to the Bob-4H OSD
144
Description:          Send OSD Data to the Bob-4H OSD
138
 
145
 
139
  @return           void
146
  @return           void
140
  @pre              -
147
  @pre              -
141
  @post             -
148
  @post             -
142
  @author           Michael Walter
149
  @author           Michael Walter
143
**************************************************************************** */
150
**************************************************************************** */
144
void UART2Print()
151
void UART2Print()
145
{
152
{
146
        OSDBuff[OSDPtr] = '\r';
153
  OSDBuff[OSDPtr] = '\r';
147
        if (UART2PrintAbgeschlossen == 1)
154
  if (UART2PrintAbgeschlossen == 1)
148
        {
155
  {
149
                UART2PrintAbgeschlossen = 0;
156
    UART2PrintAbgeschlossen = 0;
150
                UDR1 = OSDBuff[0];
157
    UDR1 = OSDBuff[0];
151
        }
158
  }
152
}
159
}
153
 
160
 
154
/* ****************************************************************************
161
/* ****************************************************************************
155
Functionname:     SIGNAL                      */ /*!
162
Functionname:     SIGNAL                      */ /*!
156
Description:          Send OSD Data to the Bob-4H OSD
163
Description:          Send OSD Data to the Bob-4H OSD
157
 
164
 
158
  @return           void
165
  @return           void
159
  @pre              -
166
  @pre              -
160
  @post             -
167
  @post             -
161
  @author           Michael Walter
168
  @author           Michael Walter
162
**************************************************************************** */
169
**************************************************************************** */
163
SIGNAL(SIG_USART1_TRANS)
170
SIGNAL(SIG_USART1_TRANS)
164
{
171
{
165
        static unsigned int ptr = 0;
172
  static unsigned int ptr = 0;
166
       
173
 
167
        unsigned char tmp_tx;
174
  unsigned char tmp_tx;
168
        if(!UART2PrintAbgeschlossen)  
175
  if(!UART2PrintAbgeschlossen)  
169
        {
176
  {
170
                ptr++;   // die [0] wurde schon gesendet
177
    ptr++;   // die [0] wurde schon gesendet
171
                tmp_tx = OSDBuff[ptr];  
178
    tmp_tx = OSDBuff[ptr];  
172
                if((tmp_tx == '\r')  /* tmp_tx == 0 */)
179
    if((tmp_tx == '\r')  /* tmp_tx == 0 */)
173
                {
180
    {
174
                        ptr = 0;
181
      ptr = 0;
175
                        UART2PrintAbgeschlossen = 1;
182
      UART2PrintAbgeschlossen = 1;
176
                }
183
    }
177
                UDR1 = tmp_tx;
184
    UDR1 = tmp_tx;
178
        }
185
  }
179
        else ptr = 0;
186
  else ptr = 0;
180
}
187
}
181
 
188
 
182
 
189
 
183
/* ****************************************************************************
190
/* ****************************************************************************
184
  Functionname:     SendOSD                      */ /*!
191
  Functionname:     SendOSD                      */ /*!
185
  Description:          Display OnScreen Display Data on a Bob-4H
192
  Description:          Display OnScreen Display Data on a Bob-4H
186
 
193
 
187
  @param[in]        
194
  @param[in]        
188
 
195
 
189
  @return           void
196
  @return           void
190
  @pre              -
197
  @pre              -
191
  @post             -
198
  @post             -
192
  @author           Michael Walter
199
  @author           Michael Walter
193
**************************************************************************** */
200
**************************************************************************** */
194
void SendOSD()
201
void SendOSD()
195
{
202
{
196
        /*--- (SYMBOLIC) CONSTANTS ---*/
203
/*--- (SYMBOLIC) CONSTANTS ---*/
197
       
204
 
198
        /*--- VARIABLES ---*/
205
/*--- VARIABLES ---*/
199
        //static int dx, dy, x1,y1,x2,y2;
206
  static int dx, dy, x1,y1,x2,y2;
200
        //f32_t sinPhi_P_cosTheta_P;
207
  f32_t sinPhi_P_cosTheta_P;
201
        //static int x1_old, y1_old, x2_old, y2_old;
208
  static int x1_old, y1_old, x2_old, y2_old;
202
       
-
 
203
        static int iState = 0;
209
  static int iState = 0;
204
       
210
 
205
        switch (iState)
211
  switch (iState)
206
        {
212
  {
207
        case 0:
213
  case 0:
208
                OSD_printf ("\33[0;11HHDG:%03d", status.iPsi10 / 10);          
214
    OSD_printf ("\33[0;11HHDG:%03d", status.iPsi10 / 10);
209
                iState++;                                              
215
    iState++;
210
                break;
216
    break;
211
        case 1: /* Display the battery voltage an the RC signal level */
217
  case 1: /* Display the battery voltage an the RC signal level */
212
                OSD_printf ("\33[0;0HU:%03d\33[1;0HR:%03d", UBat, RCQuality);          
218
    OSD_printf ("\33[0;0HU:%03d\33[1;0HR:%03d", UBat, RCQuality);
213
                iState++;
219
    iState++;
214
                break;
220
    break;
215
        case 2: /* Display the current altitude */                     
221
  case 2: /* Display the current altitude */
216
                if (targetPosValid == 1)
222
    if (targetPosValid == 1)
217
                {
223
    {
218
                        int DeltaGPSAltitude = (actualPos.altitude - targetPos.altitude);
224
      int DeltaGPSAltitude = (actualPos.altitude - targetPos.altitude);
219
                        OSD_printf ("\33[18;20HAGL:%03d\33[17;20HBar:%03d", DeltaGPSAltitude, CurrentAltitude);        
225
      OSD_printf ("\33[18;20HAGL:%03d\33[17;20HBar:%03d", DeltaGPSAltitude, CurrentAltitude);
220
                }
226
    }
221
                else
227
    else
222
                {
228
    {
223
                        OSD_printf ("\33[18;20HAGL:-.-\33[17;20HBar:%03d", CurrentAltitude);           
229
      OSD_printf ("\33[18;20HAGL:-.-\33[17;20HBar:%03d", CurrentAltitude);
224
                }      
-
 
225
                iState++;
-
 
226
                break;
-
 
227
        case 3: /* Draw an artificial horizon. Part 1 */                       
-
 
228
#if 0                   
-
 
229
                sinPhi_P_cosTheta_P =  sinPhi_P * cosTheta_P;          
-
 
230
                Theta45 = c_asin_8192((int)(sin45 * (-sinTheta_P + sinPhi_P_cosTheta_P ) * 8192.F));
-
 
231
                Phi45 = c_atan2((int)(100.F * sin45 * (-sinTheta_P - sinPhi_P_cosTheta_P) / (cosPhi_P * cosTheta_P)) , 100);
-
 
232
                dx = c_cos_8192(Phi45) / 128;                  
-
 
233
                dy = c_sin_8192(Phi45) / 128;
-
 
234
                x1 = 180 - dx;
-
 
235
                y1 = 120 + 2 * Theta45 + dy;
-
 
236
                x2 = 180 + dx;
-
 
237
                y2 = y1 - 2 * dy;
-
 
238
               
-
 
239
                OSDPtr = 0;  
-
 
240
                OSD_printf_("\33[%d;%d.r\33[%d;%d+r\33[0/r",x1_old,y1_old,x2_old,y2_old);
-
 
241
#endif          
-
 
242
                iState++;
-
 
243
                break;
-
 
244
        case 4:  /* Draw an artificial horizon. Part 2 */                      
-
 
245
#if 0                   
230
    }
246
                OSD_printf_("\33[%d;%d.r\33[%d;%d+r\33[/r",x1,y1,x2,y2);
-
 
247
                UART2Print();
-
 
248
                x1_old = x1;
-
 
249
                y1_old = y1;
-
 
250
                x2_old = x2;
-
 
251
                y2_old = y2;   
-
 
252
#endif          
-
 
253
                iState++;
-
 
254
                break;         
-
 
255
        case 5:  /* Display velocity over ground */
-
 
256
                if (actualPos.state > 1)
-
 
257
                {
-
 
258
                        OSD_printf ("\33[0;20HVel:%03d", ((actualPos.groundSpeed / 10) * 36) /100);            
-
 
259
                }
-
 
260
                else
-
 
261
                {
-
 
262
                        OSD_printf ("\33[0;20HVel:-.-");               
-
 
263
                }                                              
-
 
264
                iState++;
-
 
265
                break;
-
 
266
        case 6:  /* Display distance from target */
-
 
267
                if (targetPosValid == 1)
-
 
268
                {
-
 
269
                        OSD_printf ("\33[1;20HDst:%03d", maxDistance / 10);            
-
 
270
                }
-
 
271
                else
-
 
272
                {
-
 
273
                        OSD_printf ("\33[1;20HDst:-.-");               
-
 
274
                }                                              
-
 
275
                iState++;      
231
    iState++;
276
                break;
232
    break;
277
        case 7: /* Draw an artificial horizon. Part 1 */               
233
  case 3: /* Draw an artificial horizon. Part 1 */
278
#if 0
234
#if 1
279
                sinPhi_P_cosTheta_P =  sinPhi_P * cosTheta_P;          
235
    sinPhi_P_cosTheta_P =  sinPhi_P * cosTheta_P;
280
                Theta45 = c_asin_8192((int)(sin45 * (-sinTheta_P + sinPhi_P_cosTheta_P ) * 8192.F));
236
    Theta45 = c_asin_8192((int)(sin45 * (-sinTheta_P + sinPhi_P_cosTheta_P ) * 8192.F));
281
                Phi45 = c_atan2((int)(100.F * sin45 * (-sinTheta_P - sinPhi_P_cosTheta_P) / (cosPhi_P * cosTheta_P)) , 100);
237
    Phi45 = c_atan2((int)(100.F * sin45 * (-sinTheta_P - sinPhi_P_cosTheta_P) / (cosPhi_P * cosTheta_P)) , 100);
282
                dx = c_cos_8192(Phi45) / 128;                  
238
    dx = c_cos_8192(Phi45) / 128;
283
                dy = c_sin_8192(Phi45) / 128;
239
    dy = c_sin_8192(Phi45) / 128;
284
                x1 = 180 - dx;
240
    x1 = 180 - dx;
285
                y1 = 120 + 2 * Theta45 + dy;
241
    y1 = 120 + 2 * Theta45 + dy;
286
                x2 = 180 + dx;
242
    x2 = 180 + dx;
287
                y2 = y1 - 2 * dy;
243
    y2 = y1 - 2 * dy;
288
               
244
   
289
                OSDPtr = 0;  
245
    OSDPtr = 0;  
290
                OSD_printf_("\33[%d;%d.r\33[%d;%d+r\33[0/r",x1_old,y1_old,x2_old,y2_old);
246
    OSD_printf_("\33[%d;%d.r\33[%d;%d+r\33[0/r",x1_old,y1_old,x2_old,y2_old);
291
#endif  
-
 
292
                iState++;
-
 
293
                break;
-
 
294
        case 8: /* Draw an artificial horizon. Part 2 */                               
-
 
295
#if 0                   
-
 
296
                OSD_printf_("\33[%d;%d.r\33[%d;%d+r\33[/r",x1,y1,x2,y2);
-
 
297
                UART2Print();
-
 
298
               
-
 
299
                x1_old = x1;
-
 
300
                y1_old = y1;
-
 
301
                x2_old = x2;
-
 
302
                y2_old = y2;   
-
 
303
#endif
247
#endif
-
 
248
    iState++;
-
 
249
    break;
-
 
250
  case 4:  /* Draw an artificial horizon. Part 2 */
-
 
251
#if 1
-
 
252
    OSD_printf_("\33[%d;%d.r\33[%d;%d+r\33[/r",x1,y1,x2,y2);
-
 
253
    UART2Print();
-
 
254
    x1_old = x1;
-
 
255
    y1_old = y1;
-
 
256
    x2_old = x2;
-
 
257
    y2_old = y2;
-
 
258
#endif
-
 
259
    iState++;
-
 
260
    break;
-
 
261
  case 5:  /* Display velocity over ground */
-
 
262
    if (actualPos.state > 1)
-
 
263
    {
-
 
264
      OSD_printf ("\33[0;20HVel:%03d", ((actualPos.groundSpeed / 10) * 36) /100);
-
 
265
    }
-
 
266
    else
-
 
267
    {
-
 
268
      OSD_printf ("\33[0;20HVel:-.-");
-
 
269
    }
-
 
270
    iState++;
-
 
271
    break;
-
 
272
  case 6:  /* Display distance from target */
-
 
273
    if (targetPosValid == 1)
-
 
274
    {
-
 
275
      OSD_printf ("\33[1;20HDst:%03d", maxDistance / 10);
-
 
276
    }
-
 
277
    else
-
 
278
    {
-
 
279
      OSD_printf ("\33[1;20HDst:-.-");
-
 
280
    }
-
 
281
    iState = 8;
-
 
282
    break;
-
 
283
  case 7:
-
 
284
    OSD_printf ("\33[4;0HN:%03d\33[5;0HR:%03d", status.iTheta10 / 10, status.iPhi10 / 10);             
-
 
285
    iState++;
-
 
286
    break;
-
 
287
  case 8: /* Draw an artificial horizon. Part 1 */
-
 
288
#if 1
-
 
289
    sinPhi_P_cosTheta_P =  sinPhi_P * cosTheta_P;
-
 
290
    Theta45 = c_asin_8192((int)(sin45 * (-sinTheta_P + sinPhi_P_cosTheta_P ) * 8192.F));
-
 
291
    Phi45 = c_atan2((int)(100.F * sin45 * (-sinTheta_P - sinPhi_P_cosTheta_P) / (cosPhi_P * cosTheta_P)) , 100);
-
 
292
    dx = c_cos_8192(Phi45) / 128;
-
 
293
    dy = c_sin_8192(Phi45) / 128;
-
 
294
    x1 = 180 - dx;
-
 
295
    y1 = 120 + 2 * Theta45 + dy;
-
 
296
    x2 = 180 + dx;
-
 
297
    y2 = y1 - 2 * dy;
-
 
298
   
-
 
299
    OSDPtr = 0;  
-
 
300
    OSD_printf_("\33[%d;%d.r\33[%d;%d+r\33[0/r",x1_old,y1_old,x2_old,y2_old);
-
 
301
#endif
-
 
302
    iState++;
-
 
303
    break;
-
 
304
  case 9: /* Draw an artificial horizon. Part 2 */
-
 
305
#if 1
-
 
306
    OSD_printf_("\33[%d;%d.r\33[%d;%d+r\33[/r",x1,y1,x2,y2);
-
 
307
    UART2Print();
-
 
308
   
-
 
309
    x1_old = x1;
-
 
310
    y1_old = y1;
-
 
311
    x2_old = x2;
-
 
312
    y2_old = y2;
-
 
313
#endif
304
                iState++;
314
    iState++;
305
                break;         
315
    break;
306
        case 9: /* Display the GPS control outputs */                                                  
316
  case 10: /* Display the GPS control outputs */
307
                OSD_printf ("\33[16;0HNG:%03d EG:%03d \33[17;0HNV:%03d EV:%03d ", nick_gain_p,  roll_gain_p, nick_gain_d,  roll_gain_d);               
317
    OSD_printf ("\33[16;0HNG:%03d EG:%03d \33[17;0HNV:%03d EV:%03d ", nick_gain_p,  roll_gain_p, nick_gain_d,  roll_gain_d);
308
                iState++;
318
    iState++;
309
                break;                         
319
    break;
310
        case 10:                       
320
  case 11:
311
                OSD_printf ("\33[16;20HClb:%03d", DeltaAltitude);              
321
    OSD_printf ("\33[16;20HClb:%03d", DeltaAltitude);
312
                iState++;
322
    iState++;
313
                break;                         
323
    break;
314
        case 11:/*  Draw a ^ to indicate the target direction  */      
324
  case 12:/*  Draw a ^ to indicate the target direction  */
315
                {              
325
    {
316
                        static int LastGierOffset = 0;
326
      static int LastGierOffset = 0;
317
                        int GierOffset = (TargetGier - status.iPsi10) / 10;
327
      int GierOffset = (TargetGier - status.iPsi10) / 10;
318
                        if (GierOffset > 180)
328
      if (GierOffset > 180)
319
                        {
329
      {
320
                                GierOffset -= 360;
330
        GierOffset -= 360;
321
                        }
331
      }
322
                        if (GierOffset < -180)
332
      if (GierOffset < -180)
323
                        {
333
      {
324
                                GierOffset += 360;
334
        GierOffset += 360;
325
                        }
335
      }
326
                        GierOffset /= 14;
336
      GierOffset /= 14;
327
                       
337
     
328
                        OSD_printf ("\33[2;%dH \33[2;%dH^", 14 + LastGierOffset,14 + GierOffset);              
338
      OSD_printf ("\33[2;%dH \33[2;%dH^", 14 + LastGierOffset,14 + GierOffset);
329
                        LastGierOffset = GierOffset;
339
      LastGierOffset = GierOffset;
330
                        iState++;
340
      iState = 14;
331
                        break;
341
      break;
332
                }
342
    }
333
        case 12:         /* Display the GPS_Nick and  GPS_Roll / StickNick and StickRoll */                            
343
  case 13: /* Display the GPS_Nick and  GPS_Roll / StickNick and StickRoll */
334
                if (Override == 0)
344
    if (Override == 0)
335
                {
345
    {
336
                        OSD_printf ("\33[18;0HGN:%03d GR:%03d ", GPS_Nick, GPS_Roll);          
346
      OSD_printf ("\33[18;0HGN:%03d GR:%03d ", GPS_Nick, GPS_Roll);
337
                }
347
    }
338
                else                   
348
    else
339
                {
349
    {
340
                        OSD_printf ("\33[18;0HSN:%03d SR:%03d ", StickNick, StickRoll);        
350
      OSD_printf ("\33[18;0HSN:%03d SR:%03d ", StickNick, StickRoll);
341
                }
351
    }
342
                iState++;
352
    iState++;
343
                break;
353
    break;
344
        case 13:
354
  case 14:
345
#if 0           /* Display the Horizon  */              
355
#if 1/* Display the Horizon  */
346
                OSD_printf ("\33[156;120.r\33[204;120+r\33[/r ");              
356
    OSD_printf ("\33[156;120.r\33[204;120+r\33[/r ");
347
#endif       
357
#endif       
348
                iState=0;
358
    iState=0;
349
                break;                 
359
    break;
350
        default:
360
  default:
351
                iState = 0;
361
    iState = 0;
352
                }              
362
  }
353
}
363
}
354
 
364
 
355
 
365