Subversion Repositories FlightCtrl

Rev

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