Subversion Repositories FlightCtrl

Rev

Rev 1994 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1995 - 1
#include "jetimenu.h"
2
#include "libfc.h"
3
#include "printf_P.h"
4
#include "main.h"
5
#include "spi.h"
6
#include "capacity.h"
7
#include "hottmenu.h"
8
 
9
#define JETIBOX_KEY_RIGHT       0x1F
10
#define JETIBOX_KEY_UP          0x2F
11
#define JETIBOX_KEY_DOWN        0x4F
12
#define JETIBOX_KEY_LEFT        0x8F
13
#define JETIBOX_KEY_NONE        0x0F
14
#define JETIBOX_KEY_UNDEF       0x00
15
 
16
//MartinW added Key's
17
#define JETIBOX_KEY_LANDR       0x9F // 159
18
#define JETIBOX_KEY_DownANDR    0x5F // 95
19
#define JETIBOX_KEY_DownANDL    0xCF // 207
20
#define JETIBOX_KEY_DownANDUP   0x6F // 111
21
#define JETIBOX_KEY_UPANDL      0xAF // 175
22
#define JETIBOX_KEY_UPANDR      0x3F // 63
23
//MartinW added Key's
24
 
25
#define JetiBox_printfxy(x,y,format, args...)  { LIBFC_JetiBox_SetPos(y * 16 + x); _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);}
26
#define JetiBox_printf(format, args...)        {  _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);}
27
 
28
// -----------------------------------------------------------
29
// the menu functions
30
// -----------------------------------------------------------
31
 
32
unsigned char exit2=0;
33
 
34
void Menu_Status(uint8_t key)  
35
{                               //0123456789ABCDEF
36
 
37
        JetiBox_printfxy(0,0,"%2i.%1iV",UBat/10, UBat%10);
38
        if(NaviDataOkay)
39
                {
40
//              JetiBox_printfxy(6,0,"%03dm %03d%c", GPSInfo.HomeDistance/10,GPSInfo.HomeBearing, 0xDF);
41
                JetiBox_printfxy(6,0,"%3d%c %03dm%c",ErsatzKompassInGrad, 0xDF, GPSInfo.HomeDistance/10,NC_GPS_ModeCharacter);
42
                }
43
                else
44
                {
45
                JetiBox_printfxy(6,0,"Status");
46
                }
47
        #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
48
        if(NC_ErrorCode)
49
        {
50
         static unsigned int timer;
51
         static char toggle = 1;
52
 
53
         if(CheckDelay(timer)) { if(toggle) toggle = 0; else toggle = 1; timer = SetDelay(1500);};
54
     if(toggle)
55
          {
56
       LIBFC_JetiBox_SetPos(0);
57
           _printf_P(&LIBFC_JetiBox_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0);
58
          }
59
          else
60
          {
61
           JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode);
62
           if(MotorenEin) JetiBeep = 'O';
63
          }
64
        }
65
#else
66
        if(NC_ErrorCode) { JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); if(MotorenEin) JetiBeep = 'O';};
67
#endif
68
        JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60);
69
                if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
70
                {
71
                        JetiBox_printfxy(10,1,"%4im%c", (int16_t)(HoehenWert/100),VarioCharacter);
72
                }
73
 
74
}
75
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
76
void Menu_Sponsor(uint8_t key)
77
{
78
         static unsigned int timer;
79
         static char toggle = 1;
80
 
81
         if(CheckDelay(timer)) { if(toggle) toggle = 0; else toggle = 1; timer = SetDelay(1500);};
82
     if(toggle)
83
          {
84
                JetiBox_printfxy(0,0,"JETI+ sponsored " );
85
                JetiBox_printfxy(0,1,"by Flyinghigh.ch" );
86
          }
87
          else
88
          {
89
                JetiBox_printfxy(0,0,"Settting %1i",GetActiveParamSet());
90
                JetiBox_printfxy(0,1,"%s",EE_Parameter.Name);
91
          }    
92
}
93
 
94
#else
95
void Menu_Sponsor(uint8_t key)
96
{
97
        JetiBox_printfxy(0,0,"JETI+ sponsored " );
98
        JetiBox_printfxy(0,1,"by Flyinghigh.ch" );
99
}
100
#endif
101
 
102
 
103
void Menu_Temperature(uint8_t key)
104
{                       //0123456789ABCDEF
105
 
106
        JetiBox_printfxy(0,0,"T%3i %3i %3i %3i", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature);
107
        JetiBox_printfxy(0,1," %3i %3i %3i %3i", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature);
108
 
109
 
110
/* ///MartinW unnecessary
111
  if(RequiredMotors <= 4)
112
        {
113
         JetiBox_printfxy(0,1,"Temperatures");
114
    }
115
        else
116
    if(RequiredMotors <= 6)
117
        {
118
         JetiBox_printfxy(8,1,"\%cC     ",0xdf);
119
        }
120
*/
121
}
122
 
123
 
124
void Menu_Battery(uint8_t key)
125
{                       //0123456789ABCDEF
126
 
127
if(Capacity.ActualCurrent > MotorsTmax) MotorsTmax = Capacity.ActualCurrent;    ///
128
 
129
JetiBox_printfxy(0,0,"%2i.%1iV", UBat/10, UBat%10);
130
                                        //0123456789ABCDEF
131
        if(!MotorenEin)                                                                                                                         //if Motors not on, show Maximum Values
132
                        {
133
                        JetiBox_printfxy(10,0,"%3i.%1iA",MotorsTmax/10, MotorsTmax%10);
134
                        }
135
                else
136
                {
137
                JetiBox_printfxy(10,0,"%3i.%1iA",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10);
138
                }
139
        JetiBox_printfxy(0,1,"%4iW %6imAH",Capacity.ActualPower, Capacity.RemainCapacity);
140
 
141
}
142
 
143
void Magnet_Values(uint8_t key)
144
{                       //0123456789ABCDEF
145
        JetiBox_printfxy(0,0,"Magnet:%3i%% %3i%c",EarthMagneticField, KompassValue,0xDF);
146
        JetiBox_printfxy(0,1,"Incli.:%3i%c (%i) ",EarthMagneticInclination, 0xDF,EarthMagneticInclinationTheoretic);
147
}
148
 
149
 
150
void Menu_PosInfo(uint8_t key)
151
{
152
        if(NaviDataOkay)
153
        {
154
                JetiBox_printfxy(0,0,"%2um/s Sat:%d ",GPSInfo.Speed,GPSInfo.NumOfSats);
155
                switch (GPSInfo.SatFix)
156
                {
157
                        case SATFIX_3D:
158
                                JetiBox_printfxy(12,0,"  3D");
159
                                break;
160
//                      case SATFIX_2D:
161
//                      case SATFIX_NONE:
162
                        default:
163
                                JetiBox_printfxy(12,0,"NoFx");
164
                                break;
165
                }
166
                if(GPSInfo.Flags & FLAG_DIFFSOLN)
167
                {
168
                        JetiBox_printfxy(12,0,"DGPS");
169
                }
170
                JetiBox_printfxy(0,1,"Home:%3dm %3d%c %c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF,NC_GPS_ModeCharacter);
171
        }
172
        else
173
        {                     //0123456789ABCDEF
174
                JetiBox_printfxy(2,0,"No NaviCtrl!");
175
        }
176
}
177
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
178
 
179
void Menu_Current(uint8_t key)
180
{                       //0123456789ABCDEF
181
        unsigned char i;
182
 
183
        loop1 ++;
184
 
185
        for(i=0;i<=RequiredMotors-1;i++)
186
        {
187
 
188
                if(loop1 >= updatemotors) Motors[i] =Motor[i].Current;
189
 
190
                if(Motor[i].Current > Motorsmax[i]) Motorsmax[i] = Motor[i].Current;   
191
 
192
                if(!MotorenEin) Motors[i]=Motorsmax[i];
193
        }
194
 
195
                if(loop1 >= updatemotors)       loop1=0;
196
 
197
                JetiBox_printfxy(0,0,"I%3i %3i %3i %3i", Motors[0]-(CurrentOffset/RequiredMotors), Motors[1]-(CurrentOffset/RequiredMotors), Motors[2]-(CurrentOffset/RequiredMotors), Motors[3]-(CurrentOffset/RequiredMotors));
198
                JetiBox_printfxy(0,1," %3i %3i %3i %3i", Motors[4]-(CurrentOffset/RequiredMotors), Motors[5]-(CurrentOffset/RequiredMotors), Motors[6]-(CurrentOffset/RequiredMotors), Motors[7]-(CurrentOffset/RequiredMotors));
199
 
200
                if(RequiredMotors == 4)
201
                {
202
                JetiBox_printfxy(0,1,"Currents T%3i.%1iA",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10);
203
                }
204
 
205
                else
206
                if(RequiredMotors == 6)
207
                {
208
                JetiBox_printfxy(8,1,"%3i.%1iA ",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10);
209
                }
210
 
211
        if(key== JETIBOX_KEY_UP) updatemotors ++;
212
        if(key== JETIBOX_KEY_DOWN) updatemotors --;
213
}
214
 
215
#else
216
void Menu_Current(uint8_t key)
217
{                       //0123456789ABCDEF
218
        unsigned char i;
219
 
220
        loop1 ++;
221
 
222
 
223
                JetiBox_printfxy(0,0,"I%3i %3i %3i %3i", Motor[1].Current-(CurrentOffset/RequiredMotors), Motor[2].Current-(CurrentOffset/RequiredMotors), Motor[3].Current-(CurrentOffset/RequiredMotors), Motor[4].Current-(CurrentOffset/RequiredMotors));
224
                JetiBox_printfxy(0,1," %3i %3i %3i %3i", Motor[5].Current-(CurrentOffset/RequiredMotors), Motor[6].Current-(CurrentOffset/RequiredMotors), Motor[7].Current-(CurrentOffset/RequiredMotors), Motor[8].Current-(CurrentOffset/RequiredMotors));
225
}
226
 
227
#endif
228
 
229
 
230
uint8_t Menu_keynumber(uint8_t key) /// thanks to "metro"
231
{
232
        pos1=0;pos2=0;pos3=0;pos4=0;
233
        if((key== JETIBOX_KEY_UP)||(key== JETIBOX_KEY_DOWN)||((keynumber >= 1)&&(keynumber <= 4 )))
234
        {
235
                if((keynumber <= 0)||(keynumber >= 5 ))
236
                {
237
                        if(key== JETIBOX_KEY_DOWN) {keynumber=1;key= JETIBOX_KEY_UNDEF;} //Key auf UNDEF setzen da sonst der Wert gleich um 1 verkleinert wird.
238
                        if(key== JETIBOX_KEY_UP) {keynumber=4;key= JETIBOX_KEY_UNDEF;}   //Key auf UNDEF setzen da sonst der Wert gleich um 1 vergrössert wird.
239
                }
240
                if(keynumber== 1) pos1=0X3E;if(keynumber== 2) pos2=0X3E;if(keynumber== 3) pos3=0X3E;if(keynumber== 4) pos4=0X3E;
241
                if(key== JETIBOX_KEY_LEFT) keynumber--;
242
                if(key== JETIBOX_KEY_RIGHT) keynumber++;
243
        }
244
        return key;
245
}
246
 
247
 
248
void Menu_I2C(uint8_t key)
249
{                       //0123456789ABCDEF
250
 
251
                JetiBox_printfxy(0,0,"I2C%3i%3i%3i%3i",Motor[0].State & MOTOR_STATE_ERROR_MASK,Motor[1].State & MOTOR_STATE_ERROR_MASK, Motor[2].State & MOTOR_STATE_ERROR_MASK, Motor[3].State & MOTOR_STATE_ERROR_MASK);
252
                JetiBox_printfxy(0,1,"   %3i%3i%3i%3i",Motor[4].State & MOTOR_STATE_ERROR_MASK,Motor[5].State & MOTOR_STATE_ERROR_MASK, Motor[6].State & MOTOR_STATE_ERROR_MASK, Motor[7].State & MOTOR_STATE_ERROR_MASK);
253
 
254
}
255
 
256
 
257
void Menu_Integal(uint8_t key)
258
{                       //0123456789ABCDEF
259
int r=0;
260
int n=0;
261
int g=0;
262
n=SummeNick >> 9;
263
r=SummeRoll >> 9;
264
g=Mess_Integral_Gier >> 9;
265
 
266
        JetiBox_printfxy(0,0,"%3iN %3iR  +N",n, r);
267
        JetiBox_printfxy(0,1,"%3iG    +R -N -R",g);
268
}
269
 
270
void Menu_Info(uint8_t key)
271
{                       //0123456789ABCDEF
272
        //key=Menu_keynumber(key);
273
 
274
 
275
        JetiBox_printfxy(0,0,"%3i=HG/4 %3i=Gas",HoverGas/4,StickGas);
276
        //JetiBox_printfxy(0,1,"%3i=VSpeed",VarioMeter);
277
 
278
        //JetiBox_printfxy(0,1,"%3i=JetiBeep",JetiBeep);
279
}
280
 
281
 
282
 
283
void Menu_Serialpoti(uint8_t key)
284
{                      
285
        key=Menu_keynumber(key);
286
 
287
        JetiBox_printfxy(0,0,"%c%3i=SP1%c%3i=SP3",pos1,PPM_in[13]+127,pos3,PPM_in[15]+127);
288
        JetiBox_printfxy(0,1,"%c%3i=SP2%c%3i=SP4",pos2,PPM_in[14]+127,pos4,PPM_in[16]+127);
289
 
290
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==1)) PPM_in[13]       ++;
291
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==1)) PPM_in[13]       --;
292
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==2)) PPM_in[14]       ++;
293
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==2)) PPM_in[14]       --;
294
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==3)) PPM_in[15]= PPM_in[15]   +5;
295
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==3)) PPM_in[15]= PPM_in[15]   -5;
296
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==4)) PPM_in[16]= PPM_in[16]   +10;
297
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==4)) PPM_in[16]= PPM_in[16]   -10;
298
 
299
}
300
 
301
 
302
void Menu_hoeheconf(uint8_t key)
303
{  
304
/*/                     //0123456789ABCDEF
305
//CFG2_HEIGHT_LIMIT | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC
306
 
307
SENSITIVE_RC on/off     |VARIO_BEEP on/off|     sw Height= 1 Vario Height = 0;
308
bit             2               1               0
309
000     0       rcoff   Beepoff h
310
001     1       rcoff   Beepoff v
311
010     2       rcoff   Beepon  h
312
011     3       rcoff   Beepon  v
313
100     4       rcon    Beepoff h
314
101     5       rcon    Beepoff v
315
110     6       rcon    Beepon  h
316
111     7       rcon    Beepon  v
317
 
318
/*/    
319
 
320
//JetiBox_printfxy(0,0,"%3i econf",EE_Parameter.ExtraConfig);
321
//JetiBox_printfxy(0,1,"%3i=beep %3ideckel",(EE_Parameter.ExtraConfig & CFG2_VARIO_BEEP),(EE_Parameter.ExtraConfig & CFG2_HEIGHT_LIMIT));
322
  JetiBeep = 0;
323
        if((EE_Parameter.ExtraConfig & CFG2_HEIGHT_LIMIT) == 1) //EE_Parameter.ExtraConfig == 1 =switched Hightv+ variopiepser
324
        {
325
        JetiBox_printfxy(0,0,"switched Hight v");
326
        }
327
 
328
                if((EE_Parameter.ExtraConfig & CFG2_HEIGHT_LIMIT) == 0)
329
                {
330
                JetiBox_printfxy(0,1,"Vario withbeep ^");
331
                }      
332
 
333
        if(key== JETIBOX_KEY_UP)   EE_Parameter.ExtraConfig |= (1 << 0) ;// set bit 0
334
 
335
        if(key== JETIBOX_KEY_DOWN)
336
        {
337
        EE_Parameter.ExtraConfig &= ~(1 << 0)   ;               //delete bit 0
338
        EE_Parameter.ExtraConfig |=  (1 << 1)   ;                       //set bit 1              +piep
339
        }
340
}
341
 
342
 
343
 
344
void Menu_hoehe1(uint8_t key)
345
{                      
346
        Menu_keynumber(key);
347
 
348
        JetiBox_printfxy(0,0,"%c%3i=HD %c%3i=HA",pos1,EE_Parameter.Luftdruck_D,pos3,EE_Parameter.Hoehe_ACC_Wirkung);
349
        JetiBox_printfxy(0,1,"%c%3i=HP %c%3i=HM",pos2,EE_Parameter.Hoehe_P,pos4,EE_Parameter.Hoehe_MinGas);
350
 
351
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==1)) EE_Parameter.Luftdruck_D                 ++;
352
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==1)) EE_Parameter.Luftdruck_D                 --;
353
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==2)) EE_Parameter.Hoehe_P                     ++;
354
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==2)) EE_Parameter.Hoehe_P                     --;
355
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==3)) EE_Parameter.Hoehe_ACC_Wirkung ++;
356
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==3)) EE_Parameter.Hoehe_ACC_Wirkung --;
357
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==4)) EE_Parameter.Hoehe_MinGas                ++;
358
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==4)) EE_Parameter.Hoehe_MinGas                --;
359
}  
360
 
361
void Menu_acc_kalib(uint8_t key)
362
{                      
363
        //Menu_keynumber(key);
364
        keynumber=1;
365
 
366
/*
367
        // Save ACC neutral settings to eeprom
368
        SetParamWord(PID_ACC_NICK, (uint16_t)NeutralAccX);
369
        SetParamWord(PID_ACC_ROLL, (uint16_t)NeutralAccY);
370
        SetParamWord(PID_ACC_TOP,  (uint16_t)NeutralAccZ);*/
371
 
372
                                                //0123456789ABCDEF
373
        JetiBox_printfxy(0,0,"ACC  N=%3i R=%3i",NeutralAccX,NeutralAccY);
374
        JetiBox_printfxy(0,1,"S<>E^v%4i  %4i",PPM_in[EE_Parameter.Kanalbelegung[K_NICK]],PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]);  //^+v JetiBox_printfxy(0,1,"Save<+> Exit");
375
 
376
        if(key== JETIBOX_KEY_UP   ) NeutralAccX                 ++;
377
        if(key== JETIBOX_KEY_DOWN ) NeutralAccX                 --;
378
        if(key== JETIBOX_KEY_RIGHT ) NeutralAccY                ++;
379
        if(key== JETIBOX_KEY_LEFT) NeutralAccY          --;
380
 
381
        if(key== JETIBOX_KEY_LANDR)
382
        {
383
                if(!MotorenEin)
384
                {
385
 
386
                        SetParamWord(PID_ACC_NICK, (uint16_t)NeutralAccX);
387
                        SetParamWord(PID_ACC_ROLL, (uint16_t)NeutralAccY);
388
                                                            //0123456789ABCDEF
389
                        JetiBox_printfxy(0,1,"saved  ");
390
                }
391
                else
392
                {
393
                        #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
394
                        JetiBox_printfxy(0,1,"Motors not off!");
395
                        #endif
396
                }
397
        }
398
 
399
        if(key== JETIBOX_KEY_DownANDUP) keynumber=0;
400
 
401
}
402
 
403
 
404
void Menu_hoehe2(uint8_t key)
405
{                      
406
        key=Menu_keynumber(key);
407
 
408
        JetiBox_printfxy(0,0,"%c%3i=HV %c%3i=HZ",pos1,EE_Parameter.Hoehe_HoverBand,pos3,EE_Parameter.Hoehe_GPS_Z);
409
        JetiBox_printfxy(0,1,"%c%3i=HG %c%3i=NG",pos2,EE_Parameter.Hoehe_Verstaerkung,pos4,EE_Parameter.NotGas);
410
 
411
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==1)) EE_Parameter.Hoehe_HoverBand     ++;
412
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==1)) EE_Parameter.Hoehe_HoverBand     --;
413
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==2)) EE_Parameter.Hoehe_Verstaerkung ++;
414
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==2)) EE_Parameter.Hoehe_Verstaerkung --;
415
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==3)) EE_Parameter.Hoehe_GPS_Z                 ++;
416
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==3)) EE_Parameter.Hoehe_GPS_Z                 --;
417
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==4)) EE_Parameter.NotGas                      ++;
418
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==4)) EE_Parameter.NotGas                      --;
419
}  
420
 
421
 
422
void Menu_stick(uint8_t key)
423
{                      
424
        key=Menu_keynumber(key);
425
 
426
        JetiBox_printfxy(0,0,"%c%3i=StP%c%3i=SGP",pos1,EE_Parameter.Stick_P,pos3,EE_Parameter.StickGier_P);
427
        JetiBox_printfxy(0,1,"%c%3i=StD%c%3i=DrC",pos2,EE_Parameter.Stick_D,pos4,EE_Parameter.Driftkomp);
428
 
429
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==1)) EE_Parameter.Stick_P     ++;
430
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==1)) EE_Parameter.Stick_P     --;
431
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==2)) EE_Parameter.Stick_D     ++;
432
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==2)) EE_Parameter.Stick_D     --;
433
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==3)) EE_Parameter.StickGier_P         ++;
434
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==3)) EE_Parameter.StickGier_P         --;
435
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==4)) EE_Parameter.Driftkomp   ++;
436
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==4)) EE_Parameter.Driftkomp   --;
437
}  
438
 
439
 
440
 
441
void Menu_gyro(uint8_t key)
442
{                      
443
        key=Menu_keynumber(key);
444
 
445
 
446
        JetiBox_printfxy(0,0,"%c%3i=GYP%c%3i=GYI",pos1,EE_Parameter.Gyro_P,pos3,EE_Parameter.Gyro_I);
447
        JetiBox_printfxy(0,1,"%c%3i=GYD%c%3i=MaI",pos2,EE_Parameter.Gyro_D,pos4,EE_Parameter.I_Faktor);
448
 
449
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==1)) EE_Parameter.Gyro_P              ++;
450
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==1)) EE_Parameter.Gyro_P              --;
451
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==2)) EE_Parameter.Gyro_D              ++;
452
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==2)) EE_Parameter.Gyro_D              --;
453
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==3)) EE_Parameter.Gyro_I              ++;
454
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==3)) EE_Parameter.Gyro_I              --;
455
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==4)) EE_Parameter.I_Faktor            ++;
456
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==4)) EE_Parameter.I_Faktor            --;
457
}  
458
 
459
void Menu_gps(uint8_t key)
460
{                      
461
        key=Menu_keynumber(key);
462
 
463
 
464
        JetiBox_printfxy(0,0,"%c%3i=NGG%c%3i=NSC",pos1,EE_Parameter.NaviGpsGain,pos3,EE_Parameter.NaviAccCompensation);
465
        JetiBox_printfxy(0,1,"%c%3i=NWC%c%3i=NAL",pos2,EE_Parameter.NaviWindCorrection,pos4,EE_Parameter.NaviAngleLimitation);
466
 
467
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==1)) EE_Parameter.NaviGpsGain                                 ++;
468
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==1)) EE_Parameter.NaviGpsGain                                 --;
469
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==2)) EE_Parameter.NaviWindCorrection          ++;
470
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==2)) EE_Parameter.NaviWindCorrection          --;
471
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==3)) EE_Parameter.NaviAccCompensation                 ++;
472
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==3)) EE_Parameter.NaviAccCompensation                 --;
473
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==4)) EE_Parameter.NaviAngleLimitation                 ++;
474
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==4)) EE_Parameter.NaviAngleLimitation                 --;
475
}  
476
 
477
void Menu_gpspid(uint8_t key)
478
{                      
479
        key=Menu_keynumber(key);
480
        JetiBox_printfxy(0,0,"%c%3i=NP%c%3i=ND",pos1,EE_Parameter.NaviGpsP,pos3,EE_Parameter.NaviGpsD);
481
        JetiBox_printfxy(0,1,"%c%3i=NI%c%",pos2,EE_Parameter.NaviGpsI,pos4);
482
 
483
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==1)) EE_Parameter.NaviGpsP                            ++;
484
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==1)) EE_Parameter.NaviGpsP                            --;
485
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==2)) EE_Parameter.NaviGpsI            ++;
486
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==2)) EE_Parameter.NaviGpsI            --;
487
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==3)) EE_Parameter.NaviGpsD            ++;
488
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==3)) EE_Parameter.NaviGpsD            --;
489
 
490
}
491
 
492
 
493
void Menu_LOOPconf(uint8_t key) // Korrigiert mit &0xF0
494
{                       //0123456789ABCDEF
495
                char loopval;
496
                loopval=EE_Parameter.BitConfig&0x0F;
497
 
498
                JetiBox_printfxy(0,0," ");
499
 
500
                if(EE_Parameter.BitConfig & CFG_LOOP_LINKS)
501
                {
502
                LIBFC_JetiBox_Putchar(0x3C);
503
                LIBFC_JetiBox_Putchar(0x00);
504
 
505
                }
506
 
507
                if(EE_Parameter.BitConfig & CFG_LOOP_OBEN)
508
                {
509
                LIBFC_JetiBox_Putchar(0X5E);
510
                LIBFC_JetiBox_Putchar(0x00);
511
 
512
                }
513
 
514
                if(EE_Parameter.BitConfig & CFG_LOOP_UNTEN)
515
                {
516
                LIBFC_JetiBox_Putchar(0x76);
517
                LIBFC_JetiBox_Putchar(0x00);
518
 
519
                }
520
 
521
                if(EE_Parameter.BitConfig & CFG_LOOP_RECHTS)
522
                {
523
                LIBFC_JetiBox_Putchar(0X3E);
524
                }
525
 
526
                JetiBox_printfxy(0,1,"Loopingvalue %2id",loopval);
527
 
528
        if((key== JETIBOX_KEY_UP )  & ((loopval) <15 )) loopval ++;
529
        if((key== JETIBOX_KEY_DOWN)  & ((loopval) >0 )) loopval --;
530
 
531
        EE_Parameter.BitConfig=(EE_Parameter.BitConfig&0xF0)|loopval;
532
 
533
}
534
 
535
 
536
void Menu_loopP(uint8_t key)
537
{                      
538
        key=Menu_keynumber(key);
539
 
540
        JetiBox_printfxy(0,0,"%c%3i=LGL%c%3i=LHy",pos1,EE_Parameter.LoopGasLimit,pos3,EE_Parameter.LoopHysterese);
541
        JetiBox_printfxy(0,1,"%c%3i=LTh",pos2,EE_Parameter.LoopThreshold);
542
 
543
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==1)) EE_Parameter.LoopGasLimit                        ++;
544
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==1)) EE_Parameter.LoopGasLimit                        --;
545
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==2)) EE_Parameter.LoopThreshold                       ++;
546
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==2)) EE_Parameter.LoopThreshold                       --;
547
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==3)) EE_Parameter.LoopHysterese                       ++;
548
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==3)) EE_Parameter.LoopHysterese                       --;
549
}  
550
 
551
 
552
void Menu_coup(uint8_t key)
553
{                      
554
        key=Menu_keynumber(key);
555
 
556
        JetiBox_printfxy(0,0,"%c%3i=FGP%c%3i=CYC",pos1,EE_Parameter.AchsKopplung1,pos3,EE_Parameter.CouplingYawCorrection);
557
        JetiBox_printfxy(0,1,"%c%3i=FNR%c%3i=MSH",pos2,EE_Parameter.AchsKopplung2,pos4,EE_Parameter.MotorSmooth);
558
 
559
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==1)) EE_Parameter.AchsKopplung1                       ++;
560
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==1)) EE_Parameter.AchsKopplung1                       --;
561
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==2)) EE_Parameter.AchsKopplung2                       ++;
562
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==2)) EE_Parameter.AchsKopplung2                       --;
563
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==3)) EE_Parameter.CouplingYawCorrection       ++;
564
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==3)) EE_Parameter.CouplingYawCorrection       --;
565
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==4)) EE_Parameter.MotorSmooth                         ++;
566
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==4)) EE_Parameter.MotorSmooth                         --;
567
}  
568
 
569
void Menu_gyroGandStab(uint8_t key)
570
{                      
571
        key=Menu_keynumber(key);
572
 
573
        JetiBox_printfxy(0,0,"%c%3i=GGP%c%3i=GSt",pos1,EE_Parameter.Gyro_Gier_P,pos3,EE_Parameter.Gyro_Stability);
574
        JetiBox_printfxy(0,1,"%c%3i=GGI%c%3i=DSt",pos2,EE_Parameter.Gyro_Gier_I,pos4,EE_Parameter.DynamicStability);
575
 
576
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==1)) EE_Parameter.Gyro_Gier_P                 ++;
577
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==1)) EE_Parameter.Gyro_Gier_P                 --;
578
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==2)) EE_Parameter.Gyro_Gier_I                 ++;
579
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==2)) EE_Parameter.Gyro_Gier_I                 --;
580
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==3) & ( EE_Parameter.Gyro_Stability <15 )) EE_Parameter.Gyro_Stability        ++;
581
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==3) & ( EE_Parameter.Gyro_Stability >0  )) EE_Parameter.Gyro_Stability        --;
582
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==4)) EE_Parameter.DynamicStability    ++;
583
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==4)) EE_Parameter.DynamicStability    --;
584
}                              
585
 
586
void Menu_camera(uint8_t key)
587
{                      
588
        key=Menu_keynumber(key);
589
 
590
        JetiBox_printfxy(0,0,"%c%3i=NCT%c%3i=RCT",pos1,EE_Parameter.ServoNickControl,pos3,EE_Parameter.ServoRollControl);
591
        JetiBox_printfxy(0,1,"%c%3i=NCP%c%3i=RCP",pos2,EE_Parameter.ServoNickComp,pos4,EE_Parameter.ServoRollComp);
592
 
593
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==1)) EE_Parameter.ServoNickControl            ++;     // Wert : 0-247     // Stellung des Servos
594
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==1)) EE_Parameter.ServoNickControl            --;  
595
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==2)) EE_Parameter.ServoNickComp               ++; // Wert : 0-247     // Einfluss Gyro/Servo
596
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==2)) EE_Parameter.ServoNickComp               --;  
597
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==3)) EE_Parameter.ServoRollControl    ++;     // Wert : 0-247     // Stellung des Servos   
598
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==3)) EE_Parameter.ServoRollControl    --;    
599
        if((key== JETIBOX_KEY_UP  ) & (keynumber ==4)) EE_Parameter.ServoRollComp       ++;             // Wert : 0-247     // Einfluss Gyro/Servo
600
        if((key== JETIBOX_KEY_DOWN) & (keynumber ==4)) EE_Parameter.ServoRollComp       --;
601
}
602
 
603
 
604
 
605
 
606
void Menu_mtest(uint8_t key)
607
{                       //0123456789ABCDEF
608
 
609
 
610
        Debug("Motort=%i",PC_MotortestActive);
611
        PC_MotortestActive = 254;
612
 
613
        JetiBox_printfxy(0,0,"Mtest <+v <+^%3i",Motor[loop3].Current-(CurrentOffset/RequiredMotors));  //13 chars
614
        JetiBox_printfxy(0,1,"Motor=%2i Sp=%2i",loop3+1, MotorTest[loop3]);
615
 
616
        if((key== JETIBOX_KEY_UP)   & (loop2 <100 )) loop2=loop2 +2;//GESCHW
617
        if((key== JETIBOX_KEY_DOWN) & (loop2 >0  )) loop2=loop2 -2;
618
 
619
        if((key== JETIBOX_KEY_UPANDL)  & (loop3 <15 ))
620
                {
621
                MotorTest[loop3]=0;
622
                loop3 ++;//motornummer
623
                }
624
 
625
        if((key==JETIBOX_KEY_DownANDL) & (loop3 >0 ))
626
                {
627
                MotorTest[loop3]=0;
628
                loop3 --;
629
                }
630
 
631
        MotorTest[loop3]=loop2;
632
 
633
}
634
 
635
void Menu_mem(uint8_t key)
636
{                      
637
        JetiBox_printfxy(0,0,"Set%1i=%s ",GetActiveParamSet(),EE_Parameter.Name);
638
        JetiBox_printfxy(0,1,   "< + >toSTOREto %1i",settingdest);
639
                                                 //     00123456789ABCDEF
640
                //if(key== JETIBOX_KEY_DOWN )
641
 
642
                if(key== JETIBOX_KEY_LANDR &&  !MotorenEin)
643
                {
644
 
645
                ParamSet_WriteToEEProm(settingdest);
646
                Piep(GetActiveParamSet(),120);
647
                JetiBox_printfxy(13,0,"OK!");  
648
 
649
 
650
                }
651
 
652
                if((key== JETIBOX_KEY_UP)   & (settingdest <5 )) settingdest++;
653
 
654
 
655
                if((key== JETIBOX_KEY_DOWN) & (settingdest >1  )) settingdest--;
656
 
657
}
658
 
659
 
660
 
661
// -----------------------------------------------------------
662
// the menu topology
663
// -----------------------------------------------------------
664
typedef void (*pFctMenu) (uint8_t);  // the menu item handler function pointer
665
 
666
typedef struct{
667
  int8_t left;
668
  int8_t right;
669
  int8_t up;
670
  int8_t down;
671
  pFctMenu pHandler;
672
} MENU_ENTRY;
673
 
674
 
675
// the menu navigation structure
676
 
677
const MENU_ENTRY JetiBox_Menu[] PROGMEM=
678
{ // l  r  u  d  pHandler links rechts up down
679
        { 1,  1,  1,  1, &Menu_Sponsor },//{ 0,  0,  0,  0, &Menu_acc_kalib },
680
        {10,  2,  1, 11, &Menu_Status },
681
        { 1,  3,  2,  2, &Menu_Temperature },
682
        { 2,  4,  3,  3, &Menu_Battery },
683
        { 3,  5,  4,  4, &Menu_PosInfo },
684
        { 4,  6,  5, 25, &Magnet_Values },
685
        { 5,  7,  6,  6, &Menu_Current },
686
        { 6,  8,  7,  7, &Menu_I2C },
687
        { 7,  9,  8,  8, &Menu_Integal },
688
        { 8, 10,  9,  9, &Menu_Info },
689
        { 9,  1, 10, 10, &Menu_mtest },
690
        { 1, 12, 11, 11, &Menu_Serialpoti },
691
        {11, 13, 12, 12, &Menu_hoehe1 },
692
        {12, 14, 13, 13, &Menu_hoehe2 },
693
        {13, 15, 14, 14, &Menu_stick },
694
        {14, 16, 15, 15, &Menu_gyro },
695
        {15, 17, 16, 16, &Menu_gyroGandStab },
696
        {16, 18, 17, 17, &Menu_gps },
697
        {17, 19, 18, 18, &Menu_gpspid },
698
        {18, 20, 19, 19, &Menu_loopP },
699
        {19, 21, 20, 20, &Menu_coup },
700
        {20, 22, 21, 21, &Menu_camera },
701
        {21, 23, 22, 22, &Menu_LOOPconf },
702
        {22, 24, 23, 23, &Menu_hoeheconf },
703
        {23,  1, 24, 24, &Menu_mem },
704
        { 5,  5, 25, 25, &Menu_acc_kalib },
705
};
706
//void Menu_gpspid(uint8_t key)
707
 
708
 
709
// -----------------------------------------------------------
710
// Update display buffer
711
// -----------------------------------------------------------
712
unsigned char JetiBox_Update(unsigned char key)
713
{
714
//printf(" %3i = keynumber, pos1 =%3i \n\r ", pos1); ///
715
 
716
        static uint8_t item = 0, last_item = 0; // the menu item
717
 
718
        // navigate within the menu by key action
719
        last_item = item;
720
        switch(key)
721
        {
722
                case JETIBOX_KEY_LEFT:
723
                        ///if (item == 0) return (1);                                                                   // switch back to jeti expander menu, so no back possible
724
                         ///else
725
                                ///{
726
                                if (keynumber <= 0 || keynumber >=5)  //keynumber normaly 0, only in the parameter pages keyn=1...4
727
                                        {
728
                                        item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item
729
                                        }
730
                                ///} 
731
 
732
                        break;
733
                case JETIBOX_KEY_RIGHT:
734
                if (keynumber <= 0 || keynumber >=5)
735
                        {
736
                        item = pgm_read_byte(&JetiBox_Menu[item].right);        //trigger to right menu item
737
                        }
738
                        break;
739
                case JETIBOX_KEY_UP:   
740
                        item = pgm_read_byte(&JetiBox_Menu[item].up);           //trigger to up menu item
741
                        break;
742
                case JETIBOX_KEY_DOWN:
743
                        item = pgm_read_byte(&JetiBox_Menu[item].down);         //trigger to down menu item
744
                        break;
745
 
746
                case JETIBOX_KEY_NONE: ///
747
                if (keynumber == 5 )
748
                        {
749
                        item = pgm_read_byte(&JetiBox_Menu[item].right);        //trigger to right menu item
750
                        keynumber=6;
751
                        }
752
 
753
                if (keynumber == 0)  //keynumber normaly 0, only in the parameter pages keyn=1...4
754
                                        {
755
                                        item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item
756
                                        keynumber=-1;
757
 
758
                                        }
759
                        break;
760
 
761
                default:
762
                        break;
763
        }
764
        // if the menu item has been changed, do not pass the key to the item handler
765
        // to avoid jumping over to items
766
        if(item != last_item) key = JETIBOX_KEY_UNDEF;
767
 
768
        LIBFC_JetiBox_Clear();
769
        //execute menu item handler
770
        ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key);
771
 
772
 
773
 
774
 
775
        if(!(FC_StatusFlags & FC_STATUS_LOWBAT)) /// MartinW; Variobeep only when no Battery warning
776
        {
777
                if(VarioCharacter == 0x2B) ///
778
                {
779
                JetiBeep = 101;//"."
780
                }
781
 
782
                if(VarioCharacter == 0x2D) ///
783
                {
784
                JetiBeep = 116;// "_"
785
                }
786
        }      
787
 
788
        return (0);
789
}
790