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 "libfc.h"
54
#include "printf_P.h"
55
#include "main.h"
56
#include "spi.h"
57
#include "capacity.h"
58
 
59
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
60
 
61
#define HoTT_printf(format, args...)                    {  _printf_P(&LIBFC_HoTT_Putchar, PSTR(format) , ## args);}
62
#define HoTT_printfxy(x,y,format, args...)              { LIBFC_HoTT_SetPos(y * 21 + x); _printf_P(&LIBFC_HoTT_Putchar, PSTR(format) , ## args);}
63
#define HoTT_printfxy_INV(x,y,format, args...)          { LIBFC_HoTT_SetPos(y * 21 + x); _printf_P(&LIBFC_HoTT_Putchar_INV, PSTR(format) , ## args);}
64
#define HoTT_printfxy_BLINK(x,y,format, args...)        { LIBFC_HoTT_SetPos(y * 21 + x); _printf_P(&LIBFC_HoTT_Putchar_BLINK, PSTR(format) , ## args);}
65
#define HoTT_printf_BLINK(format, args...)              { _printf_P(&LIBFC_HoTT_Putchar_BLINK, PSTR(format) , ## args);}
66
#define HoTT_printf_INV(format, args...)                        { _printf_P(&LIBFC_HoTT_Putchar_INV, PSTR(format) , ## args);}
67
 
68
#define VOICE_MINIMALE_EINGANSSPANNUNG    16
69
#define VOICE_BEEP                         5
70
#define HoTT_GRAD       96
71
#define HoTT_LINKS      123
72
#define HoTT_RECHTS 124
73
#define HoTT_OBEN       125
74
#define HoTT_UNTEN      126
75
 
76
#define HOTT_KEY_RIGHT  1
77
#define HOTT_KEY_DOWN   2
78
#define HOTT_KEY_UP     4
79
#define HOTT_KEY_SET    6
80
#define HOTT_KEY_LEFT   8
81
 
82
unsigned char NaviData_WaypointIndex = 0, NaviData_WaypointNumber = 0, NaviData_TargetHoldTime = 0;
83
unsigned int NaviData_TargetDistance = 0;
84
 
85
GPSPacket_t GPSPacket;
86
VarioPacket_t VarioPacket;
87
ASCIIPacket_t ASCIIPacket;
88
ElectricAirPacket_t ElectricAirPacket;
89
HoTTGeneral_t HoTTGeneral;
90
unsigned char SpeakHoTT = SPEAK_MIKROKOPTER;
91
unsigned char ToNC_SpeakHoTT = 0;
92
int HoTTVarioMeter = 0;
93
const char PROGMEM MIKROKOPTER[] =      {"     MikroKopter     "};
94
const char PROGMEM UNDERVOLTAGE[] =     {" !! LiPo voltage !!  "};
95
const char PROGMEM NC_ERROR_TEXT[MAX_ERR_NUMBER][17] =
96
{
97
//0123456789123456
98
 "No Error        \0",  // 0
99
 "Not compatible  \0",  // 1
100
 "MK3Mag not compa\0",  // 2
101
 "No FC communicat\0",  // 3
102
 "Compass communic\0",  // 4
103
 "GPS communicatio\0",  // 5
104
 "compass value   \0",  // 6
105
 "RC Signal lost  \0",  // 7
106
 "FC spi rx error \0",  // 8
107
 "No NC communicat\0",  // 9
108
 "FC Nick Gyro    \0",  // 10
109
 "FC Roll Gyro    \0",  // 11
110
 "FC Yaw Gyro     \0",  // 12
111
 "FC Nick ACC     \0",  // 13
112
 "FC Roll ACC     \0",  // 14
113
 "FC Z-ACC        \0",  // 15
114
 "Pressure sensor \0",  // 16
115
 "I2C FC->BL-Ctrl \0",  // 17
116
 "Bl Missing      \0",  // 18
117
 "Mixer Error     \0",  // 19
118
 "Carefree Error  \0",  // 20
119
 "GPS Fix lost    \0",  // 21
120
 "Magnet Error    \0",  // 22
121
 "Motor restart   \0",  // 23
122
 "BL Limitation   \0",  // 24
123
 "GPS Range       \0",  // 25
124
 "No SD-Card      \0",  // 26
125
 "SD-Logging error\0",  // 27
126
 "Flying range!   \0",  // 28
127
 "Max Altitude!   \0",  // 29
128
 "No GPS fix      \0",  // 30
129
 "compass not cal.\0"  // 31
130
};
131
 
132
 
133
const char PROGMEM HOTT_ERROR[MAX_ERR_NUMBER][2] =
134
{       // 1 -> only in flight   0 -> also on ground
135
//0123456789123456
136
         {0,0},// "No Error        \0",  // 0
137
         {SPEAK_ERROR,0},// "Not compatible  \0",  // 1
138
         {SPEAK_ERROR,0},// "MK3Mag not compa\0",  // 2
139
         {SPEAK_ERR_NAVI,1},// "No FC communicat\0",  // 3
140
         {SPEAK_ERR_COMPASS,1},// "MK3Mag communica\0",  // 4
141
         {SPEAK_ERR_GPS,0},// "GPS communicatio\0",  // 5
142
         {SPEAK_ERR_COMPASS,1},// "compass value   \0",  // 6
143
         {SPEAK_ERR_RECEICER,0},// "RC Signal lost  \0",  // 7
144
         {SPEAK_ERR_NAVI,0},// "FC spi rx error \0",  // 8
145
         {SPEAK_ERR_NAVI,0},// "No NC communicat\0",  // 9
146
         {SPEAK_ERR_SENSOR,0},// "FC Nick Gyro    \0",  // 10
147
         {SPEAK_ERR_SENSOR,0},// "FC Roll Gyro    \0",  // 11
148
         {SPEAK_ERR_SENSOR,0},// "FC Yaw Gyro     \0",  // 12
149
         {SPEAK_ERR_SENSOR,0},// "FC Nick ACC     \0",  // 13
150
         {SPEAK_ERR_SENSOR,0},// "FC Roll ACC     \0",  // 14
151
         {SPEAK_ERR_SENSOR,0},// "FC Z-ACC        \0",  // 15
152
         {SPEAK_ERR_SENSOR,0},// "Pressure sensor \0",  // 16
153
         {SPEAK_ERR_DATABUS,1},// "I2C FC->BL-Ctrl \0",  // 17
154
         {SPEAK_ERR_DATABUS,1},// "Bl Missing      \0",  // 18
155
         {SPEAK_ERROR,0},// "Mixer Error     \0",  // 19
156
         {SPEAK_CF_OFF,1},// "Carefree Error  \0",  // 20
157
         {SPEAK_GPS_FIX,1},// "GPS Fix lost    \0",  // 21
158
         {SPEAK_ERR_COMPASS,0},// "Magnet Error    \0",  // 22
159
         {SPEAK_ERR_MOTOR,1},// "Motor restart   \0",  // 23
160
         {SPEAK_MAX_TEMPERAT,1},// "BL Limitation   \0",  // 24
161
         {SPEAK_MAX_RANGE,1},// "GPS Range       \0",  // 25
162
         {SPEAK_ERROR,1},// "No SD-Card      \0",  // 26
163
         {SPEAK_ERROR,1},// "SD-Logging error\0",  // 27
164
         {SPEAK_MAX_RANGE,1},// "Flying range!   \0",   // 28
165
         {SPEAK_MAX_ALTITUD,1},// "Max Altitude!   \0"   // 29
166
         {SPEAK_GPS_FIX,1}// "no GPS Fix,  // 30
167
};
168
 
169
 
170
unsigned char MaxBlTempertaure = 0;
171
unsigned char MinBlTempertaure = 0;
172
unsigned char HottestBl = 0;
173
 
174
void GetHottestBl(void)
175
{
176
 static unsigned char search = 0,tmp_max,tmp_min,who;
177
                if(Motor[search].Temperature > tmp_max) { tmp_max = Motor[search].Temperature; who = search;}
178
                else
179
                if(Motor[search].Temperature) if(Motor[search].Temperature < tmp_min) tmp_min = Motor[search].Temperature;
180
                if(++search > MAX_MOTORS)
181
                {
182
                 search = 0;
183
                 if(tmp_min != 255) MinBlTempertaure = tmp_min; else MinBlTempertaure = 0;
184
                 MaxBlTempertaure = tmp_max;
185
                 HottestBl = who;
186
                 tmp_min = 255;
187
                 tmp_max = 0;
188
                 who = 0;
189
                 }
190
}
191
 
192
//---------------------------------------------------------------
193
void Hott_ClearLine(unsigned char line)
194
{
195
 HoTT_printfxy(0,line,"                     ");
196
}
197
//---------------------------------------------------------------
198
 
199
 
200
unsigned char HoTT_Waring(void)
201
{
202
  unsigned char status = 0;
203
  static char old_status = 0;
204
  static int repeat;
205
//if(Parameter_UserParam1) return(Parameter_UserParam1); 
206
  ToNC_SpeakHoTT = SpeakHoTT;
207
  if(FC_StatusFlags & FC_STATUS_LOWBAT) status = VOICE_MINIMALE_EINGANSSPANNUNG;
208
  else
209
  if(NC_ErrorCode)      // Fehlercodes
210
   {
211
    if(MotorenEin || !pgm_read_byte(&HOTT_ERROR[NC_ErrorCode][1])) status = pgm_read_byte(&HOTT_ERROR[NC_ErrorCode][0]);
212
   }
213
  if(!status)    // Sprachansagen
214
   {
215
//      if(!(GetParamByte(PID_SPEAK_HOTT_CFG) & 0x01)) SpeakHoTT = 0;  // is the voice wanted?
216
    if(!(EE_Parameter.GlobalConfig3 & CFG3_SPEAK_ALL)) SpeakHoTT = 0;  // is the voice wanted?
217
    else status = SpeakHoTT;
218
   }
219
   else ToNC_SpeakHoTT = status;
220
 
221
  if(old_status == status) // Gleichen Fehler nur alle 5 sek bringen
222
   {
223
    if(!CheckDelay(repeat)) return(0);
224
        repeat = SetDelay(5000);
225
   }
226
   else repeat = SetDelay(2000);
227
 
228
  if(status)
229
   {
230
    if(status == SpeakHoTT) SpeakHoTT = 0;
231
   }   
232
  old_status = status;
233
//  DebugOut.Analog[16] = status;
234
  return(status);
235
}
236
 
237
/*
238
unsigned char HoTTErrorCode(void)
239
{
240
 return(NC_ErrorCode);
241
}
242
*/
243
//---------------------------------------------------------------
244
void NC_Fills_HoTT_Telemety(void)
245
{
246
 unsigned char *ptr = NULL;
247
 unsigned char max = 0,i,z;
248
 switch(FromNaviCtrl.Param.Byte[11])
249
  {
250
   case HOTT_VARIO_PACKET_ID:
251
                ptr = (unsigned char *) &VarioPacket;
252
                max = sizeof(VarioPacket);
253
                break;
254
   case HOTT_GPS_PACKET_ID:
255
                ptr = (unsigned char *) &GPSPacket;
256
                max = sizeof(GPSPacket);
257
                break;
258
   case HOTT_ELECTRIC_AIR_PACKET_ID:
259
                ptr = (unsigned char *) &ElectricAirPacket;
260
                max = sizeof(ElectricAirPacket);
261
                break;
262
   case HOTT_GENERAL_PACKET_ID:
263
                ptr = (unsigned char *) &HoTTGeneral;
264
                max = sizeof(HoTTGeneral);
265
                break;
266
  }
267
 z = FromNaviCtrl.Param.Byte[0]; // Data allocation
268
 
269
 for(i=0; i < FromNaviCtrl.Param.Byte[1]; i++)
270
  {
271
   if(z >= max) break;
272
   ptr[z] = FromNaviCtrl.Param.Byte[2+i];
273
   z++;
274
  }
275
}
276
 
277
unsigned int BuildHoTT_Vario(void)
278
{
279
 unsigned int tmp = 30000;
280
 if(VarioCharacter == '+' || VarioCharacter == '-')
281
  {
282
   tmp = 30000 + (AltitudeSetpointTrimming * EE_Parameter.Hoehe_Verstaerkung) / 3;
283
   if(tmp < 30000 && tmp > 30000 - 50) tmp = 30000 - 50; // weil es sonst erst bei < 0,5m/sek piept
284
  }
285
 else
286
 if((VarioCharacter == ' ') && (FC_StatusFlags & FC_STATUS_FLY))
287
  {
288
   tmp = 30000 + HoTTVarioMeter;
289
   if(tmp > 30000)
290
    {
291
     if(tmp < 30000 + 100) tmp = 30000;
292
         else tmp -= 100;
293
        }
294
   if(tmp < 30000)
295
    {
296
     if(tmp > 30000 - 100) tmp = 30000;
297
         else tmp += 100;
298
        }
299
  }
300
 else
301
 if(VarioCharacter == '^') tmp = 30000 + FromNC_AltitudeSpeed * 10;
302
 else
303
 if(VarioCharacter == 'v') tmp = 30000 - FromNC_AltitudeSpeed * 10;
304
 
305
 return(tmp);
306
}
307
 
308
//---------------------------------------------------------------
309
unsigned char HoTT_Telemety(unsigned char packet_request)
310
{
311
unsigned char i;
312
  //Debug("rqst: %02X",packet_request);
313
 
314
 switch(packet_request)
315
 {
316
  case HOTT_VARIO_PACKET_ID:
317
                VarioPacket.Altitude = HoehenWert/100 + 500;  
318
                VarioPacket.m_sec = BuildHoTT_Vario();
319
                VarioPacket.m_3sec = VarioPacket.m_sec;
320
                VarioPacket.m_10sec = VarioPacket.m_sec;
321
                if (VarioPacket.Altitude < VarioPacket.MinAltitude) VarioPacket.MinAltitude = VarioPacket.Altitude;
322
                if (VarioPacket.Altitude > VarioPacket.MaxAltitude) VarioPacket.MaxAltitude = VarioPacket.Altitude;            
323
                VarioPacket.WarnBeep = 0;//HoTT_Waring();
324
                HoTT_DataPointer = (unsigned char *) &VarioPacket;
325
        VarioPacket.FreeCharacters[0] = VarioCharacter;
326
    if(FC_StatusFlags2 & FC_STATUS2_CAREFREE) VarioPacket.FreeCharacters[1] = 'C'; else VarioPacket.FreeCharacters[1] = ' ';
327
//      VarioPacket.FreeCharacters[2] = ' ';
328
    if(NC_ErrorCode)
329
         {
330
                VarioPacket.Text[0] = NC_ErrorCode/10 + '0';
331
                VarioPacket.Text[1] = NC_ErrorCode%10 + '0';
332
                VarioPacket.Text[2] = ':';
333
                for(i=0; i<16;i++) VarioPacket.Text[i+3] = pgm_read_byte(&NC_ERROR_TEXT[NC_ErrorCode][i]);
334
         }
335
         else
336
         if(FC_StatusFlags & FC_STATUS_LOWBAT) for(i=0; i<21;i++) VarioPacket.Text[i] = pgm_read_byte(&UNDERVOLTAGE[i]); // no Error
337
         else    
338
     if(NaviData_WaypointNumber)
339
         {    
340
          unsigned int tmp_int;
341
      unsigned char tmp;
342
      VarioPacket.Text[0] = 'W'; VarioPacket.Text[1] = 'P';
343
      VarioPacket.Text[2] = ' ';
344
      VarioPacket.Text[3] = '0'+(NaviData_WaypointIndex) / 10;
345
      VarioPacket.Text[4] = '0'+(NaviData_WaypointIndex) % 10;
346
      VarioPacket.Text[5] = '/';
347
      VarioPacket.Text[6] = '0'+(NaviData_WaypointNumber) / 10;
348
      VarioPacket.Text[7] = '0'+(NaviData_WaypointNumber) % 10;
349
      VarioPacket.Text[8] = ' ';
350
          tmp_int = NaviData_TargetDistance;
351
      if(tmp_int > 1000) { VarioPacket.Text[9] = '0'+(tmp_int) / 1000; tmp_int %= 1000;}
352
          else VarioPacket.Text[9] = ' ';
353
      if(tmp_int > 100) { VarioPacket.Text[10] = '0'+(tmp_int) / 100; tmp_int %= 100;}
354
          else VarioPacket.Text[10] = ' ';
355
      VarioPacket.Text[11] = '0'+(tmp_int) / 10;
356
      VarioPacket.Text[12] = '0'+(tmp_int) % 10;
357
      VarioPacket.Text[13] = 'm';
358
      VarioPacket.Text[14] = ' ';
359
      tmp = NaviData_TargetHoldTime;
360
          if(tmp > 100) { VarioPacket.Text[15] = '0'+(tmp) / 100; tmp %= 100;} else VarioPacket.Text[15] = ' ';
361
      VarioPacket.Text[16] = '0'+(tmp) / 10;
362
      VarioPacket.Text[17] = '0'+(tmp) % 10;
363
      VarioPacket.Text[18] = 's';
364
      VarioPacket.Text[19] = ' ';
365
//unsigned char NaviData_WaypointIndex = 0, NaviData_WaypointNumber = 0, NaviData_TargetHoldTime = 0;
366
//unsigned int NaviData_TargetDistance = 0;
367
         }
368
         else
369
         for(i=0; i<21;i++) VarioPacket.Text[i] = pgm_read_byte(&MIKROKOPTER[i]); // no Error
370
 
371
                return(sizeof(VarioPacket));
372
                break;
373
 
374
  case HOTT_GPS_PACKET_ID:
375
                GPSPacket.Altitude = HoehenWert/100 + 500;  
376
//              GPSPacket.Distance = GPSInfo.HomeDistance/10;  // macht die NC
377
//              GPSPacket.Heading = GPSInfo.HomeBearing/2;     // macht die NC
378
//              GPSPacket.Speed = (GPSInfo.Speed * 36) / 10;   // macht die NC
379
                GPSPacket.m_sec = BuildHoTT_Vario();
380
                GPSPacket.m_3sec = 120;
381
                GPSPacket.NumOfSats = GPSInfo.NumOfSats;
382
                GPSPacket.WarnBeep = HoTT_Waring();
383
                if(GPSInfo.Flags & FLAG_DIFFSOLN) GPSPacket.SatFix = 'D';
384
                else
385
        if(GPSInfo.SatFix == SATFIX_3D) GPSPacket.SatFix = ' ';
386
                else GPSPacket.SatFix = '!';
387
                HoTT_DataPointer = (unsigned char *) &GPSPacket;
388
                GPSPacket.FreeCharacters[0] = NC_GPS_ModeCharacter;
389
                GPSPacket.FreeCharacters[2] = GPSPacket.SatFix;
390
                GPSPacket.HomeDirection = GPSInfo.HomeBearing / 2;//230;
391
                return(sizeof(GPSPacket));  
392
                break;
393
  case HOTT_ELECTRIC_AIR_PACKET_ID:
394
                GetHottestBl();
395
                ElectricAirPacket.Altitude = HoehenWert/100 + 500;
396
                ElectricAirPacket.Battery1 = UBat;
397
                ElectricAirPacket.Battery2 = UBat;
398
                ElectricAirPacket.VoltageCell1 = ErsatzKompassInGrad / 2;
399
                ElectricAirPacket.VoltageCell8 = ElectricAirPacket.VoltageCell1;
400
                ElectricAirPacket.VoltageCell6 = GPSInfo.HomeBearing / 2;
401
                ElectricAirPacket.VoltageCell7 = GPSInfo.HomeDistance/20;
402
                ElectricAirPacket.VoltageCell13 = ElectricAirPacket.VoltageCell6;
403
                ElectricAirPacket.VoltageCell14 = ElectricAirPacket.VoltageCell7;
404
                ElectricAirPacket.m_sec = BuildHoTT_Vario();
405
                ElectricAirPacket.m_3sec = 120;
406
                ElectricAirPacket.InputVoltage = UBat;
407
                ElectricAirPacket.Temperature1 = MinBlTempertaure + 20;
408
                ElectricAirPacket.Temperature2 = MaxBlTempertaure + 20;
409
                ElectricAirPacket.Capacity = Capacity.UsedCapacity/10;
410
                ElectricAirPacket.WarnBeep = 0;//HoTT_Waring();
411
                ElectricAirPacket.Current = Capacity.ActualCurrent;
412
                HoTT_DataPointer = (unsigned char *) &ElectricAirPacket;
413
                ElectricAirPacket.FlightTimeMinutes = FlugSekunden / 60;
414
                ElectricAirPacket.FlightTimeSeconds = FlugSekunden % 60;
415
                return(sizeof(ElectricAirPacket));
416
                break;
417
  case HOTT_GENERAL_PACKET_ID:
418
                GetHottestBl();
419
                HoTTGeneral.Rpm = GPSInfo.HomeDistance/100;
420
                HoTTGeneral.VoltageCell1 = ErsatzKompassInGrad / 2;
421
                HoTTGeneral.VoltageCell6 = GPSInfo.HomeBearing / 2;
422
                if(UBat > BattLowVoltageWarning + 5) HoTTGeneral.FuelPercent = (UBat - (BattLowVoltageWarning + 6)) * 3;
423
                else HoTTGeneral.FuelPercent = 0;
424
                HoTTGeneral.FuelCapacity = HoehenWert/100;
425
                if(HoTTGeneral.FuelCapacity < 0) HoTTGeneral.FuelCapacity = 0;
426
                HoTTGeneral.Altitude = HoehenWert/100 + 500;
427
                HoTTGeneral.Battery1 = UBat;
428
                HoTTGeneral.Battery2 = UBat;
429
                HoTTGeneral.m_sec =  BuildHoTT_Vario();
430
                HoTTGeneral.m_3sec = 120;
431
                HoTTGeneral.InputVoltage = UBat;
432
                HoTTGeneral.Temperature1 = MinBlTempertaure + 20;
433
                HoTTGeneral.Temperature2 = MaxBlTempertaure + 20;
434
                HoTTGeneral.Capacity = Capacity.UsedCapacity/10;
435
                HoTTGeneral.WarnBeep = 0;//HoTT_Waring();
436
                HoTTGeneral.Current = Capacity.ActualCurrent;
437
//HoTTGeneral.ErrorNumber = HoTTErrorCode();
438
                HoTT_DataPointer = (unsigned char *) &HoTTGeneral;
439
                return(sizeof(HoTTGeneral));
440
                break;
441
  default: return(0);
442
  }            
443
}
444
 
445
//---------------------------------------------------------------
446
void HoTT_Menu(void)
447
{
448
 static unsigned char line, page = 0,show_current = 0,show_mag = 0, show_poti = 0;
449
 unsigned char tmp;
450
 HoTTVarioMeter = (HoTTVarioMeter * 7 + VarioMeter) / 8;
451
 
452
 if(page == 0)
453
  switch(line++)
454
  {
455
        case 0:  
456
                if(FC_StatusFlags & FC_STATUS_LOWBAT)
457
                         HoTT_printfxy_BLINK(0,0,"  %2i.%1iV  ",UBat/10, UBat%10)
458
                        else
459
                         HoTT_printfxy(0,0,"  %2i.%1iV  ",UBat/10, UBat%10)
460
 
461
                        if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG)
462
                          {
463
                           if(HoehenReglerAktiv)        HoTT_printfxy_INV(10,0,"ALT:%4im %c", (int16_t)(HoehenWert/100),VarioCharacter)
464
                           else                                         HoTT_printfxy(10,0,"ALT:%4im  ", (int16_t)(HoehenWert/100))
465
                           }
466
            else    HoTT_printfxy(10,0,"ALT:---- ");
467
                        break;
468
        case 1:  
469
                if(FC_StatusFlags & FC_STATUS_LOWBAT)
470
                         HoTT_printfxy_BLINK(0,1,"  %2i:%02i  ",FlugSekunden/60,FlugSekunden%60)
471
            else   HoTT_printfxy(0,1,"  %2i:%02i  ",FlugSekunden/60,FlugSekunden%60);                      
472
                        HoTT_printfxy(10,1,"DIR: %3d%c",ErsatzKompassInGrad, HoTT_GRAD);
473
                        if(FC_StatusFlags2 & FC_STATUS2_CAREFREE) HoTT_printfxy_INV(20,1,"C") else HoTT_printfxy(20,1," ");
474
            break;
475
        case 2:
476
                if(FC_StatusFlags & FC_STATUS_LOWBAT)
477
                         HoTT_printfxy_BLINK(0,2,"  %5i  ",Capacity.UsedCapacity)
478
            else   HoTT_printfxy(0,2,"  %5i  ",Capacity.UsedCapacity);                     
479
                        HoTT_printfxy(12,2,"I:%2i.%1iA ",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10);
480
                        break;
481
        case 3:
482
                        HoTT_printfxy(9,0,":");
483
                        HoTT_printfxy(9,1,":");
484
                        HoTT_printfxy(9,2,":");
485
                        HoTT_printfxy(0,3,"---------+-----------");
486
 
487
//                      HoTT_printfxy(0,3,"---------------------");
488
                        HoTT_printfxy(0,6,"---------------------");
489
                        break;
490
        case 4:  
491
                        if(NaviDataOkay)
492
                        {
493
                                HoTT_printfxy(9,4,":");
494
                                HoTT_printfxy(0,4,"SAT:%2d ",GPSInfo.NumOfSats);
495
                            HoTT_printfxy(10,4,"DIST:%3dm",GPSInfo.HomeDistance/10);
496
                                switch (GPSInfo.SatFix)
497
                                {
498
                                        case SATFIX_3D:
499
                                                        if(GPSInfo.Flags & FLAG_DIFFSOLN) HoTT_printfxy(7,4,"D ")
500
                                                        else HoTT_printfxy(7,4,"3D");
501
                                                break;
502
                                        default:
503
                                                HoTT_printfxy_BLINK(7,4,"!!");
504
                                                break;
505
                                }      
506
                        }
507
                        else
508
                        {                    
509
                                Hott_ClearLine(4);
510
                        }
511
                        break;
512
        case 5:
513
                        if(NaviDataOkay)
514
                        {
515
                        if(show_mag)
516
                          {
517
                                HoTT_printfxy(0,5,"MAG:%3u%% ",EarthMagneticField);
518
                            HoTT_printfxy(12,5,"HM:%3d%c %c", GPSInfo.HomeBearing, HoTT_GRAD, NC_GPS_ModeCharacter);
519
                                HoTT_printfxy(9,5,"incl:%2d%c(%2i)",EarthMagneticInclination, HoTT_GRAD,EarthMagneticInclinationTheoretic);
520
              }
521
                         else
522
                          {
523
                                HoTT_printfxy(0,5,"    %2um/s:  HM:%3d%c %c",GPSInfo.Speed, GPSInfo.HomeBearing, HoTT_GRAD, NC_GPS_ModeCharacter);
524
                          }    
525
            }
526
                        else Hott_ClearLine(5);
527
                        break;
528
        case 6:
529
                        break;
530
        case 7: if(NC_ErrorCode)
531
                  {
532
                           if(HoTTBlink && NC_ErrorCode < MAX_ERR_NUMBER)
533
                            {
534
                             Hott_ClearLine(7);
535
                             HoTT_printfxy_INV(0,7,"ERR: %2d !",NC_ErrorCode);
536
                            }
537
                                else
538
                                {
539
                                 HoTT_printfxy(0,7,"ERR: ");     _printf_P(&LIBFC_HoTT_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0);};
540
                                }
541
                        else
542
                        if(FC_StatusFlags & FC_STATUS_LOWBAT) HoTT_printfxy(1,7,"!! LiPo voltage !!")
543
                        else HoTT_printfxy(0,7," www.MikroKopter.de  ");
544
                        break;
545
        case 8: //ASCIIPacket.WarnBeep = HoTT_Waring();
546
                        // ASCIIPacket.WarnBeep = Parameter_UserParam1;
547
        case 9:
548
        case 10:
549
        case 11:
550
        case 12:
551
        case 13:
552
        case 14:  
553
        case 15:  
554
        case 16:  
555
                        if(HottKeyboard == HOTT_KEY_SET) { if(show_mag) show_mag = 0; else show_mag = 1;}
556
                        else
557
                        if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page = 1; line = 0;};
558
                        HottKeyboard = 0;
559
                        break;
560
   default:  line = 0;
561
                        break;
562
  }
563
  else
564
  if(page == 1)
565
  switch(line++)
566
  {
567
        case 0:  
568
                if(FC_StatusFlags & FC_STATUS_LOWBAT)
569
                         HoTT_printfxy_BLINK(0,0," %2i:%02i  %2i.%1iV %4imAh",FlugSekunden/60,FlugSekunden%60,UBat/10, UBat%10,Capacity.UsedCapacity)
570
            else   HoTT_printfxy(0,0," %2i:%02i  %2i.%1iV %4imAh",FlugSekunden/60,FlugSekunden%60,UBat/10, UBat%10,Capacity.UsedCapacity);                         
571
                        break;
572
        case 1:  
573
                        HoTT_printfxy(0,1,"DIR:%3d%c",KompassValue, HoTT_GRAD);
574
                        if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG)
575
                          {
576
                           if(HoehenReglerAktiv)        HoTT_printfxy_INV(10,1,"ALT:%4im", (int16_t)(HoehenWert/100))
577
                           else                                         HoTT_printfxy(10,1,"ALT:%4im", (int16_t)(HoehenWert/100))
578
                           }
579
            else    HoTT_printfxy(10,1,"ALT:---- ");
580
                        HoTT_printfxy(20,1,"%c",VarioCharacter);
581
            break;
582
        case 2:
583
                        if(NaviDataOkay)
584
                        {
585
                          HoTT_printfxy(1,2,"HM:%3d%c  DIST:%3dm %c", GPSInfo.HomeBearing, HoTT_GRAD, GPSInfo.HomeDistance/10, NC_GPS_ModeCharacter);
586
            }
587
                        else
588
                        {
589
                         Hott_ClearLine(2);
590
                        }
591
                        break;
592
        case 3:
593
                        HoTT_printfxy(0,3,"PWR:%2i.%1iA (%iW) ",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10,Capacity.ActualPower);
594
                        if(FC_StatusFlags2 & FC_STATUS2_CAREFREE) HoTT_printfxy_INV(19,3,"CF") else HoTT_printfxy(19,3,"  ");
595
                        break;
596
        case 4:  
597
                        if(NaviDataOkay)
598
                        {
599
                                HoTT_printfxy(0,4,"GPS:%2um/s SAT:%d ",GPSInfo.Speed,GPSInfo.NumOfSats);
600
                                switch (GPSInfo.SatFix)
601
                                {
602
                                        case SATFIX_3D:
603
                                                HoTT_printfxy(16,4,"  3D ");
604
                                                break;
605
                                        //case SATFIX_2D:
606
                                        //case SATFIX_NONE:
607
                                        default:
608
                                                HoTT_printfxy_BLINK(16,4,"NOFIX");
609
                                                break;
610
                                }      
611
                                if(GPSInfo.Flags & FLAG_DIFFSOLN)
612
                                {
613
                                        HoTT_printfxy(16,4,"DGPS ");
614
                                }
615
                        }
616
                        else
617
                        {                    //012345678901234567890
618
                                HoTT_printfxy(0,4,"   No NaviCtrl       ");
619
                        }
620
                        break;
621
        case 5:
622
                        if(show_current)
623
                         {
624
                                HoTT_printfxy(0,5,"%2i.%i %2i.%i %2i.%i %2i.%iA", Motor[0].Current/10,Motor[0].Current%10,Motor[1].Current/10,Motor[1].Current%10,Motor[2].Current/10,Motor[2].Current%10,Motor[3].Current/10,Motor[3].Current%10);
625
                         }
626
                         else
627
                         {
628
                                HoTT_printfxy(0,5,"%3i %3i %3i %3i%cC", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature,HoTT_GRAD);
629
                         }
630
                        break;
631
        case 6:
632
                        if(show_current)
633
                         {
634
                    if(RequiredMotors == 4) Hott_ClearLine(6);
635
                                else
636
                                if(RequiredMotors == 6)  HoTT_printfxy(0,6,"%2i.%i %2i.%iA", Motor[4].Current/10,Motor[4].Current%10,Motor[5].Current/10,Motor[5].Current%10)
637
                                else
638
                                if(RequiredMotors > 6)   HoTT_printfxy(0,6,"%2i.%i %2i.%i %2i.%i %2i.%iA", Motor[4].Current/10,Motor[4].Current%10,Motor[5].Current/10,Motor[5].Current%10,Motor[6].Current/10,Motor[6].Current%10,Motor[7].Current/10,Motor[7].Current%10);
639
             }
640
                         else
641
                         {
642
                    if(RequiredMotors == 4) Hott_ClearLine(6);
643
                                else
644
                                if(RequiredMotors == 6)  HoTT_printfxy(0,6,"%3i %3i%cC        ", Motor[4].Temperature, Motor[5].Temperature,HoTT_GRAD)
645
                                else
646
                                if(RequiredMotors > 6)   HoTT_printfxy(0,6,"%3i %3i %3i %3i%cC", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature,HoTT_GRAD);
647
             }
648
                        break;
649
        case 7: if(NC_ErrorCode)
650
                  {
651
                           if(HoTTBlink && NC_ErrorCode < MAX_ERR_NUMBER)
652
                            {
653
                             Hott_ClearLine(7);
654
                             HoTT_printfxy_INV(0,7,"ERR: %2d !",NC_ErrorCode);
655
                            }
656
                                else
657
                                {
658
                                 HoTT_printfxy(0,7,"ERR: ");     _printf_P(&LIBFC_HoTT_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0);};
659
                                }
660
                        else
661
                        if(FC_StatusFlags & FC_STATUS_LOWBAT) HoTT_printfxy(1,7,"!! LiPo voltage !!")
662
                        else HoTT_printfxy(0,7," www.MikroKopter.de  ");
663
                        break;
664
        case 8: // ASCIIPacket.WarnBeep = HoTT_Waring();
665
                        // ASCIIPacket.WarnBeep = Parameter_UserParam1;
666
        case 9:
667
        case 10:
668
        case 11:
669
        case 12:
670
        case 13:
671
        case 14:  
672
        case 15:  
673
        case 16:  
674
                        if(HottKeyboard == HOTT_KEY_SET) { if(show_current) show_current = 0; else show_current = 1;   Hott_ClearLine(5);  Hott_ClearLine(6);}
675
                        else
676
                        if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page = 2; line = 0;}
677
                        else
678
                        if(HottKeyboard == HOTT_KEY_RIGHT) { LIBFC_HoTT_Clear(); page = 0; line = 0;}
679
//if(HottKeyboard) HoTT_printfxy(15,6,"%KEY:%02x ",HottKeyboard);
680
                        HottKeyboard = 0;
681
                        break;
682
   default:  line = 0;
683
                        break;
684
  }
685
  else
686
  if(page == 2)
687
  switch(line++)
688
  {
689
        case 0:  
690
                        HoTT_printfxy_INV(0,0,"Setting:%u %s ",GetActiveParamSet(),EE_Parameter.Name);
691
                        break;
692
    case 1: HoTT_printfxy(0,1,"Min:%2i.%1iV %s ",BattLowVoltageWarning/10, BattLowVoltageWarning%10, Mixer.Name);
693
                        break;
694
    case 2:  HoTT_printfxy(0,2,"ALT:");
695
                 if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG)
696
                 {
697
                          if(!(EE_Parameter.GlobalConfig & CFG_HOEHEN_SCHALTER)) HoTT_printf("POTI:%3u ", Parameter_HoehenSchalter)
698
                          else
699
                          {
700
                           if(Parameter_HoehenSchalter > 50) HoTT_printf("(ON)  ") else HoTT_printf("(OFF) ");
701
                           if((Parameter_ExtraConfig & CFG2_HEIGHT_LIMIT)) HoTT_printf("LIMIT", Parameter_HoehenSchalter)
702
                           else HoTT_printf("VARIO", Parameter_HoehenSchalter);
703
                          }
704
                         }
705
                        else
706
                                HoTT_printf("DISABLED");
707
                        break;
708
    case 3: HoTT_printfxy(0,3,"CF:");
709
                        if(!EE_Parameter.CareFreeModeControl) HoTT_printf("DISABLED")
710
                        else
711
                         {
712
                          if(CareFree)  HoTT_printf(" (ON) ") else HoTT_printf(" (OFF)");
713
                          if(EE_Parameter.ExtraConfig & CFG_LEARNABLE_CAREFREE) HoTT_printf(" TEACH");
714
                         }
715
                        break;
716
    case 4: HoTT_printfxy(0,4,"GPS:");
717
                    if(!(Parameter_GlobalConfig & CFG_GPS_AKTIV)) HoTT_printf("DISABLED")
718
                        else
719
                         {
720
                          CHK_POTI(tmp,EE_Parameter.NaviGpsModeControl);
721
                          if(tmp < 50) HoTT_printf("(FREE)")
722
                          else
723
                          if(tmp >= 180) HoTT_printf("(HOME)")
724
                          else
725
                          if(EE_Parameter.ExtraConfig & CFG_GPS_AID) HoTT_printf("(AID) ")
726
                          else HoTT_printf("(HOLD)")
727
                         }
728
                        if(EE_Parameter.FailSafeTime) HoTT_printfxy(10,4," FS:%usek ",EE_Parameter.FailSafeTime)
729
 
730
                        break;
731
    case 5: HoTT_printfxy(0,5,"HOME ALT:");
732
                        if(EE_Parameter.ComingHomeAltitude) HoTT_printf("%um",EE_Parameter.ComingHomeAltitude) else HoTT_printf("HOLD ");
733
                        break;
734
        case 6:
735
                        if(!show_poti)
736
                         {
737
              HoTT_printfxy(0,6,"Ni:%4i Ro:%4i C:%3i",PPM_in[EE_Parameter.Kanalbelegung[K_NICK]],PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]], Parameter_ServoNickControl);
738
                      HoTT_printfxy(0,7,"Gs:%4i Ya:%4i ",PPM_in[EE_Parameter.Kanalbelegung[K_GAS]]+127,PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]);
739
                         }
740
                        else
741
                         {
742
              HoTT_printfxy(0,6,"P1:%4i P2:%4i 3:%3i",Poti1,Poti2, Poti3);
743
                      HoTT_printfxy(0,7,"P4:%4i P5:%4i 6:%3i",Poti4,Poti5, Poti6);
744
                         }
745
 
746
                        break;
747
    case 7: //HoTT_printfxy(0,6,"WARNINGS:");
748
                        if(HoTTBlink)
749
                        {
750
                         LIBFC_HoTT_SetPos(6 * 21);
751
                         if(!(Parameter_GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV)) HoTT_printf_BLINK("COUPLING OFF! ");
752
                         if(EE_Parameter.BitConfig & (CFG_LOOP_LINKS | CFG_LOOP_RECHTS | CFG_LOOP_UNTEN | CFG_LOOP_OBEN)) HoTT_printf_BLINK("LOOPING! ");
753
                         if(Parameter_GlobalConfig & CFG_HEADING_HOLD) HoTT_printf_BLINK("HH! ");
754
                         if(!(Parameter_GlobalConfig & CFG_KOMPASS_AKTIV)) HoTT_printf_BLINK("COMPASS OFF! ");
755
                        }
756
                        break;
757
    case 8: //ASCIIPacket.WarnBeep = HoTT_Waring();
758
                        break;
759
    case 9:
760
    case 10:
761
    case 11:
762
    case 12:
763
    case 13:
764
    case 14:
765
    case 15:
766
    case 16:
767
                        if(HottKeyboard == HOTT_KEY_SET) { if(show_poti) show_poti = 0; else show_poti = 1;   Hott_ClearLine(6);  Hott_ClearLine(7);}
768
//                      else
769
//                      if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page = 3; line = 0;}
770
                        else
771
                        if(HottKeyboard == HOTT_KEY_RIGHT) { LIBFC_HoTT_Clear(); page = 1; line = 0;};
772
                        HottKeyboard = 0;
773
                        break;
774
   default:  line = 0;
775
                        break;
776
  }
777
/*  else
778
  if(page == 3)
779
  switch(line++)
780
  {
781
        case 0:  
782
                        HoTT_printfxy(0,2,"Speak:");
783
                        break;
784
        case 1:  
785
//                      if(GetParamByte(PID_SPEAK_HOTT_CFG) & 0x01)
786
                        if(!(GlobalConfig3 & CFG3_SPEAK_ALL) & 0x01)) HoTT_printfxy_INV(7,2,"All Messages ")
787
                        else                    HoTT_printfxy_INV(7,2,"Warnings only");
788
                        break;
789
        case 2:  
790
                        HoTT_printfxy(1,4,"Use (set) to select");
791
                        break;
792
    default:
793
                        if(HottKeyboard == HOTT_KEY_SET)
794
                         {
795
                          SetParamByte(PID_SPEAK_HOTT_CFG, GetParamByte(PID_SPEAK_HOTT_CFG) ^ 0x01);
796
                         }
797
                        else
798
                        if(HottKeyboard == HOTT_KEY_RIGHT) { LIBFC_HoTT_Clear(); page = 2; line = 0;};
799
                        HottKeyboard = 0;
800
                        line = 0;
801
                        break;
802
  }
803
*/
804
  else page = 0;
805
}
806
 
807
#endif
808
 
809
 
810