Subversion Repositories FlightCtrl

Rev

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

Rev Author Line No. Line
2050 holgerb 1
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2
// + Software Nutzungsbedingungen (english version: see below)
3
// + www.MikroKopter.com
4
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5
// + der Fa. HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland - nachfolgend Lizenzgeber genannt -
6
// + Der Lizenzgeber räumt dem Kunden ein nicht-ausschließliches, zeitlich und räumlich* unbeschränktes Recht ein, die im den
7
// + Mikrocontroller verwendete Firmware für die Hardware Flight-Ctrl, Navi-Ctrl, BL-Ctrl, MK3Mag & PC-Programm MikroKopter-Tool 
8
// + - nachfolgend Software genannt - nur für private Zwecke zu nutzen.
9
// + Der Einsatz dieser Software ist nur auf oder mit Produkten des Lizenzgebers zulässig.
10
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11
// + Die vom Lizenzgeber gelieferte Software ist urheberrechtlich geschützt. Alle Rechte an der Software sowie an sonstigen im
12
// + Rahmen der Vertragsanbahnung und Vertragsdurchführung überlassenen Unterlagen stehen im Verhältnis der Vertragspartner ausschließlich dem Lizenzgeber zu.
13
// + Die in der Software enthaltenen Copyright-Vermerke, Markenzeichen, andere Rechtsvorbehalte, Seriennummern sowie
14
// + sonstige der Programmidentifikation dienenden Merkmale dürfen vom Kunden nicht verändert oder unkenntlich gemacht werden.
15
// + Der Kunde trifft angemessene Vorkehrungen für den sicheren Einsatz der Software. Er wird die Software gründlich auf deren
16
// + Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt.
17
// + Die Haftung des Lizenzgebers wird - soweit gesetzlich zulässig - begrenzt in Höhe des typischen und vorhersehbaren
18
// + Schadens. Die gesetzliche Haftung bei Personenschäden und nach dem Produkthaftungsgesetz bleibt unberührt. Dem Lizenzgeber steht jedoch der Einwand 
19
// + des Mitverschuldens offen.
20
// + Der Kunde trifft angemessene Vorkehrungen für den Fall, dass die Software ganz oder teilweise nicht ordnungsgemäß arbeitet.
21
// + Er wird die Software gründlich auf deren Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt.
22
// + Der Kunde wird er seine Daten vor Einsatz der Software nach dem Stand der Technik sichern.
23
// + Der Kunde ist darüber unterrichtet, dass der Lizenzgeber seine Daten im zur Vertragsdurchführung erforderlichen Umfang
24
// + und auf Grundlage der Datenschutzvorschriften erhebt, speichert, verarbeitet und, sofern notwendig, an Dritte übermittelt.
25
// + *) Die räumliche Nutzung bezieht sich nur auf den Einsatzort, nicht auf die Reichweite der programmierten Software.
26
// + #### ENDE DER NUTZUNGSBEDINGUNGEN ####'
27
// +  Hinweis: Informationen über erweiterte Nutzungsrechte (wie z.B. Nutzung für nicht-private Zwecke) sind auf Anfrage per Email an info(@)hisystems.de verfügbar.
28
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
29
// + Software LICENSING TERMS
30
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31
// + of HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland, Germany - the Licensor -
32
// + The Licensor grants the customer a non-exclusive license to use the microcontroller firmware of the Flight-Ctrl, Navi-Ctrl, BL-Ctrl, and MK3Mag hardware 
33
// + (the Software) exclusively for private purposes. The License is unrestricted with respect to time and territory*.
34
// + The Software may only be used with the Licensor's products.
35
// + The Software provided by the Licensor is protected by copyright. With respect to the relationship between the parties to this
36
// + agreement, all rights pertaining to the Software and other documents provided during the preparation and execution of this
37
// + agreement shall be the property of the Licensor.
38
// + The information contained in the Software copyright notices, trademarks, other legal reservations, serial numbers and other
39
// + features that can be used to identify the program may not be altered or defaced by the customer.
40
// + The customer shall be responsible for taking reasonable precautions
41
// + for the safe use of the Software. The customer shall test the Software thoroughly regarding its suitability for the
42
// + intended purpose before implementing it for actual operation. The Licensor's liability shall be limited to the extent of typical and
43
// + foreseeable damage to the extent permitted by law, notwithstanding statutory liability for bodily injury and product
44
// + liability. However, the Licensor shall be entitled to the defense of contributory negligence.
45
// + The customer will take adequate precautions in the case, that the software is not working properly. The customer will test
46
// + the software for his purpose before any operational usage. The customer will backup his data before using the software.
47
// + The customer understands that the Licensor collects, stores and processes, and, where required, forwards, customer data
48
// + to third parties to the extent necessary for executing the agreement, subject to applicable data protection and privacy regulations.
49
// + *) The territory aspect only refers to the place where the Software is used, not its programmed range.
50
// + #### END OF LICENSING TERMS ####
51
// + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de.
52
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1484 killagreg 53
#include "jetimenu.h"
54
#include "libfc.h"
55
#include "printf_P.h"
56
#include "main.h"
57
#include "spi.h"
1500 killagreg 58
#include "capacity.h"
1930 holgerb 59
#include "hottmenu.h"
1484 killagreg 60
 
61
#define JETIBOX_KEY_RIGHT       0x1F
62
#define JETIBOX_KEY_UP          0x2F
63
#define JETIBOX_KEY_DOWN        0x4F
64
#define JETIBOX_KEY_LEFT        0x8F
65
#define JETIBOX_KEY_NONE        0x0F
66
#define JETIBOX_KEY_UNDEF       0x00
67
 
68
#define JetiBox_printfxy(x,y,format, args...)  { LIBFC_JetiBox_SetPos(y * 16 + x); _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);}
69
#define JetiBox_printf(format, args...)        {  _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);}
70
 
2537 holgerb 71
unsigned char JumpToMenu = 0xff;
72
 
1484 killagreg 73
// -----------------------------------------------------------
74
// the menu functions
75
// -----------------------------------------------------------
1517 killagreg 76
void Menu_Status(uint8_t key)
77
{                                               //0123456789ABCDEF
2030 holgerb 78
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1512 holgerb 79
        JetiBox_printfxy(0,0,"%2i.%1iV",UBat/10, UBat%10);
80
        if(NaviDataOkay)
1484 killagreg 81
        {
2482 holgerb 82
                JetiBox_printfxy(6,0,"%3d%c %3dm%c",CompassCorrected, 0xDF, GPSInfo.HomeDistance/10,NC_GPS_ModeCharacter);
1484 killagreg 83
        }
1517 killagreg 84
        else
85
        {
2482 holgerb 86
                JetiBox_printfxy(6,0,"Status    ");
1517 killagreg 87
        }
1930 holgerb 88
 
89
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
90
        if(NC_ErrorCode)
91
        {
92
         static unsigned int timer;
93
         static char toggle = 1;
94
 
95
         if(CheckDelay(timer)) { if(toggle) toggle = 0; else toggle = 1; timer = SetDelay(1500);};
96
     if(toggle)
97
          {
98
       LIBFC_JetiBox_SetPos(0);
99
           _printf_P(&LIBFC_JetiBox_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0);
100
          }
101
          else
102
          {
103
           JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode);
2327 holgerb 104
//         if(MotorenEin) JetiBeep = 'O'; 
1930 holgerb 105
          }
106
        }
2344 holgerb 107
        else
2614 holgerb 108
        if(Partner_ErrorCode)
109
        {
110
         static unsigned int timer;
111
         static char toggle = 1;
112
 
113
         if(CheckDelay(timer)) { if(toggle) toggle = 0; else toggle = 1; timer = SetDelay(1500);};
114
     if(toggle)
115
          {
116
       LIBFC_JetiBox_SetPos(0);
117
           _printf_P(&LIBFC_JetiBox_Putchar, NC_ERROR_TEXT[Partner_ErrorCode] , 0);
118
          }
119
          else
120
          {
121
           if(IamMaster == SLAVE) JetiBox_printfxy(6,0,"MA-ERR:%2d ",Partner_ErrorCode)
122
           else JetiBox_printfxy(6,0,"SL-ERR:%2d ",Partner_ErrorCode);
123
//         if(MotorenEin) JetiBeep = 'O'; 
124
          }
125
        }
126
        else
2482 holgerb 127
         if(NC_To_FC_Flags & NC_TO_FC_SIMULATION_ACTIVE)
128
         {
129
           JetiBox_printfxy(6,0,"SIMULATION");
130
         }
131
        else
2345 holgerb 132
        if(ShowSettingNameTime)
2344 holgerb 133
        {
134
         LIBFC_JetiBox_Clear();
2482 holgerb 135
         JetiBox_printfxy(0,0,"Set%d:%s",ActiveParamSet,EE_Parameter.Name);
136
         if(FC_StatusFlags3 & FC_STATUS3_BOAT) JetiBox_printfxy(0,1,"(Boat-Mode)");
2344 holgerb 137
         return; // nichts weiter ausgeben
138
        }
139
 
1930 holgerb 140
#else
2327 holgerb 141
        if(NC_ErrorCode) { JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); if(MotorenEin) JetiBeep = 'S';};
1930 holgerb 142
#endif
1591 holgerb 143
        JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60);
1916 holgerb 144
        if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG)
1517 killagreg 145
        {
1591 holgerb 146
                JetiBox_printfxy(10,1,"%4im%c", (int16_t)(HoehenWert/100),VarioCharacter);
1517 killagreg 147
        }
2533 holgerb 148
        if(FC_StatusFlags3 & FC_STATUS3_REDUNDANCE_AKTIVE) JetiBox_printfxy(10,1,"R");
2437 holgerb 149
 
2030 holgerb 150
#endif
1517 killagreg 151
}
1512 holgerb 152
 
1705 holgerb 153
 
1693 holgerb 154
void Menu_Temperature(uint8_t key)
1517 killagreg 155
{                       //0123456789ABCDEF
2030 holgerb 156
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1687 holgerb 157
  JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature);
1693 holgerb 158
  JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature);
1690 holgerb 159
  if(RequiredMotors <= 4)
160
        {
161
         JetiBox_printfxy(0,1,"Temperatures    ");
162
    }
163
        else
164
    if(RequiredMotors <= 6)
165
        {
166
         JetiBox_printfxy(8,1,"\%cC     ",0xdf);
167
        }
1692 holgerb 168
 
2030 holgerb 169
#endif
1484 killagreg 170
}
1517 killagreg 171
 
172
void Menu_Battery(uint8_t key)
1500 killagreg 173
{                       //0123456789ABCDEF
2030 holgerb 174
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1972 holgerb 175
        JetiBox_printfxy(0,0,"%2i.%1iV %3i.%1iA", UBat/10, UBat%10, Capacity.ActualCurrent/10, Capacity.ActualCurrent%10);
1529 killagreg 176
        JetiBox_printfxy(0,1,"%4iW %6imAh",Capacity.ActualPower, Capacity.UsedCapacity);
2030 holgerb 177
#endif
1500 killagreg 178
}
179
 
1972 holgerb 180
void Magnet_Values(uint8_t key)
181
{                       //0123456789ABCDEF
2030 holgerb 182
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1972 holgerb 183
        JetiBox_printfxy(0,0,"Magnet:%3i%% %3i%c",EarthMagneticField, KompassValue,0xDF);
184
        JetiBox_printfxy(0,1,"Incli.:%3i%c (%i) ",EarthMagneticInclination, 0xDF,EarthMagneticInclinationTheoretic);
2030 holgerb 185
#endif
1972 holgerb 186
}
1680 holgerb 187
 
1972 holgerb 188
 
2418 holgerb 189
void Menu_WPL_A1(uint8_t key)
190
{                       //0123456789ABCDEF
191
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
192
        JetiBox_printfxy(0,0,"Load Waypoints");
2420 holgerb 193
        JetiBox_printfxy(0,1,"(Fixed)      ");
2418 holgerb 194
#endif
195
}
196
 
197
void Menu_WPL_R1(uint8_t key)
198
{                       //0123456789ABCDEF
199
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
200
        JetiBox_printfxy(0,0,"Load Waypoints");
201
        JetiBox_printfxy(0,1,"(Relative)   ");
202
#endif
203
}
204
 
2440 holgerb 205
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
2439 holgerb 206
void Menu_POINT_LD(uint8_t key)
207
{                       //0123456789ABCDEF
208
        JetiBox_printfxy(0,0,"Load singl.Point");
209
//      JetiBox_printfxy(0,1,"(Fixed)      ");
2440 holgerb 210
}
2439 holgerb 211
#endif
212
 
2440 holgerb 213
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
2439 holgerb 214
void Menu_POINT_SV(uint8_t key)
215
{                       //0123456789ABCDEF
216
        JetiBox_printfxy(0,0,"Save singl.Point");
217
//      JetiBox_printfxy(0,1,"(Relative)   ");
2440 holgerb 218
}
2537 holgerb 219
 
220
void Menu_AccCal_Ask(uint8_t key)
221
{                       //0123456789ABCDEF
222
        JetiBox_printfxy(0,0,"ACC calibration");
223
//      JetiBox_printfxy(0,1,"(Relative)   ");
224
}
225
 
226
void Menu_AccCal(uint8_t key)
227
{
228
 static unsigned char changed = 0;
229
                                                //0123456789ABCDEF
230
        JetiBox_printfxy(0,0,"ACC calibration");
231
 
232
        if((FC_StatusFlags & FC_STATUS_MOTOR_RUN) && ((NC_GPS_ModeCharacter == ' ') || (NC_GPS_ModeCharacter == '/') || (NC_GPS_ModeCharacter == '-')))
233
         {
234
          if(!EE_Parameter.Driftkomp) EE_Parameter.Driftkomp = 6; // enables the Gyro-Drift compensation to make sure that a litlte calibration error won't effect the attitude                                   
235
          JetiBox_printfxy(0,0,"ACC  N=%3i R=%3i",NeutralAccX,NeutralAccY);
236
          if(ChannelNick || ChannelRoll)
237
                                        JetiBox_printfxy(0,1,"Stick! (%i/%i)",ChannelNick,ChannelRoll)
238
          else                             //0123456789ABCDEF
2540 holgerb 239
          if(changed)   JetiBox_printfxy(0,1,"land to save    ")
2537 holgerb 240
          else                  JetiBox_printfxy(0,1,"use keys now    ")
241
 
242
          if(key== JETIBOX_KEY_UP   )  {NeutralAccX++;JetiBeep=130; changed = 1;}
243
          if(key== JETIBOX_KEY_DOWN )  {NeutralAccX--;JetiBeep=130; changed = 1;}
244
          if(key== JETIBOX_KEY_RIGHT ) {NeutralAccY++;JetiBeep=130; changed = 1;}
245
          if(key== JETIBOX_KEY_LEFT)   {NeutralAccY--;JetiBeep=130; changed = 1;}
246
    }
247
         else
248
         {
249
          if(!(FC_StatusFlags & FC_STATUS_MOTOR_RUN))    // motors are off 
250
                 {
251
             if(key == JETIBOX_KEY_LEFT) { JumpToMenu = 0; changed = 0; }// Exit
252
 
253
                 if(changed == 0) JetiBox_printfxy(0,1,"Fly with GPS off")
254
                 else
255
                 if(changed == 1)
256
                   {
2540 holgerb 257
                          JetiBox_printfxy(0,1,"       save -->")
2537 holgerb 258
                    if(key== JETIBOX_KEY_RIGHT)
259
                         {
260
                          StoreNeutralToEeprom();
261
                          JetiBeep = 130;
262
                          changed = 2;
263
                         }
264
                  }
265
                 else
266
                 if(changed == 2)
267
                   {
268
                          JetiBox_printfxy(0,1," values stored  ");
269
           }
270
           }                        //0123456789ABCDEF
271
           else JetiBox_printfxy(0,1,"switch GPS off  ")
272
         }  
273
//      JetiBox_printfxy(0,1,"(Relative)   ");
274
}
2439 holgerb 275
#endif
276
 
2440 holgerb 277
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
2439 holgerb 278
void Menu_POINT_SV2(uint8_t key)
279
{                       //0123456789ABCDEF
2561 holgerb 280
static unsigned char load_waypoint_tmp = 0, changed, hyterese = 1;
281
static int delay;
2439 holgerb 282
//  if(WPL_Name[0] == 0) JetiBox_printfxy(0,0,"Relative WPs ")
283
//  else JetiBox_printfxy(0,0,"Rel:%s",WPL_Name);
284
  JetiBox_printfxy(0,0,"Save Point:");
285
 
286
  if(NaviData_MaxWpListIndex == 0) JetiBox_printfxy(0,1,"no SD-Card")
287
  else
288
  if(GPSInfo.SatFix != SATFIX_3D) JetiBox_printfxy(0,1,"no GPS-Fix")
289
  else
290
  {
2561 holgerb 291
        if(load_waypoint_tmp)   JetiBox_printfxy(11,0,"%2d",load_waypoint_tmp)
292
        else JetiBox_printfxy(11,0,"--");
2439 holgerb 293
 
294
//      if(NaviData_WaypointNumber)     JetiBox_printfxy(8,1,"%2d/%d ",NaviData_WaypointIndex,NaviData_WaypointNumber)
295
//      else JetiBox_printfxy(8,1,"--/--")
296
        JetiBox_printfxy(0,1,"Dir:%3d Alt:%3dm",CompassCorrected,(int16_t)(HoehenWert/100))
297
 
298
    if(changed)         JetiBox_printfxy(14,0,"->")
299
        else            JetiBox_printfxy(14,0,"  ");
300
 
301
        if(key == JETIBOX_KEY_UP && load_waypoint_tmp < NaviData_MaxWpListIndex) { load_waypoint_tmp++; changed = 1;}
302
        if(key == JETIBOX_KEY_DOWN && load_waypoint_tmp > 1) { load_waypoint_tmp--; changed = 1; }
303
 
304
        if(key == JETIBOX_KEY_RIGHT && load_waypoint_tmp)
305
        {
306
         ToNC_Store_SingePoint = load_waypoint_tmp;
307
         changed = 0;
308
        }
2561 holgerb 309
 
2554 holgerb 310
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
311
// Bedienung per Taster am Sender
2572 holgerb 312
  if(PPM_in[EE_Parameter.MenuKeyChannel] > 50)  // 
2554 holgerb 313
   {
2561 holgerb 314
    hyterese = 2;
315
    if(CheckDelay(delay)) { load_waypoint_tmp = 0; hyterese = 1;}
316
   }
317
  else
2572 holgerb 318
  if(PPM_in[EE_Parameter.MenuKeyChannel] < -50)  
2561 holgerb 319
   {
320
        delay = SetDelay(2500);
321
        if(hyterese == 2 && (load_waypoint_tmp < NaviData_MaxWpListIndex))
2554 holgerb 322
         {
323
          load_waypoint_tmp++;
324
          ToNC_Store_SingePoint = load_waypoint_tmp;
325
          changed = 0;
2561 holgerb 326
//        JetiBeep = 'A'; // "MikroKopter"
2554 holgerb 327
         }
328
    hyterese = 0;
329
   }
330
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2439 holgerb 331
  }
2440 holgerb 332
}
2439 holgerb 333
#endif
334
 
2440 holgerb 335
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
2439 holgerb 336
void Menu_POINT_LD2(uint8_t key)
337
{                       //0123456789ABCDEF
2561 holgerb 338
static unsigned char load_waypoint_tmp = 0, changed, hyterese = 1;
339
static int delay;  
2439 holgerb 340
//  if(WPL_Name[0] == 0) JetiBox_printfxy(0,0,"FIX Waypoints")
341
//  else JetiBox_printfxy(0,0,"FIX:%s",WPL_Name);
342
  JetiBox_printfxy(0,0,"Load Point")
343
 
344
  if(NaviData_MaxWpListIndex == 0) JetiBox_printfxy(0,1,"no SD-Card")
345
  else
346
  {
2561 holgerb 347
        if(load_waypoint_tmp)   JetiBox_printfxy(11,0,"%2d",load_waypoint_tmp)
348
        else JetiBox_printfxy(11,0,"--");
2439 holgerb 349
 
350
        if(NaviData_WaypointNumber)     JetiBox_printfxy(0,1,"Dist:%3d Alt:%3d ",NaviData_TargetDistance,(int16_t)(FromNC_AltitudeSetpoint/100))
351
        else JetiBox_printfxy(8,1,"                ");
352
 
353
    if(changed)         JetiBox_printfxy(14,0,"->")
354
        else            JetiBox_printfxy(14,0,"  ");
355
 
356
        if(key == JETIBOX_KEY_UP && load_waypoint_tmp < NaviData_MaxWpListIndex) { load_waypoint_tmp++; changed = 1;}
357
        if(key == JETIBOX_KEY_DOWN && load_waypoint_tmp > 1) { load_waypoint_tmp--; changed = 1; }
358
 
359
        if(key == JETIBOX_KEY_RIGHT && load_waypoint_tmp)
360
        {
361
         ToNC_Load_SingePoint = load_waypoint_tmp;
362
         changed = 0;
363
        }
2554 holgerb 364
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
365
// Bedienung per Taster am Sender
2572 holgerb 366
  if(PPM_in[EE_Parameter.MenuKeyChannel] > 50)  // 
2554 holgerb 367
   {
2561 holgerb 368
    hyterese = 2;
369
    if(CheckDelay(delay)) { load_waypoint_tmp = 0; hyterese = 1;}
370
   }
371
  else
2572 holgerb 372
  if(PPM_in[EE_Parameter.MenuKeyChannel] < -50)  
2561 holgerb 373
   {
374
        delay = SetDelay(2500);
375
        if(hyterese == 2 && (load_waypoint_tmp < NaviData_MaxWpListIndex))
2554 holgerb 376
         {
377
          load_waypoint_tmp++;
378
          ToNC_Load_SingePoint = load_waypoint_tmp;
379
          changed = 0;
2561 holgerb 380
//        JetiBeep = 'A'; // "MikroKopter"
2554 holgerb 381
         }
382
    hyterese = 0;
383
   }
384
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2439 holgerb 385
  }
2440 holgerb 386
}
2439 holgerb 387
#endif
388
 
389
 
2418 holgerb 390
void Menu_WPL_A2(uint8_t key)
391
{                       //0123456789ABCDEF
392
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
2420 holgerb 393
static unsigned char load_waypoint_tmp = 1, changed;
2424 holgerb 394
 
395
  if(WPL_Name[0] == 0) JetiBox_printfxy(0,0,"FIX Waypoints")
396
  else JetiBox_printfxy(0,0,"FIX:%s",WPL_Name);
2418 holgerb 397
 
2420 holgerb 398
  if(NaviData_MaxWpListIndex == 0) JetiBox_printfxy(0,1,"no SD-Card")
399
  else
400
  {
401
        JetiBox_printfxy(0,1,"#%2d WP:",load_waypoint_tmp);
402
        if(NaviData_WaypointNumber)     JetiBox_printfxy(8,1,"%2d/%d ",NaviData_WaypointIndex,NaviData_WaypointNumber)
403
        else JetiBox_printfxy(8,1,"--/--")
404
 
2418 holgerb 405
    if(changed)         JetiBox_printfxy(14,1,"->")
406
        else            JetiBox_printfxy(14,1,"  ");
407
 
2420 holgerb 408
        if(key == JETIBOX_KEY_UP && load_waypoint_tmp < NaviData_MaxWpListIndex) { load_waypoint_tmp++; changed = 1;}
409
        if(key == JETIBOX_KEY_DOWN && load_waypoint_tmp > 1) { load_waypoint_tmp--; changed = 1; }
2418 holgerb 410
 
411
        if(key == JETIBOX_KEY_RIGHT && load_waypoint_tmp)
412
        {
413
         ToNC_Load_WP_List = load_waypoint_tmp;
414
         changed = 0;
415
        }
2420 holgerb 416
  }
2418 holgerb 417
#endif
418
}
419
 
420
void Menu_WPL_R2(uint8_t key)
421
{                       //0123456789ABCDEF
422
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
2420 holgerb 423
static unsigned char load_waypoint_tmp = 1, changed;
2418 holgerb 424
 
2425 holgerb 425
  if(WPL_Name[0] == 0) JetiBox_printfxy(0,0,"Relative WPs ")
2424 holgerb 426
  else JetiBox_printfxy(0,0,"Rel:%s",WPL_Name);
427
 
2420 holgerb 428
  if(NaviData_MaxWpListIndex == 0) JetiBox_printfxy(0,1,"no SD-Card")
429
  else
2425 holgerb 430
  if(GPSInfo.SatFix != SATFIX_3D) JetiBox_printfxy(0,1,"no GPS-Fix")
431
  else
2420 holgerb 432
  {
433
        JetiBox_printfxy(0,1,"#%2d WPs:",load_waypoint_tmp);
434
        if(NaviData_WaypointNumber)     JetiBox_printfxy(8,1,"%2d/%d ",NaviData_WaypointIndex,NaviData_WaypointNumber)
435
        else JetiBox_printfxy(8,1,"--/--")
2418 holgerb 436
 
437
    if(changed)         JetiBox_printfxy(14,1,"->")
438
        else            JetiBox_printfxy(14,1,"  ");
439
 
2420 holgerb 440
        if(key == JETIBOX_KEY_UP && load_waypoint_tmp < NaviData_MaxWpListIndex) { load_waypoint_tmp++; changed = 1;}
441
        if(key == JETIBOX_KEY_DOWN && load_waypoint_tmp > 1) { load_waypoint_tmp--; changed = 1; }
2418 holgerb 442
 
443
        if(key == JETIBOX_KEY_RIGHT && load_waypoint_tmp)
444
        {
445
         ToNC_Load_WP_List = load_waypoint_tmp | 0x80;
446
         changed = 0;
447
        }
2420 holgerb 448
  }
2418 holgerb 449
#endif
450
}
451
 
452
 
453
 
1517 killagreg 454
void Menu_PosInfo(uint8_t key)
1484 killagreg 455
{
2030 holgerb 456
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1484 killagreg 457
        if(NaviDataOkay)
458
        {
1690 holgerb 459
                JetiBox_printfxy(0,0,"%2um/s Sat:%d ",GPSInfo.Speed,GPSInfo.NumOfSats);
1517 killagreg 460
                switch (GPSInfo.SatFix)
461
                {
1690 holgerb 462
                        case SATFIX_3D:
463
                                JetiBox_printfxy(12,0,"  3D");
1517 killagreg 464
                                break;
1933 holgerb 465
//                      case SATFIX_2D:
466
//                      case SATFIX_NONE:
1517 killagreg 467
                        default:
1690 holgerb 468
                                JetiBox_printfxy(12,0,"NoFx");
1517 killagreg 469
                                break;
470
                }
471
                if(GPSInfo.Flags & FLAG_DIFFSOLN)
472
                {
1690 holgerb 473
                        JetiBox_printfxy(12,0,"DGPS");
1517 killagreg 474
                }
1923 holgerb 475
                JetiBox_printfxy(0,1,"Home:%3dm %3d%c %c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF,NC_GPS_ModeCharacter);
1484 killagreg 476
        }
477
        else
1517 killagreg 478
        {                     //0123456789ABCDEF
479
                JetiBox_printfxy(2,0,"No NaviCtrl!");
1484 killagreg 480
        }
2030 holgerb 481
#endif
1484 killagreg 482
}
483
 
1517 killagreg 484
 
1484 killagreg 485
// -----------------------------------------------------------
486
// the menu topology
487
// -----------------------------------------------------------
488
typedef void (*pFctMenu) (uint8_t);  // the menu item handler function pointer
489
 
490
typedef struct{
491
  int8_t left;
492
  int8_t right;
493
  int8_t up;
494
  int8_t down;
495
  pFctMenu pHandler;
496
} MENU_ENTRY;
497
 
498
 
499
// the menu navigation structure
1517 killagreg 500
/*                                              |
501
3 - 0 - 1 - 2 - 3 - 0
1484 killagreg 502
*/
503
 
504
const MENU_ENTRY JetiBox_Menu[] PROGMEM=
505
{ // l  r  u  d  pHandler
2030 holgerb 506
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
2440 holgerb 507
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
2537 holgerb 508
#define ACC_CAL  13
2439 holgerb 509
        {8, 1, 0, 0, &Menu_Status },    // 0
1693 holgerb 510
        {0, 2, 1, 1, &Menu_Temperature },       // 1
1517 killagreg 511
        {1, 3, 2, 2, &Menu_Battery },   // 2
1972 holgerb 512
        {2, 4, 3, 3, &Menu_PosInfo },   // 3
2542 holgerb 513
        {3, 5, 4,10, &Menu_WPL_A1 },    // 4
514
        {4, 6, 5,11, &Menu_WPL_R1 },    // 5
515
        {5, 7, 6,12, &Menu_POINT_LD},   // 6
516
        {6, 8, 7,13, &Menu_POINT_SV},   // 7
2537 holgerb 517
        {7, 9, 8, 8, &Magnet_Values },  // 8
518
        {8, 0, 9,14, &Menu_AccCal_Ask},// 9
2418 holgerb 519
 
2537 holgerb 520
        {4,10,10,10, &Menu_WPL_A2 },    // 10
521
        {5,11,11,11, &Menu_WPL_R2 },    // 11
522
        {6,12,12,12, &Menu_POINT_LD2},  // 12
523
        {7,13,13,13, &Menu_POINT_SV2},  // 13
524
 
525
        {14,14,14,14, &Menu_AccCal},    // 14 
2440 holgerb 526
#else
527
        {6, 1, 0, 0, &Menu_Status },    // 0
528
        {0, 2, 1, 1, &Menu_Temperature },       // 1
529
        {1, 3, 2, 2, &Menu_Battery },   // 2
530
        {2, 4, 3, 3, &Menu_PosInfo },   // 3
531
        {3, 5, 7, 7, &Menu_WPL_A1 },    // 4
532
        {4, 6, 8, 8, &Menu_WPL_R1 },    // 5
533
        {5, 0, 6, 6, &Magnet_Values },  // 6
534
 
535
        {4, 7, 7, 7, &Menu_WPL_A2 },    // 7
536
        {5, 8, 8, 8, &Menu_WPL_R2 },    // 8
537
#endif
2418 holgerb 538
 
2030 holgerb 539
#endif
1484 killagreg 540
};
541
 
542
// -----------------------------------------------------------
543
// Update display buffer
544
// -----------------------------------------------------------
1583 ingob 545
unsigned char JetiBox_Update(unsigned char key)
1484 killagreg 546
{
2030 holgerb 547
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1484 killagreg 548
        static uint8_t item = 0, last_item = 0; // the menu item
2418 holgerb 549
        static uint8_t updateDelay = 1 , last_key;
1484 killagreg 550
        // navigate within the menu by key action
551
        last_item = item;
552
        switch(key)
553
        {
554
                case JETIBOX_KEY_LEFT:
1972 holgerb 555
                        //if (item == 0) return (1);                                                                    // switch back to jeti expander menu
556
                        // else 
557
                         item = pgm_read_byte(&JetiBox_Menu[item].left);                //trigger to left menu item
1484 killagreg 558
                        break;
559
                case JETIBOX_KEY_RIGHT:
560
                        item = pgm_read_byte(&JetiBox_Menu[item].right);        //trigger to right menu item
561
                        break;
562
                case JETIBOX_KEY_UP:
563
                        item = pgm_read_byte(&JetiBox_Menu[item].up);           //trigger to up menu item
564
                        break;
565
                case JETIBOX_KEY_DOWN:
566
                        item = pgm_read_byte(&JetiBox_Menu[item].down);         //trigger to down menu item
567
                        break;
568
                default:
569
                        break;
570
        }
2537 holgerb 571
        if(JumpToMenu != 0xff) { item = JumpToMenu; JumpToMenu = 0xff;};
1484 killagreg 572
        // if the menu item has been changed, do not pass the key to the item handler
573
        // to avoid jumping over to items
574
        if(item != last_item) key = JETIBOX_KEY_UNDEF;
575
 
2448 holgerb 576
//      if((updateDelay++ & 0x01) || (key != last_key))
577
        if((updateDelay++ & 0x01) || (key != JETIBOX_KEY_NONE))
2182 ingob 578
        {      
2418 holgerb 579
                last_key = key;
2182 ingob 580
                LIBFC_JetiBox_Clear();
581
                //execute menu item handler
582
                ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key);
583
        }      
2030 holgerb 584
#endif
1583 ingob 585
        return (0);
1484 killagreg 586
}
587