Subversion Repositories FlightCtrl

Rev

Rev 2425 | Rev 2439 | 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
 
71
// -----------------------------------------------------------
72
// the menu functions
73
// -----------------------------------------------------------
1517 killagreg 74
void Menu_Status(uint8_t key)
75
{                                               //0123456789ABCDEF
2030 holgerb 76
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1512 holgerb 77
        JetiBox_printfxy(0,0,"%2i.%1iV",UBat/10, UBat%10);
78
        if(NaviDataOkay)
1484 killagreg 79
        {
2437 holgerb 80
                JetiBox_printfxy(6,0,"%3d%c %03dm%c",CompassCorrected, 0xDF, GPSInfo.HomeDistance/10,NC_GPS_ModeCharacter);
1484 killagreg 81
        }
1517 killagreg 82
        else
83
        {
1591 holgerb 84
                JetiBox_printfxy(6,0,"Status");
1517 killagreg 85
        }
1930 holgerb 86
 
87
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
88
        if(NC_ErrorCode)
89
        {
90
         static unsigned int timer;
91
         static char toggle = 1;
92
 
93
         if(CheckDelay(timer)) { if(toggle) toggle = 0; else toggle = 1; timer = SetDelay(1500);};
94
     if(toggle)
95
          {
96
       LIBFC_JetiBox_SetPos(0);
97
           _printf_P(&LIBFC_JetiBox_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0);
98
          }
99
          else
100
          {
101
           JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode);
2327 holgerb 102
//         if(MotorenEin) JetiBeep = 'O'; 
1930 holgerb 103
          }
104
        }
2344 holgerb 105
        else
2345 holgerb 106
        if(ShowSettingNameTime)
2344 holgerb 107
        {
108
         LIBFC_JetiBox_Clear();
109
         JetiBox_printfxy(0,1,"Set%d:%s  ",ActiveParamSet,EE_Parameter.Name);
110
         return; // nichts weiter ausgeben
111
        }
112
 
1930 holgerb 113
#else
2327 holgerb 114
        if(NC_ErrorCode) { JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); if(MotorenEin) JetiBeep = 'S';};
1930 holgerb 115
#endif
1591 holgerb 116
        JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60);
1916 holgerb 117
        if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG)
1517 killagreg 118
        {
1591 holgerb 119
                JetiBox_printfxy(10,1,"%4im%c", (int16_t)(HoehenWert/100),VarioCharacter);
1517 killagreg 120
        }
2437 holgerb 121
        if(RedundanceBlOperation) JetiBox_printfxy(10,1,"R");
122
 
2030 holgerb 123
#endif
1517 killagreg 124
}
1512 holgerb 125
 
1705 holgerb 126
 
1693 holgerb 127
void Menu_Temperature(uint8_t key)
1517 killagreg 128
{                       //0123456789ABCDEF
2030 holgerb 129
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1687 holgerb 130
  JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature);
1693 holgerb 131
  JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature);
1690 holgerb 132
  if(RequiredMotors <= 4)
133
        {
134
         JetiBox_printfxy(0,1,"Temperatures    ");
135
    }
136
        else
137
    if(RequiredMotors <= 6)
138
        {
139
         JetiBox_printfxy(8,1,"\%cC     ",0xdf);
140
        }
1692 holgerb 141
 
2030 holgerb 142
#endif
1484 killagreg 143
}
1517 killagreg 144
 
145
void Menu_Battery(uint8_t key)
1500 killagreg 146
{                       //0123456789ABCDEF
2030 holgerb 147
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1972 holgerb 148
        JetiBox_printfxy(0,0,"%2i.%1iV %3i.%1iA", UBat/10, UBat%10, Capacity.ActualCurrent/10, Capacity.ActualCurrent%10);
1529 killagreg 149
        JetiBox_printfxy(0,1,"%4iW %6imAh",Capacity.ActualPower, Capacity.UsedCapacity);
2030 holgerb 150
#endif
1500 killagreg 151
}
152
 
1972 holgerb 153
void Magnet_Values(uint8_t key)
154
{                       //0123456789ABCDEF
2030 holgerb 155
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1972 holgerb 156
        JetiBox_printfxy(0,0,"Magnet:%3i%% %3i%c",EarthMagneticField, KompassValue,0xDF);
157
        JetiBox_printfxy(0,1,"Incli.:%3i%c (%i) ",EarthMagneticInclination, 0xDF,EarthMagneticInclinationTheoretic);
2030 holgerb 158
#endif
1972 holgerb 159
}
1680 holgerb 160
 
1972 holgerb 161
 
2418 holgerb 162
void Menu_WPL_A1(uint8_t key)
163
{                       //0123456789ABCDEF
164
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
165
        JetiBox_printfxy(0,0,"Load Waypoints");
2420 holgerb 166
        JetiBox_printfxy(0,1,"(Fixed)      ");
2418 holgerb 167
#endif
168
}
169
 
170
void Menu_WPL_R1(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,"(Relative)   ");
175
#endif
176
}
177
 
178
void Menu_WPL_A2(uint8_t key)
179
{                       //0123456789ABCDEF
180
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
2420 holgerb 181
static unsigned char load_waypoint_tmp = 1, changed;
2424 holgerb 182
 
183
  if(WPL_Name[0] == 0) JetiBox_printfxy(0,0,"FIX Waypoints")
184
  else JetiBox_printfxy(0,0,"FIX:%s",WPL_Name);
2418 holgerb 185
 
2420 holgerb 186
  if(NaviData_MaxWpListIndex == 0) JetiBox_printfxy(0,1,"no SD-Card")
187
  else
188
  {
189
        JetiBox_printfxy(0,1,"#%2d WP:",load_waypoint_tmp);
190
        if(NaviData_WaypointNumber)     JetiBox_printfxy(8,1,"%2d/%d ",NaviData_WaypointIndex,NaviData_WaypointNumber)
191
        else JetiBox_printfxy(8,1,"--/--")
192
 
2418 holgerb 193
    if(changed)         JetiBox_printfxy(14,1,"->")
194
        else            JetiBox_printfxy(14,1,"  ");
195
 
2420 holgerb 196
        if(key == JETIBOX_KEY_UP && load_waypoint_tmp < NaviData_MaxWpListIndex) { load_waypoint_tmp++; changed = 1;}
197
        if(key == JETIBOX_KEY_DOWN && load_waypoint_tmp > 1) { load_waypoint_tmp--; changed = 1; }
2418 holgerb 198
 
199
        if(key == JETIBOX_KEY_RIGHT && load_waypoint_tmp)
200
        {
201
         ToNC_Load_WP_List = load_waypoint_tmp;
202
         changed = 0;
203
        }
2420 holgerb 204
  }
2418 holgerb 205
#endif
206
}
207
 
208
void Menu_WPL_R2(uint8_t key)
209
{                       //0123456789ABCDEF
210
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
2420 holgerb 211
static unsigned char load_waypoint_tmp = 1, changed;
2418 holgerb 212
 
2425 holgerb 213
  if(WPL_Name[0] == 0) JetiBox_printfxy(0,0,"Relative WPs ")
2424 holgerb 214
  else JetiBox_printfxy(0,0,"Rel:%s",WPL_Name);
215
 
2420 holgerb 216
  if(NaviData_MaxWpListIndex == 0) JetiBox_printfxy(0,1,"no SD-Card")
217
  else
2425 holgerb 218
  if(GPSInfo.SatFix != SATFIX_3D) JetiBox_printfxy(0,1,"no GPS-Fix")
219
  else
2420 holgerb 220
  {
221
        JetiBox_printfxy(0,1,"#%2d WPs:",load_waypoint_tmp);
222
        if(NaviData_WaypointNumber)     JetiBox_printfxy(8,1,"%2d/%d ",NaviData_WaypointIndex,NaviData_WaypointNumber)
223
        else JetiBox_printfxy(8,1,"--/--")
2418 holgerb 224
 
225
    if(changed)         JetiBox_printfxy(14,1,"->")
226
        else            JetiBox_printfxy(14,1,"  ");
227
 
2420 holgerb 228
        if(key == JETIBOX_KEY_UP && load_waypoint_tmp < NaviData_MaxWpListIndex) { load_waypoint_tmp++; changed = 1;}
229
        if(key == JETIBOX_KEY_DOWN && load_waypoint_tmp > 1) { load_waypoint_tmp--; changed = 1; }
2418 holgerb 230
 
231
        if(key == JETIBOX_KEY_RIGHT && load_waypoint_tmp)
232
        {
233
         ToNC_Load_WP_List = load_waypoint_tmp | 0x80;
234
         changed = 0;
235
        }
2420 holgerb 236
  }
2418 holgerb 237
#endif
238
}
239
 
240
 
241
 
1517 killagreg 242
void Menu_PosInfo(uint8_t key)
1484 killagreg 243
{
2030 holgerb 244
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1484 killagreg 245
        if(NaviDataOkay)
246
        {
1690 holgerb 247
                JetiBox_printfxy(0,0,"%2um/s Sat:%d ",GPSInfo.Speed,GPSInfo.NumOfSats);
1517 killagreg 248
                switch (GPSInfo.SatFix)
249
                {
1690 holgerb 250
                        case SATFIX_3D:
251
                                JetiBox_printfxy(12,0,"  3D");
1517 killagreg 252
                                break;
1933 holgerb 253
//                      case SATFIX_2D:
254
//                      case SATFIX_NONE:
1517 killagreg 255
                        default:
1690 holgerb 256
                                JetiBox_printfxy(12,0,"NoFx");
1517 killagreg 257
                                break;
258
                }
259
                if(GPSInfo.Flags & FLAG_DIFFSOLN)
260
                {
1690 holgerb 261
                        JetiBox_printfxy(12,0,"DGPS");
1517 killagreg 262
                }
1923 holgerb 263
                JetiBox_printfxy(0,1,"Home:%3dm %3d%c %c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF,NC_GPS_ModeCharacter);
1484 killagreg 264
        }
265
        else
1517 killagreg 266
        {                     //0123456789ABCDEF
267
                JetiBox_printfxy(2,0,"No NaviCtrl!");
1484 killagreg 268
        }
2030 holgerb 269
#endif
1484 killagreg 270
}
271
 
1517 killagreg 272
 
1484 killagreg 273
// -----------------------------------------------------------
274
// the menu topology
275
// -----------------------------------------------------------
276
typedef void (*pFctMenu) (uint8_t);  // the menu item handler function pointer
277
 
278
typedef struct{
279
  int8_t left;
280
  int8_t right;
281
  int8_t up;
282
  int8_t down;
283
  pFctMenu pHandler;
284
} MENU_ENTRY;
285
 
286
 
287
// the menu navigation structure
1517 killagreg 288
/*                                              |
289
3 - 0 - 1 - 2 - 3 - 0
1484 killagreg 290
*/
291
 
292
const MENU_ENTRY JetiBox_Menu[] PROGMEM=
293
{ // l  r  u  d  pHandler
2030 holgerb 294
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
2418 holgerb 295
        {6, 1, 0, 0, &Menu_Status },    // 0
1693 holgerb 296
        {0, 2, 1, 1, &Menu_Temperature },       // 1
1517 killagreg 297
        {1, 3, 2, 2, &Menu_Battery },   // 2
1972 holgerb 298
        {2, 4, 3, 3, &Menu_PosInfo },   // 3
2420 holgerb 299
        {3, 5, 7, 7, &Menu_WPL_A1 },    // 4
300
        {4, 6, 8, 8, &Menu_WPL_R1 },    // 5
2418 holgerb 301
        {5, 0, 6, 6, &Magnet_Values },  // 6
302
 
303
        {4, 7, 7, 7, &Menu_WPL_A2 },    // 7
304
        {5, 8, 8, 8, &Menu_WPL_R2 },    // 8
305
 
2030 holgerb 306
#endif
1484 killagreg 307
};
308
 
309
// -----------------------------------------------------------
310
// Update display buffer
311
// -----------------------------------------------------------
1583 ingob 312
unsigned char JetiBox_Update(unsigned char key)
1484 killagreg 313
{
2030 holgerb 314
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1484 killagreg 315
        static uint8_t item = 0, last_item = 0; // the menu item
2418 holgerb 316
        static uint8_t updateDelay = 1 , last_key;
1484 killagreg 317
 
318
        // navigate within the menu by key action
319
        last_item = item;
320
        switch(key)
321
        {
322
                case JETIBOX_KEY_LEFT:
1972 holgerb 323
                        //if (item == 0) return (1);                                                                    // switch back to jeti expander menu
324
                        // else 
325
                         item = pgm_read_byte(&JetiBox_Menu[item].left);                //trigger to left menu item
1484 killagreg 326
                        break;
327
                case JETIBOX_KEY_RIGHT:
328
                        item = pgm_read_byte(&JetiBox_Menu[item].right);        //trigger to right menu item
329
                        break;
330
                case JETIBOX_KEY_UP:
331
                        item = pgm_read_byte(&JetiBox_Menu[item].up);           //trigger to up menu item
332
                        break;
333
                case JETIBOX_KEY_DOWN:
334
                        item = pgm_read_byte(&JetiBox_Menu[item].down);         //trigger to down menu item
335
                        break;
336
                default:
337
                        break;
338
        }
339
        // if the menu item has been changed, do not pass the key to the item handler
340
        // to avoid jumping over to items
341
        if(item != last_item) key = JETIBOX_KEY_UNDEF;
342
 
2418 holgerb 343
        if((updateDelay++ & 0x01) || (key != last_key))
2182 ingob 344
        {      
2418 holgerb 345
                last_key = key;
2182 ingob 346
                LIBFC_JetiBox_Clear();
347
                //execute menu item handler
348
                ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key);
349
        }      
2030 holgerb 350
#endif
1583 ingob 351
        return (0);
1484 killagreg 352
}
353