Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2751 - 1
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2
// + www.MikroKopter.com
3
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4
// + Software Nutzungsbedingungen (english version: see below)
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 "main.h"
54
#include "eeprom.h"
55
 
56
char DisplayBuff[80];
57
unsigned char DispPtr = 0;
58
 
59
unsigned char MaxMenue = 19;
60
unsigned char MenuePunkt = 0;
61
unsigned char RemoteKeys = 0;
62
 
63
#define KEY1    0x01
64
#define KEY2    0x02
65
#define KEY3    0x04
66
#define KEY4    0x08
67
#define KEY5    0x10
68
 
69
void LcdClear(void)
70
{
71
 unsigned char i;
72
 for(i=0;i<80;i++) DisplayBuff[i] = ' ';
73
}
74
 
75
void Menu_Putchar(char c)
76
{
77
 if(DispPtr < 80) DisplayBuff[DispPtr++] = c;
78
}
79
 
80
void Menu(void)
81
 {
82
  unsigned char i;
83
  static char DisableMenu = 0, AccMenu = 0, changed = 0;
84
 
85
if(!DisableMenu)
86
 {
87
  if(RemoteKeys & KEY1) { if(MenuePunkt) MenuePunkt--; else MenuePunkt = MaxMenue;}
88
  if(RemoteKeys & KEY2) { if(MenuePunkt == MaxMenue) MenuePunkt = 0; else MenuePunkt++;}
89
  if((RemoteKeys & KEY1) && (RemoteKeys & KEY2)) MenuePunkt = 0;
90
 }
91
  LcdClear();
92
  if(MenuePunkt < 10) {LCD_printfxy(17,0,"[%i]",MenuePunkt);}
93
  else {LCD_printfxy(16,0,"[%i]",MenuePunkt);};
94
 
95
  switch(MenuePunkt)
96
   {
97
    case 0:
98
           LCD_printfxy(0,0,"+ MikroKopter +");
99
           LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%02d%c ",PlatinenVersion/10,PlatinenVersion%10, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH +'a');
100
           LCD_printfxy(0,2,"Set:%d %s", ActiveParamSet,Mixer.Name);
101
           if(FC_StatusFlags3 & FC_STATUS3_BOAT) LCD_printfxy(16,2,"BOAT");
102
 
103
            if(VersionInfo.HardwareError[1] & FC_ERROR1_MIXER) LCD_printfxy(0,3,"Mixer Error!")
104
                    else
105
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
106
                        if(NC_ErrorCode)
107
                        {
108
                                LCD_printfxy(0,3,"ERR%2d:",NC_ErrorCode);
109
                                _printf_P(&Menu_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0);
110
                        }
111
                   else
112
#endif
113
                   if(VersionInfo.HardwareError[0]) LCD_printfxy(0,3,"Hardware Error 1:%d !!",VersionInfo.HardwareError[0])
114
                   else
115
           if(MissingMotor) LCD_printfxy(0,3,"Missing BL-Ctrl:%d !!",MissingMotor)
116
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
117
#else
118
                   else
119
                        if(NC_ErrorCode)
120
                        {
121
                                LCD_printfxy(0,3,"! NC-ERR: %2d ! ",NC_ErrorCode);
122
                        }
123
#endif
124
//                 if(VersionInfo.HardwareError[1]) LCD_printfxy(0,3,"Error 2:%d !!",VersionInfo.HardwareError[1])
125
                   else
126
           if(I2CTimeout < 6) LCD_printfxy(0,3,"I2C ERROR!!!")
127
                   else
128
               if(Capacity.MinOfMaxPWM < 30) LCD_printfxy(0,3,"BL-Selftest Err:%2d",Capacity.MinOfMaxPWM)
129
 
130
           break;
131
    case 1:
132
           LCD_printfxy(0,0,"Height:  %5i",(int)(HoehenWert/5));
133
           LCD_printfxy(0,1,"Setpoint:%5i",(int)(SollHoehe/5));
134
           LCD_printfxy(0,2,"Pressure:%5i",MessLuftdruck);
135
           LCD_printfxy(0,3,"Offset:  %5i",OCR0A);
136
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
137
                   if(ACC_AltitudeControl)     
138
                    {
139
                         LCD_printfxy(17,2,"(A)");
140
                         LCD_printfxy(17,3,"%i",CalAthmospheare);
141
                        }
142
#endif
143
           break;
144
    case 2:
145
           LCD_printfxy(0,0,"act. bearing");
146
           LCD_printfxy(0,1,"Nick:      %5i",IntegralNick/1024);
147
           LCD_printfxy(0,2,"Roll:      %5i",IntegralRoll/1024);
148
           LCD_printfxy(0,3,"Compass:   %5i",CompassCorrected);
149
           break;
150
    case 3:
151
           for(i=1;i<9;i+=2) LCD_printfxy(0,i/2,"K%i:%4i  K%i:%4i ",i,PPM_in[i],i+1,PPM_in[i+1]);
152
           break;
153
    case 4:
154
           LCD_printfxy(0,0,"Ni:%4i  Ro:%4i ",ChannelNick,ChannelRoll);
155
           LCD_printfxy(0,1,"Gs:%4i  Gi:%4i ",ChannelGas+127,ChannelYaw);
156
           LCD_printfxy(0,2,"P1:%4i  P2:%4i ",PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]]+127,PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]]+127);
157
           LCD_printfxy(0,3,"P3:%4i  P4:%4i ",PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]]+127,PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]]+127);
158
           break;
159
    case 5:
160
           LCD_printfxy(0,0,"Gyro - Sensor");
161
           LCD_printfxy(0,1,"Nick %4i (%4i)",AdWertNick - AdNeutralNick/8, AdNeutralNick);
162
           LCD_printfxy(0,2,"Roll %4i (%4i)",AdWertRoll - AdNeutralRoll/8, AdNeutralRoll);
163
           LCD_printfxy(0,3,"Yaw  %4i (%4i)",AdNeutralGier - AdWertGier, AdNeutralGier);
164
                   AccMenu = 0;
165
           break;
166
    case 6:
167
                switch(AccMenu)
168
                 {
169
                        case 0:
170
                                        LCD_printfxy(0,0,"ACC - Sensor");
171
                                        LCD_printfxy(0,1,"Nick %4i (%3i)",AdWertAccNick,NeutralAccX);
172
                                        LCD_printfxy(0,2,"Roll %4i (%3i)",AdWertAccRoll,NeutralAccY);
173
                                        LCD_printfxy(0,3,"Z    %4i (%3i)(cal)",AdWertAccHoch,(int)NeutralAccZ);
174
                                    if(RemoteKeys & KEY4) AccMenu++;
175
                                        changed = 0;
176
                                        break;
177
                        case 1:        
178
                                        LCD_printfxy(0,0,"Calibration:");
179
                                        LCD_printfxy(0,1,"ACC:   N:%3i R:%3i ",NeutralAccY,NeutralAccX);
180
                                        if(ChannelNick || ChannelRoll)  LCD_printfxy(0,2,"Stick: (%i/%i) !! ",ChannelNick,ChannelRoll);
181
                                        if((FC_StatusFlags & FC_STATUS_MOTOR_RUN) && ((NC_GPS_ModeCharacter == ' ') || (NC_GPS_ModeCharacter == '/') || (NC_GPS_ModeCharacter == '-')))
182
                                         {
183
                                          DisableMenu = 1;
184
                                          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                                   
185
                                          if(RemoteKeys & KEY1) { NeutralAccY--; changed = 1;}
186
                                          if(RemoteKeys & KEY2) { NeutralAccY++; changed = 1;}
187
                                          if(RemoteKeys & KEY3) { NeutralAccX--; changed = 1;}
188
                                          if(RemoteKeys & KEY4) { NeutralAccX++; changed = 1;}
189
                                          LCD_printfxy(13,0,"on ");
190
                                          if(changed)   LCD_printfxy(0,3,"land to save    ")
191
                                          else LCD_printfxy(0,3,"use keys to trim ACC")
192
                                         }
193
                                         else
194
                                         {
195
                                          LCD_printfxy(13,0,"off");
196
                                      DisableMenu = 0;
197
                                          if(!(FC_StatusFlags & FC_STATUS_MOTOR_RUN) && changed)
198
                                           {
199
                                                LCD_printfxy(0,3,"Save?     (yes)(no)");
200
                                            if(RemoteKeys & KEY3) { StoreNeutralToEeprom(); AccMenu = 0;}
201
                                            if(RemoteKeys & KEY4) { changed = 0;}
202
                                           }
203
                                          else LCD_printfxy(0,3,"Fly with GPS off");                                       
204
                                         }
205
                                        break;
206
                        default: AccMenu = 0; break;
207
                }
208
           break;
209
    case 7:
210
                        LCD_printfxy(0,0,"Voltage:   %3i.%1iV",UBat/10, UBat%10);
211
                        LCD_printfxy(0,1,"Current:   %3i.%1iA",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10);
212
                        LCD_printfxy(0,2,"Power:     %4iW",Capacity.ActualPower);
213
                        LCD_printfxy(0,3,"Discharge: %5imAh", Capacity.UsedCapacity);
214
                        AccMenu = 0;
215
           break;
216
    case 8:
217
           LCD_printfxy(0,0,"Receiver");
218
           LCD_printfxy(0,2,"RC-Quality: %4i", SenderOkay);
219
           LCD_printfxy(0,3,"RC-Channels:%4i", Channels-1);
220
           break;
221
    case 9:
222
           LCD_printfxy(0,0,"Undervoltages  " );
223
           LCD_printfxy(0,1,"Warn: %2d.%dV",BattLowVoltageWarning/10,BattLowVoltageWarning%10);
224
           LCD_printfxy(0,2,"Home: %2d.%dV",BattComingHomeVoltage/10,BattComingHomeVoltage%10);
225
           LCD_printfxy(0,3,"Land: %2d.%dV",BattAutoLandingVoltage/10,BattAutoLandingVoltage%10);
226
           break;
227
    case 10:
228
           for(i=0;i<4;i++) LCD_printfxy(0,i,"Poti%i:  %3i",i+1,Poti[i]);
229
           break;
230
    case 11:
231
           for(i=0;i<4;i++) LCD_printfxy(0,i,"Poti%i:  %3i",i+5,Poti[i+4]);
232
           break;
233
    case 12:
234
           LCD_printfxy(0,0,"Flight-Time  " );
235
           LCD_printfxy(0,1,"Total:%5umin",FlugMinutenGesamt);
236
           LCD_printfxy(0,2,"Act:  %5umin",FlugMinuten);
237
           LCD_printfxy(13,3,"(reset)");
238
                   if(RemoteKeys & KEY4)
239
             {
240
               FlugMinuten = 0;
241
               SetParamWord(PID_FLIGHT_MINUTES, FlugMinuten);
242
                         }
243
           break;
244
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
245
    case 13:
246
           LCD_printfxy(0,0,"Compass");
247
           LCD_printfxy(0,1,"Magnet:   %5i",KompassValue);
248
           LCD_printfxy(0,2,"Gyro:     %5i",ErsatzKompassInGrad);
249
           LCD_printfxy(0,3,"True:     %5i",CompassCorrected);
250
           break;
251
    case 14:
252
           LCD_printfxy(0,0,"Servo  " );
253
           LCD_printfxy(0,1,"Setpoint  %3i",Parameter_ServoNickControl);
254
           LCD_printfxy(0,2,"Position: %3i",ServoNickValue/4);
255
           LCD_printfxy(0,3,"Range:%3i-%3i",EE_Parameter.ServoNickMin,EE_Parameter.ServoNickMax);
256
           break;
257
    case 15:
258
                   if(RequiredMotors < 13)
259
                    {
260
                         LCD_printfxy(0,0,"BL-Ctrl Errors " );
261
                         for(i=0;i<3;i++)                                                              
262
                                LCD_printfxy(0,i+1,"%3d %3d %3d %3d ",Motor[i*4].State & MOTOR_STATE_ERROR_MASK,Motor[i*4+1].State & MOTOR_STATE_ERROR_MASK,Motor[i*4+2].State & MOTOR_STATE_ERROR_MASK,Motor[i*4+3].State & MOTOR_STATE_ERROR_MASK);
263
                        }
264
                        else
265
                    {
266
                         for(i=0;i<4;i++)                                                              
267
                                LCD_printfxy(0,i,"%3d %3d %3d %3d ",Motor[i*4].State & MOTOR_STATE_ERROR_MASK,Motor[i*4+1].State & MOTOR_STATE_ERROR_MASK,Motor[i*4+2].State & MOTOR_STATE_ERROR_MASK,Motor[i*4+3].State & MOTOR_STATE_ERROR_MASK);
268
             LCD_printfxy(16,1,"BL-");
269
             LCD_printfxy(16,2,"Err.");
270
                        }
271
           break;
272
    case 16:
273
                   if(RequiredMotors < 13)
274
                   {
275
            LCD_printfxy(0,0,"BL- Temperature" );
276
                     for(i=0;i<3;i++)
277
                      {
278
                       LCD_printfxy(0,i+1,"%3d %3d %3d %3d ",Motor[i*4].Temperature,Motor[i*4+1].Temperature,Motor[i*4+2].Temperature,Motor[i*4+3].Temperature);
279
                          }                    
280
                        }
281
                        else
282
                   {
283
                     for(i=0;i<4;i++)
284
                      {
285
                       LCD_printfxy(0,i,"%3d %3d %3d %3d ",Motor[i*4].Temperature,Motor[i*4+1].Temperature,Motor[i*4+2].Temperature,Motor[i*4+3].Temperature);
286
                          }                    
287
            LCD_printfxy(16,1,"BL-");
288
            LCD_printfxy(16,2,"Temp");
289
                        }
290
            LCD_printfxy(18,3,"C");
291
           break;
292
    case 17:
293
                   if(RequiredMotors < 13)
294
                   {
295
                        LCD_printfxy(0,0,"BL Current" );
296
                        LCD_printfxy(11,3,"(in 0.1A)" );
297
                        for(i=0;i<3;i++)
298
                                {
299
                                        LCD_printfxy(0,i+1,"%3d %3d %3d %3d ",BL3_Current(i*4),BL3_Current(i*4+1),BL3_Current(i*4+2),BL3_Current(i*4+3));
300
                                        if(4 + i * 4 >= RequiredMotors) break;
301
                                }                      
302
                        }
303
                        else
304
                        {
305
                        for(i=0;i<4;i++)
306
                                {
307
                                        LCD_printfxy(0,i,"%3d %3d %3d %3d ",BL3_Current(i*4),BL3_Current(i*4+1),BL3_Current(i*4+2),BL3_Current(i*4+3));
308
                                }                      
309
            LCD_printfxy(16,2,"BL-");
310
            LCD_printfxy(16,3,"I");
311
                        }
312
           break;
313
    case 18:
314
            LCD_printfxy(0,0,"BL-Ctrl found " );
315
                        DispPtr = 20;
316
                        for(i=0; i<MAX_MOTORS; i++)
317
                        {
318
                         if(i == 6 || i == 12) LCD_printf("  ");
319
                         if(Motor[i].State & MOTOR_STATE_PRESENT_MASK)
320
                          {
321
                                LCD_printf(" %2i",i+1);
322
                          }
323
                         else LCD_printf("  -");
324
                        }
325
           break;
326
    case 19:
327
                   if(RequiredMotors < 13)
328
                   {
329
                        LCD_printfxy(0,0,"BL Versions" );
330
                        for(i=0;i<3;i++)
331
                                {
332
                                        LCD_printfxy(0,i+1,"%1d.%02d %1d.%02d %1d.%02d %1d.%02d",Motor[i*4].VersionMajor,Motor[i*4].VersionMinor,Motor[i*4+1].VersionMajor,Motor[i*4+1].VersionMinor,Motor[i*4+2].VersionMajor,Motor[i*4+2].VersionMinor,Motor[i*4+3].VersionMajor,Motor[i*4+3].VersionMinor);
333
                                        if(4 + i * 4 >= RequiredMotors) break;
334
                                }                      
335
                        }
336
                        else
337
                        {
338
                        for(i=0;i<4;i++)
339
                                LCD_printfxy(0,i," %1d.%02d %1d.%02d %1d.%02d %1d.%02d",Motor[i*4].VersionMajor,Motor[i*4].VersionMinor,Motor[i*4+1].VersionMajor,Motor[i*4+1].VersionMinor,Motor[i*4+2].VersionMajor,Motor[i*4+2].VersionMinor,Motor[i*4+3].VersionMajor,Motor[i*4+3].VersionMinor);
340
                        }
341
           break;
342
/*    case 20:
343
           LCD_printfxy(0,0,"BL MaxPWM " );
344
                   for(i=0;i<3;i++)
345
                    {
346
                     LCD_printfxy(0,i+1,"%3d %3d %3d %3d ",Motor[i*4].MaxPWM,Motor[i*4+1].MaxPWM,Motor[i*4+2].MaxPWM,Motor[i*4+3].MaxPWM);
347
                         if(4 + i * 4 >= RequiredMotors) break;
348
                        }                      
349
           break;
350
*/
351
#endif
352
    default:
353
           if(MenuePunkt == MaxMenue) MaxMenue--;
354
           MenuePunkt = 0;
355
           break;
356
    }
357
    RemoteKeys = 0;
358
}