Subversion Repositories FlightCtrl

Rev

Rev 2081 | 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
 
2093 - 71
#define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} //MartinR
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
        {
1941 holgerb 82
                JetiBox_printfxy(6,0,"%3d%c %03dm%c",ErsatzKompassInGrad, 0xDF, GPSInfo.HomeDistance/10,NC_GPS_ModeCharacter);
1484 killagreg 83
        }
1517 killagreg 84
        else
85
        {
1591 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);
1933 holgerb 104
           if(MotorenEin) JetiBeep = 'O';
1930 holgerb 105
          }
106
        }
107
#else
1944 holgerb 108
        if(NC_ErrorCode) { JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); if(MotorenEin) JetiBeep = 'O';};
1930 holgerb 109
#endif
1591 holgerb 110
        JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60);
1916 holgerb 111
        if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG)
1517 killagreg 112
        {
1591 holgerb 113
                JetiBox_printfxy(10,1,"%4im%c", (int16_t)(HoehenWert/100),VarioCharacter);
1517 killagreg 114
        }
2030 holgerb 115
#endif
1517 killagreg 116
}
1512 holgerb 117
 
1705 holgerb 118
 
1693 holgerb 119
void Menu_Temperature(uint8_t key)
1517 killagreg 120
{                       //0123456789ABCDEF
2030 holgerb 121
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1687 holgerb 122
  JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature);
1693 holgerb 123
  JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature);
1690 holgerb 124
  if(RequiredMotors <= 4)
125
        {
126
         JetiBox_printfxy(0,1,"Temperatures    ");
127
    }
128
        else
129
    if(RequiredMotors <= 6)
130
        {
131
         JetiBox_printfxy(8,1,"\%cC     ",0xdf);
132
        }
1692 holgerb 133
 
2030 holgerb 134
#endif
1484 killagreg 135
}
1517 killagreg 136
 
137
void Menu_Battery(uint8_t key)
1500 killagreg 138
{                       //0123456789ABCDEF
2030 holgerb 139
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1972 holgerb 140
        JetiBox_printfxy(0,0,"%2i.%1iV %3i.%1iA", UBat/10, UBat%10, Capacity.ActualCurrent/10, Capacity.ActualCurrent%10);
1529 killagreg 141
        JetiBox_printfxy(0,1,"%4iW %6imAh",Capacity.ActualPower, Capacity.UsedCapacity);
2030 holgerb 142
#endif
1500 killagreg 143
}
144
 
1972 holgerb 145
void Magnet_Values(uint8_t key)
146
{                       //0123456789ABCDEF
2030 holgerb 147
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1972 holgerb 148
        JetiBox_printfxy(0,0,"Magnet:%3i%% %3i%c",EarthMagneticField, KompassValue,0xDF);
149
        JetiBox_printfxy(0,1,"Incli.:%3i%c (%i) ",EarthMagneticInclination, 0xDF,EarthMagneticInclinationTheoretic);
2030 holgerb 150
#endif
1972 holgerb 151
}
1680 holgerb 152
 
1972 holgerb 153
 
1517 killagreg 154
void Menu_PosInfo(uint8_t key)
1484 killagreg 155
{
2030 holgerb 156
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1484 killagreg 157
        if(NaviDataOkay)
158
        {
1690 holgerb 159
                JetiBox_printfxy(0,0,"%2um/s Sat:%d ",GPSInfo.Speed,GPSInfo.NumOfSats);
1517 killagreg 160
                switch (GPSInfo.SatFix)
161
                {
1690 holgerb 162
                        case SATFIX_3D:
163
                                JetiBox_printfxy(12,0,"  3D");
1517 killagreg 164
                                break;
1933 holgerb 165
//                      case SATFIX_2D:
166
//                      case SATFIX_NONE:
1517 killagreg 167
                        default:
1690 holgerb 168
                                JetiBox_printfxy(12,0,"NoFx");
1517 killagreg 169
                                break;
170
                }
171
                if(GPSInfo.Flags & FLAG_DIFFSOLN)
172
                {
1690 holgerb 173
                        JetiBox_printfxy(12,0,"DGPS");
1517 killagreg 174
                }
1923 holgerb 175
                JetiBox_printfxy(0,1,"Home:%3dm %3d%c %c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF,NC_GPS_ModeCharacter);
1484 killagreg 176
        }
177
        else
1517 killagreg 178
        {                     //0123456789ABCDEF
179
                JetiBox_printfxy(2,0,"No NaviCtrl!");
1484 killagreg 180
        }
2030 holgerb 181
#endif
1484 killagreg 182
}
183
 
1517 killagreg 184
 
2093 - 185
// MartinR für Jeti+  Anfang
186
void Menu_spoti1(uint8_t key)
187
{                       //0123456789ABCDEF
188
 
189
        JetiBox_printfxy(0,0,">%3i=Serialpot1",(PPM_in[13] + 127));
190
        //JetiBox_printfxy(0,1," %3i=Serialpot2",PPM_in[14]);
191
        if(key== JETIBOX_KEY_UP) PPM_in[13] = PPM_in[13]+25;
192
        if(key== JETIBOX_KEY_DOWN) PPM_in[13] = PPM_in[13]-25;
193
        LIMIT_MIN_MAX(PPM_in[13], -127, 128);   // MartinR: Begrenzung 
194
}
195
 
196
void Menu_spoti2(uint8_t key)
197
{                       //0123456789ABCDEF
198
 
199
        //JetiBox_printfxy(0,0," %3i=Serialpot1",PPM_in[13]);
200
        JetiBox_printfxy(0,1,">%3i=Serialpot2",(PPM_in[14] + 127));
201
        if(key== JETIBOX_KEY_UP) PPM_in[14] = PPM_in[14]+2;
202
        if(key== JETIBOX_KEY_DOWN) PPM_in[14] = PPM_in[14]-2;
203
        LIMIT_MIN_MAX(PPM_in[14], -127, 128);   // MartinR: Begrenzung
204
}
205
 
206
// MartinR für Jeti+  Ende
207
 
1484 killagreg 208
// -----------------------------------------------------------
209
// the menu topology
210
// -----------------------------------------------------------
211
typedef void (*pFctMenu) (uint8_t);  // the menu item handler function pointer
212
 
213
typedef struct{
214
  int8_t left;
215
  int8_t right;
216
  int8_t up;
217
  int8_t down;
218
  pFctMenu pHandler;
219
} MENU_ENTRY;
220
 
221
 
222
// the menu navigation structure
1517 killagreg 223
/*                                              |
1484 killagreg 224
 
1517 killagreg 225
3 - 0 - 1 - 2 - 3 - 0
226
 
1484 killagreg 227
*/
228
 
229
const MENU_ENTRY JetiBox_Menu[] PROGMEM=
230
{ // l  r  u  d  pHandler
2030 holgerb 231
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
2093 - 232
        //{4, 1, 0, 0, &Menu_Status },  // 0 // MartinR: so war es
233
        {6, 1, 0, 0, &Menu_Status },    // 0 // MartinR: geändert
1693 holgerb 234
        {0, 2, 1, 1, &Menu_Temperature },       // 1
1517 killagreg 235
        {1, 3, 2, 2, &Menu_Battery },   // 2
1972 holgerb 236
        {2, 4, 3, 3, &Menu_PosInfo },   // 3
2093 - 237
        //{3, 0, 4, 4, &Magnet_Values } // 4 // MartinR: so war es
238
        {3, 5, 4, 4, &Magnet_Values },  // 4 // MartinR: geändert
239
 
240
        {4, 6, 5, 5, &Menu_spoti1 },    // 5  // MartinR: für Jeti+
241
        {5, 0, 6, 6, &Menu_spoti2 },    // 6  // MartinR: für Jeti+
242
 
2030 holgerb 243
#endif
1484 killagreg 244
};
245
 
246
// -----------------------------------------------------------
247
// Update display buffer
248
// -----------------------------------------------------------
1583 ingob 249
unsigned char JetiBox_Update(unsigned char key)
1484 killagreg 250
{
2030 holgerb 251
#if !defined (RECEIVER_SPEKTRUM_DX7EXP) && !defined (RECEIVER_SPEKTRUM_DX8EXP)
1484 killagreg 252
        static uint8_t item = 0, last_item = 0; // the menu item
253
 
254
        // navigate within the menu by key action
255
        last_item = item;
256
        switch(key)
257
        {
258
                case JETIBOX_KEY_LEFT:
1972 holgerb 259
                        //if (item == 0) return (1);                                                                    // switch back to jeti expander menu
260
                        // else 
261
                         item = pgm_read_byte(&JetiBox_Menu[item].left);                //trigger to left menu item
1484 killagreg 262
                        break;
263
                case JETIBOX_KEY_RIGHT:
264
                        item = pgm_read_byte(&JetiBox_Menu[item].right);        //trigger to right menu item
265
                        break;
266
                case JETIBOX_KEY_UP:
267
                        item = pgm_read_byte(&JetiBox_Menu[item].up);           //trigger to up menu item
268
                        break;
269
                case JETIBOX_KEY_DOWN:
270
                        item = pgm_read_byte(&JetiBox_Menu[item].down);         //trigger to down menu item
271
                        break;
272
                default:
273
                        break;
274
        }
275
        // if the menu item has been changed, do not pass the key to the item handler
276
        // to avoid jumping over to items
277
        if(item != last_item) key = JETIBOX_KEY_UNDEF;
278
 
279
        LIBFC_JetiBox_Clear();
280
        //execute menu item handler
281
        ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key);
2030 holgerb 282
#endif
1583 ingob 283
        return (0);
1484 killagreg 284
}
285