Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2751 - 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
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53
#include "jetimenu.h"
54
#include "libfc.h"
55
#include "printf_P.h"
56
#include "main.h"
57
#include "spi.h"
58
#include "capacity.h"
59
#include "hottmenu.h"
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
 
71
unsigned char JumpToMenu = 0xff;
72
 
73
// -----------------------------------------------------------
74
// the menu functions
75
// -----------------------------------------------------------
76
void Menu_Status(uint8_t key)
77
{                                               //0123456789ABCDEF
78
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
79
        JetiBox_printfxy(0,0,"%2i.%1iV",UBat/10, UBat%10);
80
        if(NaviDataOkay)
81
        {
82
                JetiBox_printfxy(6,0,"%3d%c %3dm%c",CompassCorrected, 0xDF, GPSInfo.HomeDistance/10,NC_GPS_ModeCharacter);
83
        }
84
        else
85
        {
86
                JetiBox_printfxy(6,0,"Status    ");
87
        }
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);
104
//         if(MotorenEin) JetiBeep = 'O'; 
105
          }
106
        }
107
        else
108
         if(NC_To_FC_Flags & NC_TO_FC_SIMULATION_ACTIVE)
109
         {
110
           JetiBox_printfxy(6,0,"SIMULATION");
111
         }
112
        else
113
        if(ShowSettingNameTime)
114
        {
115
         LIBFC_JetiBox_Clear();
116
         JetiBox_printfxy(0,0,"Set%d:%s",ActiveParamSet,EE_Parameter.Name);
117
         if(FC_StatusFlags3 & FC_STATUS3_BOAT) JetiBox_printfxy(0,1,"(Boat-Mode)");
118
         return; // nichts weiter ausgeben
119
        }
120
 
121
#else
122
        if(NC_ErrorCode) { JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); if(MotorenEin) JetiBeep = 'S';};
123
#endif
124
        JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60);
125
        if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG)
126
        {
127
                JetiBox_printfxy(10,1,"%4im%c", (int16_t)(HoehenWert/100),VarioCharacter);
128
        }
129
        if(FC_StatusFlags3 & FC_STATUS3_REDUNDANCE_AKTIVE) JetiBox_printfxy(10,1,"R");
130
 
131
#endif
132
}
133
 
134
 
135
void Menu_Temperature(uint8_t key)
136
{                       //0123456789ABCDEF
137
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
138
  JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature);
139
  JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature);
140
  if(RequiredMotors <= 4)
141
        {
142
         JetiBox_printfxy(0,1,"Temperatures    ");
143
    }
144
        else
145
    if(RequiredMotors <= 6)
146
        {
147
         JetiBox_printfxy(8,1,"\%cC     ",0xdf);
148
        }
149
 
150
#endif
151
}
152
 
153
void Menu_Battery(uint8_t key)
154
{                       //0123456789ABCDEF
155
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
156
        JetiBox_printfxy(0,0,"%2i.%1iV %3i.%1iA", UBat/10, UBat%10, Capacity.ActualCurrent/10, Capacity.ActualCurrent%10);
157
        JetiBox_printfxy(0,1,"%4iW %6imAh",Capacity.ActualPower, Capacity.UsedCapacity);
158
#endif
159
}
160
 
161
void Magnet_Values(uint8_t key)
162
{                       //0123456789ABCDEF
163
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
164
        JetiBox_printfxy(0,0,"Magnet:%3i%% %3i%c",EarthMagneticField, KompassValue,0xDF);
165
        JetiBox_printfxy(0,1,"Incli.:%3i%c (%i) ",EarthMagneticInclination, 0xDF,EarthMagneticInclinationTheoretic);
166
#endif
167
}
168
 
169
 
170
void Menu_WPL_A1(uint8_t key)
171
{                       //0123456789ABCDEF
172
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
173
        JetiBox_printfxy(0,0,"Load Waypoints");
174
        JetiBox_printfxy(0,1,"(Fixed)      ");
175
#endif
176
}
177
 
178
void Menu_WPL_R1(uint8_t key)
179
{                       //0123456789ABCDEF
180
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
181
        JetiBox_printfxy(0,0,"Load Waypoints");
182
        JetiBox_printfxy(0,1,"(Relative)   ");
183
#endif
184
}
185
 
186
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
187
void Menu_POINT_LD(uint8_t key)
188
{                       //0123456789ABCDEF
189
        JetiBox_printfxy(0,0,"Load singl.Point");
190
//      JetiBox_printfxy(0,1,"(Fixed)      ");
191
}
192
#endif
193
 
194
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
195
void Menu_POINT_SV(uint8_t key)
196
{                       //0123456789ABCDEF
197
        JetiBox_printfxy(0,0,"Save singl.Point");
198
//      JetiBox_printfxy(0,1,"(Relative)   ");
199
}
200
 
201
void Menu_AccCal_Ask(uint8_t key)
202
{                       //0123456789ABCDEF
203
        JetiBox_printfxy(0,0,"ACC calibration");
204
//      JetiBox_printfxy(0,1,"(Relative)   ");
205
}
206
 
207
void Menu_AccCal(uint8_t key)
208
{
209
 static unsigned char changed = 0;
210
                                                //0123456789ABCDEF
211
        JetiBox_printfxy(0,0,"ACC calibration");
212
 
213
        if((FC_StatusFlags & FC_STATUS_MOTOR_RUN) && ((NC_GPS_ModeCharacter == ' ') || (NC_GPS_ModeCharacter == '/') || (NC_GPS_ModeCharacter == '-')))
214
         {
215
          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                                   
216
          JetiBox_printfxy(0,0,"ACC  N=%3i R=%3i",NeutralAccX,NeutralAccY);
217
          if(ChannelNick || ChannelRoll)
218
                                        JetiBox_printfxy(0,1,"Stick! (%i/%i)",ChannelNick,ChannelRoll)
219
          else                             //0123456789ABCDEF
220
          if(changed)   JetiBox_printfxy(0,1,"land to save    ")
221
          else                  JetiBox_printfxy(0,1,"use keys now    ")
222
 
223
          if(key== JETIBOX_KEY_UP   )  {NeutralAccX++;JetiBeep=130; changed = 1;}
224
          if(key== JETIBOX_KEY_DOWN )  {NeutralAccX--;JetiBeep=130; changed = 1;}
225
          if(key== JETIBOX_KEY_RIGHT ) {NeutralAccY++;JetiBeep=130; changed = 1;}
226
          if(key== JETIBOX_KEY_LEFT)   {NeutralAccY--;JetiBeep=130; changed = 1;}
227
    }
228
         else
229
         {
230
          if(!(FC_StatusFlags & FC_STATUS_MOTOR_RUN))    // motors are off 
231
                 {
232
             if(key == JETIBOX_KEY_LEFT) { JumpToMenu = 0; changed = 0; }// Exit
233
 
234
                 if(changed == 0) JetiBox_printfxy(0,1,"Fly with GPS off")
235
                 else
236
                 if(changed == 1)
237
                   {
238
                          JetiBox_printfxy(0,1,"       save -->")
239
                    if(key== JETIBOX_KEY_RIGHT)
240
                         {
241
                          StoreNeutralToEeprom();
242
                          JetiBeep = 130;
243
                          changed = 2;
244
                         }
245
                  }
246
                 else
247
                 if(changed == 2)
248
                   {
249
                          JetiBox_printfxy(0,1," values stored  ");
250
           }
251
           }                        //0123456789ABCDEF
252
           else JetiBox_printfxy(0,1,"switch GPS off  ")
253
         }  
254
//      JetiBox_printfxy(0,1,"(Relative)   ");
255
}
256
#endif
257
 
258
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
259
void Menu_POINT_SV2(uint8_t key)
260
{                       //0123456789ABCDEF
261
static unsigned char load_waypoint_tmp = 0, changed, hyterese = 1;
262
static int delay;
263
//  if(WPL_Name[0] == 0) JetiBox_printfxy(0,0,"Relative WPs ")
264
//  else JetiBox_printfxy(0,0,"Rel:%s",WPL_Name);
265
  JetiBox_printfxy(0,0,"Save Point:");
266
 
267
  if(NaviData_MaxWpListIndex == 0) JetiBox_printfxy(0,1,"no SD-Card")
268
  else
269
  if(GPSInfo.SatFix != SATFIX_3D) JetiBox_printfxy(0,1,"no GPS-Fix")
270
  else
271
  {
272
        if(load_waypoint_tmp)   JetiBox_printfxy(11,0,"%2d",load_waypoint_tmp)
273
        else JetiBox_printfxy(11,0,"--");
274
 
275
//      if(NaviData_WaypointNumber)     JetiBox_printfxy(8,1,"%2d/%d ",NaviData_WaypointIndex,NaviData_WaypointNumber)
276
//      else JetiBox_printfxy(8,1,"--/--")
277
        JetiBox_printfxy(0,1,"Dir:%3d Alt:%3dm",CompassCorrected,(int16_t)(HoehenWert/100))
278
 
279
    if(changed)         JetiBox_printfxy(14,0,"->")
280
        else            JetiBox_printfxy(14,0,"  ");
281
 
282
        if(key == JETIBOX_KEY_UP && load_waypoint_tmp < NaviData_MaxWpListIndex) { load_waypoint_tmp++; changed = 1;}
283
        if(key == JETIBOX_KEY_DOWN && load_waypoint_tmp > 1) { load_waypoint_tmp--; changed = 1; }
284
 
285
        if(key == JETIBOX_KEY_RIGHT && load_waypoint_tmp)
286
        {
287
         ToNC_Store_SingePoint = load_waypoint_tmp;
288
         changed = 0;
289
        }
290
 
291
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
292
// Bedienung per Taster am Sender
293
  if(PPM_in[EE_Parameter.MenuKeyChannel] > 50)  // 
294
   {
295
    hyterese = 2;
296
    if(CheckDelay(delay)) { load_waypoint_tmp = 0; hyterese = 1;}
297
   }
298
  else
299
  if(PPM_in[EE_Parameter.MenuKeyChannel] < -50)  
300
   {
301
        delay = SetDelay(2500);
302
        if(hyterese == 2 && (load_waypoint_tmp < NaviData_MaxWpListIndex))
303
         {
304
          load_waypoint_tmp++;
305
          ToNC_Store_SingePoint = load_waypoint_tmp;
306
          changed = 0;
307
//        JetiBeep = 'A'; // "MikroKopter"
308
         }
309
    hyterese = 0;
310
   }
311
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
312
  }
313
}
314
#endif
315
 
316
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
317
void Menu_POINT_LD2(uint8_t key)
318
{                       //0123456789ABCDEF
319
static unsigned char load_waypoint_tmp = 0, changed, hyterese = 1;
320
static int delay;  
321
//  if(WPL_Name[0] == 0) JetiBox_printfxy(0,0,"FIX Waypoints")
322
//  else JetiBox_printfxy(0,0,"FIX:%s",WPL_Name);
323
  JetiBox_printfxy(0,0,"Load Point")
324
 
325
  if(NaviData_MaxWpListIndex == 0) JetiBox_printfxy(0,1,"no SD-Card")
326
  else
327
  {
328
        if(load_waypoint_tmp)   JetiBox_printfxy(11,0,"%2d",load_waypoint_tmp)
329
        else JetiBox_printfxy(11,0,"--");
330
 
331
        if(NaviData_WaypointNumber)     JetiBox_printfxy(0,1,"Dist:%3d Alt:%3d ",NaviData_TargetDistance,(int16_t)(FromNC_AltitudeSetpoint/100))
332
        else JetiBox_printfxy(8,1,"                ");
333
 
334
    if(changed)         JetiBox_printfxy(14,0,"->")
335
        else            JetiBox_printfxy(14,0,"  ");
336
 
337
        if(key == JETIBOX_KEY_UP && load_waypoint_tmp < NaviData_MaxWpListIndex) { load_waypoint_tmp++; changed = 1;}
338
        if(key == JETIBOX_KEY_DOWN && load_waypoint_tmp > 1) { load_waypoint_tmp--; changed = 1; }
339
 
340
        if(key == JETIBOX_KEY_RIGHT && load_waypoint_tmp)
341
        {
342
         ToNC_Load_SingePoint = load_waypoint_tmp;
343
         changed = 0;
344
        }
345
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
346
// Bedienung per Taster am Sender
347
  if(PPM_in[EE_Parameter.MenuKeyChannel] > 50)  // 
348
   {
349
    hyterese = 2;
350
    if(CheckDelay(delay)) { load_waypoint_tmp = 0; hyterese = 1;}
351
   }
352
  else
353
  if(PPM_in[EE_Parameter.MenuKeyChannel] < -50)  
354
   {
355
        delay = SetDelay(2500);
356
        if(hyterese == 2 && (load_waypoint_tmp < NaviData_MaxWpListIndex))
357
         {
358
          load_waypoint_tmp++;
359
          ToNC_Load_SingePoint = load_waypoint_tmp;
360
          changed = 0;
361
//        JetiBeep = 'A'; // "MikroKopter"
362
         }
363
    hyterese = 0;
364
   }
365
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
366
  }
367
}
368
#endif
369
 
370
 
371
void Menu_WPL_A2(uint8_t key)
372
{                       //0123456789ABCDEF
373
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
374
static unsigned char load_waypoint_tmp = 1, changed;
375
 
376
  if(WPL_Name[0] == 0) JetiBox_printfxy(0,0,"FIX Waypoints")
377
  else JetiBox_printfxy(0,0,"FIX:%s",WPL_Name);
378
 
379
  if(NaviData_MaxWpListIndex == 0) JetiBox_printfxy(0,1,"no SD-Card")
380
  else
381
  {
382
        JetiBox_printfxy(0,1,"#%2d WP:",load_waypoint_tmp);
383
        if(NaviData_WaypointNumber)     JetiBox_printfxy(8,1,"%2d/%d ",NaviData_WaypointIndex,NaviData_WaypointNumber)
384
        else JetiBox_printfxy(8,1,"--/--")
385
 
386
    if(changed)         JetiBox_printfxy(14,1,"->")
387
        else            JetiBox_printfxy(14,1,"  ");
388
 
389
        if(key == JETIBOX_KEY_UP && load_waypoint_tmp < NaviData_MaxWpListIndex) { load_waypoint_tmp++; changed = 1;}
390
        if(key == JETIBOX_KEY_DOWN && load_waypoint_tmp > 1) { load_waypoint_tmp--; changed = 1; }
391
 
392
        if(key == JETIBOX_KEY_RIGHT && load_waypoint_tmp)
393
        {
394
         ToNC_Load_WP_List = load_waypoint_tmp;
395
         changed = 0;
396
        }
397
  }
398
#endif
399
}
400
 
401
void Menu_WPL_R2(uint8_t key)
402
{                       //0123456789ABCDEF
403
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
404
static unsigned char load_waypoint_tmp = 1, changed;
405
 
406
  if(WPL_Name[0] == 0) JetiBox_printfxy(0,0,"Relative WPs ")
407
  else JetiBox_printfxy(0,0,"Rel:%s",WPL_Name);
408
 
409
  if(NaviData_MaxWpListIndex == 0) JetiBox_printfxy(0,1,"no SD-Card")
410
  else
411
  if(GPSInfo.SatFix != SATFIX_3D) JetiBox_printfxy(0,1,"no GPS-Fix")
412
  else
413
  {
414
        JetiBox_printfxy(0,1,"#%2d WPs:",load_waypoint_tmp);
415
        if(NaviData_WaypointNumber)     JetiBox_printfxy(8,1,"%2d/%d ",NaviData_WaypointIndex,NaviData_WaypointNumber)
416
        else JetiBox_printfxy(8,1,"--/--")
417
 
418
    if(changed)         JetiBox_printfxy(14,1,"->")
419
        else            JetiBox_printfxy(14,1,"  ");
420
 
421
        if(key == JETIBOX_KEY_UP && load_waypoint_tmp < NaviData_MaxWpListIndex) { load_waypoint_tmp++; changed = 1;}
422
        if(key == JETIBOX_KEY_DOWN && load_waypoint_tmp > 1) { load_waypoint_tmp--; changed = 1; }
423
 
424
        if(key == JETIBOX_KEY_RIGHT && load_waypoint_tmp)
425
        {
426
         ToNC_Load_WP_List = load_waypoint_tmp | 0x80;
427
         changed = 0;
428
        }
429
  }
430
#endif
431
}
432
 
433
 
434
 
435
void Menu_PosInfo(uint8_t key)
436
{
437
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
438
        if(NaviDataOkay)
439
        {
440
                JetiBox_printfxy(0,0,"%2um/s Sat:%d ",GPSInfo.Speed,GPSInfo.NumOfSats);
441
                switch (GPSInfo.SatFix)
442
                {
443
                        case SATFIX_3D:
444
                                JetiBox_printfxy(12,0,"  3D");
445
                                break;
446
//                      case SATFIX_2D:
447
//                      case SATFIX_NONE:
448
                        default:
449
                                JetiBox_printfxy(12,0,"NoFx");
450
                                break;
451
                }
452
                if(GPSInfo.Flags & FLAG_DIFFSOLN)
453
                {
454
                        JetiBox_printfxy(12,0,"DGPS");
455
                }
456
                JetiBox_printfxy(0,1,"Home:%3dm %3d%c %c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF,NC_GPS_ModeCharacter);
457
        }
458
        else
459
        {                     //0123456789ABCDEF
460
                JetiBox_printfxy(2,0,"No NaviCtrl!");
461
        }
462
#endif
463
}
464
 
465
 
466
// -----------------------------------------------------------
467
// the menu topology
468
// -----------------------------------------------------------
469
typedef void (*pFctMenu) (uint8_t);  // the menu item handler function pointer
470
 
471
typedef struct{
472
  int8_t left;
473
  int8_t right;
474
  int8_t up;
475
  int8_t down;
476
  pFctMenu pHandler;
477
} MENU_ENTRY;
478
 
479
 
480
// the menu navigation structure
481
/*                                              |
482
3 - 0 - 1 - 2 - 3 - 0
483
*/
484
 
485
const MENU_ENTRY JetiBox_Menu[] PROGMEM=
486
{ // l  r  u  d  pHandler
487
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
488
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
489
#define ACC_CAL  13
490
        {8, 1, 0, 0, &Menu_Status },    // 0
491
        {0, 2, 1, 1, &Menu_Temperature },       // 1
492
        {1, 3, 2, 2, &Menu_Battery },   // 2
493
        {2, 4, 3, 3, &Menu_PosInfo },   // 3
494
        {3, 5, 4,10, &Menu_WPL_A1 },    // 4
495
        {4, 6, 5,11, &Menu_WPL_R1 },    // 5
496
        {5, 7, 6,12, &Menu_POINT_LD},   // 6
497
        {6, 8, 7,13, &Menu_POINT_SV},   // 7
498
        {7, 9, 8, 8, &Magnet_Values },  // 8
499
        {8, 0, 9,14, &Menu_AccCal_Ask},// 9
500
 
501
        {4,10,10,10, &Menu_WPL_A2 },    // 10
502
        {5,11,11,11, &Menu_WPL_R2 },    // 11
503
        {6,12,12,12, &Menu_POINT_LD2},  // 12
504
        {7,13,13,13, &Menu_POINT_SV2},  // 13
505
 
506
        {14,14,14,14, &Menu_AccCal},    // 14 
507
#else
508
        {6, 1, 0, 0, &Menu_Status },    // 0
509
        {0, 2, 1, 1, &Menu_Temperature },       // 1
510
        {1, 3, 2, 2, &Menu_Battery },   // 2
511
        {2, 4, 3, 3, &Menu_PosInfo },   // 3
512
        {3, 5, 7, 7, &Menu_WPL_A1 },    // 4
513
        {4, 6, 8, 8, &Menu_WPL_R1 },    // 5
514
        {5, 0, 6, 6, &Magnet_Values },  // 6
515
 
516
        {4, 7, 7, 7, &Menu_WPL_A2 },    // 7
517
        {5, 8, 8, 8, &Menu_WPL_R2 },    // 8
518
#endif
519
 
520
#endif
521
};
522
 
523
// -----------------------------------------------------------
524
// Update display buffer
525
// -----------------------------------------------------------
526
unsigned char JetiBox_Update(unsigned char key)
527
{
528
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
529
        static uint8_t item = 0, last_item = 0; // the menu item
530
        static uint8_t updateDelay = 1 , last_key;
531
        // navigate within the menu by key action
532
        last_item = item;
533
        switch(key)
534
        {
535
                case JETIBOX_KEY_LEFT:
536
                        //if (item == 0) return (1);                                                                    // switch back to jeti expander menu
537
                        // else 
538
                         item = pgm_read_byte(&JetiBox_Menu[item].left);                //trigger to left menu item
539
                        break;
540
                case JETIBOX_KEY_RIGHT:
541
                        item = pgm_read_byte(&JetiBox_Menu[item].right);        //trigger to right menu item
542
                        break;
543
                case JETIBOX_KEY_UP:
544
                        item = pgm_read_byte(&JetiBox_Menu[item].up);           //trigger to up menu item
545
                        break;
546
                case JETIBOX_KEY_DOWN:
547
                        item = pgm_read_byte(&JetiBox_Menu[item].down);         //trigger to down menu item
548
                        break;
549
                default:
550
                        break;
551
        }
552
        if(JumpToMenu != 0xff) { item = JumpToMenu; JumpToMenu = 0xff;};
553
        // if the menu item has been changed, do not pass the key to the item handler
554
        // to avoid jumping over to items
555
        if(item != last_item) key = JETIBOX_KEY_UNDEF;
556
 
557
//      if((updateDelay++ & 0x01) || (key != last_key))
558
        if((updateDelay++ & 0x01) || (key != JETIBOX_KEY_NONE))
559
        {      
560
                last_key = key;
561
                LIBFC_JetiBox_Clear();
562
                //execute menu item handler
563
                ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key);
564
        }      
565
#endif
566
        return (0);
567
}
568