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
unsigned char NaviData_WaypointIndex = 0;
60
unsigned char NaviData_WaypointNumber = 0, NaviData_TargetHoldTime = 0, ToNC_Load_WP_List = 0, NaviData_MaxWpListIndex = 0;
61
unsigned char ToNC_Load_SingePoint = 0, ToNC_Store_SingePoint = 0;
62
char WPL_Name[10];// = {"         \0"};
63
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
64
 
65
#define HoTT_printf(format, args...)                    {  _printf_P(&LIBFC_HoTT_Putchar, PSTR(format) , ## args);}
66
#define HoTT_printfxy(x,y,format, args...)              { LIBFC_HoTT_SetPos((y) * 21 + (x)); _printf_P(&LIBFC_HoTT_Putchar, PSTR(format) , ## args);}
67
#define HoTT_printfxy_INV(x,y,format, args...)          { LIBFC_HoTT_SetPos((y) * 21 + (x)); _printf_P(&LIBFC_HoTT_Putchar_INV, PSTR(format) , ## args);}
68
#define HoTT_printfxy_BLINK(x,y,format, args...)        { LIBFC_HoTT_SetPos((y) * 21 + (x)); _printf_P(&LIBFC_HoTT_Putchar_BLINK, PSTR(format) , ## args);}
69
#define HoTT_printf_BLINK(format, args...)              { _printf_P(&LIBFC_HoTT_Putchar_BLINK, PSTR(format) , ## args);}
70
#define HoTT_printf_INV(format, args...)                        { _printf_P(&LIBFC_HoTT_Putchar_INV, PSTR(format) , ## args);}
71
 
72
#define VOICE_MINIMALE_EINGANSSPANNUNG    16
73
#define VOICE_BEEP                         5
74
#define HoTT_GRAD       96
75
#define HoTT_LINKS      123
76
#define HoTT_RECHTS 124
77
#define HoTT_OBEN       125
78
#define HoTT_UNTEN      126
79
 
80
#define HOTT_KEY_RIGHT  1
81
#define HOTT_KEY_DOWN   2
82
#define HOTT_KEY_UP     4
83
#define HOTT_KEY_SET    6
84
#define HOTT_KEY_LEFT   8
85
 
86
#define VARIO_ZERO 30000
87
unsigned int NaviData_TargetDistance = 0;
88
 
89
unsigned char MaxBlTemperture = 0;
90
unsigned char MinBlTemperture = 0;
91
unsigned char HottestBl = 0;
92
 
93
GPSPacket_t GPSPacket;
94
VarioPacket_t VarioPacket;
95
ASCIIPacket_t ASCIIPacket;
96
ElectricAirPacket_t ElectricAirPacket;
97
HoTTGeneral_t HoTTGeneral;
98
unsigned char SpeakHoTT = SPEAK_MIKROKOPTER;
99
unsigned char ToNC_SpeakHoTT = 0, ShowSettingNameTime = 0;
100
int HoTTVarioMeter = 0;
101
const char PROGMEM MIKROKOPTER[] =      {"     MikroKopter     "};
102
const char PROGMEM UNDERVOLTAGE[] =     {" !! LiPo voltage !!  "};
103
const char PROGMEM LANDING[] =      {" !!   LANDING    !!  "};
104
const char PROGMEM SIMULATION[] =       {"  SIMULATION active  "};
105
const char PROGMEM BOAT_MODE[] =        {" MikroKopter (Boat)  "};
106
const char PROGMEM SETTING[] =  {"Set  :"};
107
const char PROGMEM NC_ERROR_TEXT[MAX_ERR_NUMBER][17] =
108
{
109
//0123456789123456
110
 "No Error        \0",  // 0
111
 "Not compatible  \0",  // 1
112
 "MK3Mag not compa\0",  // 2
113
 "No FC communicat\0",  // 3
114
 "Compass communic\0",  // 4
115
 "GPS communicatio\0",  // 5
116
 "compass value   \0",  // 6
117
 "RC Signal lost  \0",  // 7
118
 "FC spi rx error \0",  // 8
119
 "No NC communicat\0",  // 9
120
 "FC Nick Gyro    \0",  // 10
121
 "FC Roll Gyro    \0",  // 11
122
 "FC Yaw Gyro     \0",  // 12
123
 "FC Nick ACC     \0",  // 13
124
 "FC Roll ACC     \0",  // 14
125
 "FC Z-ACC        \0",  // 15
126
 "Pressure sensor \0",  // 16
127
 "I2C FC->BL-Ctrl \0",  // 17
128
 "Bl Missing      \0",  // 18
129
 "Mixer Error     \0",  // 19
130
 "Carefree Error  \0",  // 20
131
 "GPS Fix lost    \0",  // 21
132
 "Magnet Error    \0",  // 22
133
 "Motor restart   \0",  // 23
134
 "BL Limitation   \0",  // 24
135
 "GPS Range       \0",  // 25
136
 "No SD-Card      \0",  // 26
137
 "SD-Logging error\0",  // 27
138
 "Flying range!   \0",  // 28
139
 "Max Altitude!   \0",  // 29
140
 "No GPS fix      \0",  // 30
141
 "compass not cal.\0",  // 31
142
 "BL-Selftest     \0",  // 32
143
 "no ext. compass \0",  // 33
144
 "compass sensor  \0",  // 34
145
 "Failsafe postion\0",  // 35
146
 "No Redundancy!  \0",  // 36
147
 "Redundancy test \0",  // 37
148
 "GPS Update Rate \0"   // 38
149
 };
150
 
151
 
152
const char PROGMEM HOTT_ERROR[MAX_ERR_NUMBER][2] =
153
{       // 1 -> only in flight   0 -> also on ground
154
//0123456789123456
155
         {0,0},// "No Error        \0",  // 0
156
         {SPEAK_ERROR,0},               // "Not compatible  \0",        // 1
157
         {SPEAK_ERROR,0},               // "MK3Mag not compa\0",        // 2
158
         {SPEAK_ERR_NAVI,1},    // "No FC communicat\0",        // 3
159
         {SPEAK_ERR_COMPASS,1}, // "MK3Mag communica\0",        // 4
160
         {SPEAK_ERR_GPS,0},             // "GPS communicatio\0",        // 5
161
         {SPEAK_ERR_COMPASS,1}, // "compass value   \0",        // 6
162
         {SPEAK_ERR_RECEICER,0},// "RC Signal lost  \0",        // 7
163
         {SPEAK_ERR_NAVI,0},    // "FC spi rx error \0",        // 8
164
         {SPEAK_ERR_NAVI,0},    // "No NC communicat\0",        // 9
165
         {SPEAK_ERR_SENSOR,0},  // "FC Nick Gyro    \0",        // 10
166
         {SPEAK_ERR_SENSOR,0},  // "FC Roll Gyro    \0",        // 11
167
         {SPEAK_ERR_SENSOR,0},  // "FC Yaw Gyro     \0",        // 12
168
         {SPEAK_ERR_SENSOR,0},  // "FC Nick ACC     \0",        // 13
169
         {SPEAK_ERR_SENSOR,0},  // "FC Roll ACC     \0",        // 14
170
         {SPEAK_ERR_SENSOR,0},  // "FC Z-ACC        \0",        // 15
171
         {SPEAK_ERR_SENSOR,0},  // "Pressure sensor \0",        // 16
172
         {SPEAK_ERR_DATABUS,1}, // "I2C FC->BL-Ctrl \0",        // 17
173
         {SPEAK_ERR_DATABUS,1}, // "Bl Missing      \0",        // 18
174
         {SPEAK_ERROR,0},               // "Mixer Error     \0",        // 19
175
         {SPEAK_CF_OFF,1},              // "Carefree Error  \0",        // 20
176
         {SPEAK_GPS_FIX,1},             // "GPS Fix lost    \0",        // 21
177
         {SPEAK_ERR_COMPASS,0}, // "Magnet Error    \0",        // 22
178
         {SPEAK_ERR_MOTOR,1},   // "Motor restart   \0",        // 23
179
         {SPEAK_MAX_TEMPERAT,1},// "BL Limitation   \0",        // 24
180
         {SPEAK_MAX_RANGE,1},   // "GPS Range       \0",        // 25
181
         {SPEAK_ERROR,1},               // "No SD-Card      \0",        // 26
182
         {SPEAK_ERROR,1},               // "SD-Logging error\0",        // 27
183
         {SPEAK_MAX_RANGE,1},   // "Flying range!   \0",        // 28
184
         {SPEAK_MAX_ALTITUD,1}, // "Max Altitude!   \0"         // 29
185
         {SPEAK_GPS_FIX,1},             // "No GPS fix      \0"         // 30
186
         {SPEAK_ERR_CALIBARTION,0},// "compass not cal."        // 31
187
         {SPEAK_ERR_MOTOR,0},   // "BL-Selftest     \0"         // 32
188
         {SPEAK_ERR_COMPASS,0}, // "no ext. compass"            // 33
189
         {SPEAK_ERR_COMPASS,0}, // "compass sensor"             // 34
190
         {SPEAK_ERROR,1},               // "Failsafe postion0",         // 35
191
         {SPEAK_ERROR,0},               // "No Redundancy!",            // 36
192
         {0,0},                                 // "Redundancy test",           // 37
193
         {SPEAK_ERR_GPS,0},             // "GPS Update Rate",           // 38
194
};
195
 
196
/*
197
//------------------------------------------------------------------------------------------
198
// HoTT-Plus
199
//------------------------------------------------------------------------------------------
200
char dummy=0;
201
const Parameter_List_t Parameter_List[] =
202
{ //offset,min,max,name,variable
203
        {127, 0, 247,"SP1", (unsigned char *) &PPM_in[13] },
204
        {127, 0, 247,"SP2", (unsigned char *) &PPM_in[14] },   
205
        {127, 0, 247,"SP3", (unsigned char *) &PPM_in[15] },   
206
        {127, 0, 247,"SP4", (unsigned char *) &PPM_in[16] },   
207
        {  0, 0, 247,"HD ", (unsigned char *) &EE_Parameter.Luftdruck_D },
208
        {  0, 0, 247,"HP ", (unsigned char *) &EE_Parameter.Hoehe_P },
209
        {  0, 0, 247,"HA ", (unsigned char *) &EE_Parameter.Hoehe_ACC_Wirkung },
210
        {  0, 0, 247,"HM ", (unsigned char *) &EE_Parameter.Hoehe_MinGas },
211
        {  0, 0, 247,"HV ", (unsigned char *) &EE_Parameter.Hoehe_HoverBand },
212
        {  0, 0, 247,"HG ", (unsigned char *) &EE_Parameter.Hoehe_Verstaerkung },
213
        {  0, 0, 247,"NG ", (unsigned char *) &EE_Parameter.NotGas },
214
        {  0, 0, 247,"StP", (unsigned char *) &EE_Parameter.Stick_P },
215
        {  0, 0, 247,"StD", (unsigned char *) &EE_Parameter.Stick_D },
216
        {  0, 0, 247,"SGP", (unsigned char *) &EE_Parameter.StickGier_P },
217
        {  0, 0, 247,"DrC", (unsigned char *) &EE_Parameter.Driftkomp },
218
        {  0, 0, 247,"GYP", (unsigned char *) &EE_Parameter.Gyro_P },
219
        {  0, 0, 247,"GYD", (unsigned char *) &EE_Parameter.Gyro_D },
220
        {  0, 0, 247,"GYI", (unsigned char *) &EE_Parameter.Gyro_I },
221
        {  0, 0, 247,"MaI", (unsigned char *) &EE_Parameter.I_Faktor },
222
        {  0, 0, 247,"GGP", (unsigned char *) &EE_Parameter.Gyro_Gier_P },
223
        {  0, 0, 247,"GGI", (unsigned char *) &EE_Parameter.Gyro_Gier_I },
224
        {  0, 0,  15,"GSt", (unsigned char *) &EE_Parameter.Gyro_Stability },
225
        {  0, 0, 247,"DSt", (unsigned char *) &EE_Parameter.DynamicStability },
226
        {  0, 0, 247,"NGG", (unsigned char *) &EE_Parameter.NaviGpsGain },
227
        {  0, 0, 247,"NWC", (unsigned char *) &EE_Parameter.NaviWindCorrection },
228
        {  0, 0, 247,"NSC", (unsigned char *) &EE_Parameter.NaviAccCompensation },
229
        {  0, 0, 247,"NAL", (unsigned char *) &EE_Parameter.NaviAngleLimitation },
230
        {  0, 0, 247,"NP ", (unsigned char *) &EE_Parameter.NaviGpsP },
231
        {  0, 0, 247,"ND ", (unsigned char *) &EE_Parameter.NaviGpsI },
232
        {  0, 0, 247,"NI ", (unsigned char *) &EE_Parameter.NaviGpsD },
233
        {  0, 0, 247,"LGL", (unsigned char *) &EE_Parameter.LoopGasLimit },
234
        {  0, 0, 247,"LHy", (unsigned char *) &EE_Parameter.LoopHysterese },
235
        {  0, 0, 247,"LTh", (unsigned char *) &EE_Parameter.LoopThreshold },
236
        {  0, 0,   0,"   ", (unsigned char *) &dummy },
237
        {  0, 0, 247,"FGP", (unsigned char *) &EE_Parameter.AchsKopplung1},
238
        {  0, 0, 247,"FNR", (unsigned char *) &EE_Parameter.AchsKopplung2},
239
        {  0, 0, 247,"CYC", (unsigned char *) &EE_Parameter.CouplingYawCorrection},
240
        {  0, 0, 247,"MSH", (unsigned char *) &EE_Parameter.MotorSmooth},
241
        {  0, 0, 247,"NCT", (unsigned char *) &EE_Parameter.ServoNickControl },
242
        {  0, 0, 247,"NCP", (unsigned char *) &EE_Parameter.ServoNickComp },
243
        {  0, 0, 247,"RCT", (unsigned char *) &EE_Parameter.ServoRollControl },
244
        {  0, 0, 247,"RCP", (unsigned char *) &EE_Parameter.ServoRollComp }
245
};
246
unsigned char settingdest = 0;
247
//------------------------------------------------------------------------------------------
248
// HoTT-Plus
249
//------------------------------------------------------------------------------------------
250
*/
251
void GetHottestBl(void)
252
{
253
 static unsigned char search = 0,tmp_max,tmp_min,who;
254
                if(Motor[search].Temperature > tmp_max) { tmp_max = Motor[search].Temperature; who = search;}
255
                else
256
                if(Motor[search].Temperature) if(Motor[search].Temperature < tmp_min) tmp_min = Motor[search].Temperature;
257
                if(++search >= MAX_MOTORS)
258
                {
259
                 search = 0;
260
                 if(tmp_min != 255) MinBlTemperture = tmp_min; else MinBlTemperture = 0;
261
                 MaxBlTemperture = tmp_max;
262
                 HottestBl = who;
263
                 tmp_min = 255;
264
                 tmp_max = 0;
265
                 who = 0;
266
                 }
267
}
268
 
269
//---------------------------------------------------------------
270
void Hott_ClearLine(unsigned char line)
271
{
272
 HoTT_printfxy(0,line,"                     ");
273
}
274
//---------------------------------------------------------------
275
 
276
 
277
unsigned char HoTT_Waring(void)
278
{
279
  unsigned char status = 0;
280
  static char old_status = 0;
281
  static int repeat;
282
//if(Parameter_UserParam1) SpeakHoTT = Parameter_UserParam1;
283
  ToNC_SpeakHoTT = SpeakHoTT;
284
  if(FC_StatusFlags & FC_STATUS_LOWBAT)
285
   {
286
    if(LowVoltageLandingActive && (EE_Parameter.Receiver == RECEIVER_HOTT)) status = SPEAK_LANDING;
287
        else status = VOICE_MINIMALE_EINGANSSPANNUNG; // Jeti hat kein wort: "LANDEN"
288
        if(SpeakHoTT && old_status == VOICE_MINIMALE_EINGANSSPANNUNG) status = SpeakHoTT; // das soll auch noch durch kommen
289
   }   
290
  else
291
  if(NC_ErrorCode && NC_ErrorCode < MAX_ERR_NUMBER)     // Fehlercodes
292
   {
293
    if(MotorenEin || !pgm_read_byte(&HOTT_ERROR[NC_ErrorCode][1])) status = pgm_read_byte(&HOTT_ERROR[NC_ErrorCode][0]);
294
   }
295
  if(!status)    // Sprachansagen
296
   {
297
//      if(!(GetParamByte(PID_SPEAK_HOTT_CFG) & 0x01)) SpeakHoTT = 0;  // is the voice wanted?
298
    if(!(EE_Parameter.GlobalConfig3 & CFG3_SPEAK_ALL)) SpeakHoTT = 0;  // is the voice wanted?
299
    else status = SpeakHoTT;
300
   }
301
   else ToNC_SpeakHoTT = status;
302
 
303
  if(old_status == status) // Gleichen Fehler nur alle 4 sek bringen
304
   {
305
    if(!CheckDelay(repeat)) return(0);
306
        repeat = SetDelay(4000);
307
   }
308
   else repeat = SetDelay(2000);
309
 
310
  if(status)
311
   {
312
    if(status == SpeakHoTT) SpeakHoTT = 0;
313
   }   
314
  old_status = status;
315
//  DebugOut.Analog[16] = status;
316
  return(status);
317
}
318
 
319
//---------------------------------------------------------------
320
void NC_Fills_HoTT_Telemety(void)
321
{
322
 unsigned char *ptr = NULL;
323
 unsigned char max = 0,i,z;
324
 switch(FromNaviCtrl.Param.Byte[11])
325
  {
326
   case HOTT_VARIO_PACKET_ID:
327
                ptr = (unsigned char *) &VarioPacket;
328
                max = sizeof(VarioPacket);
329
                break;
330
   case HOTT_GPS_PACKET_ID:
331
                ptr = (unsigned char *) &GPSPacket;
332
                max = sizeof(GPSPacket);
333
                break;
334
   case HOTT_ELECTRIC_AIR_PACKET_ID:
335
                ptr = (unsigned char *) &ElectricAirPacket;
336
                max = sizeof(ElectricAirPacket);
337
                break;
338
   case HOTT_GENERAL_PACKET_ID:
339
                ptr = (unsigned char *) &HoTTGeneral;
340
                max = sizeof(HoTTGeneral);
341
                break;
342
   case JETI_GPS_PACKET_ID1:
343
                ptr = (unsigned char *) &JetiExData[14].Value;
344
                max = sizeof(JetiExData[14].Value);
345
                break;
346
   case JETI_GPS_PACKET_ID2:
347
                ptr = (unsigned char *) &JetiExData[15].Value;
348
                max = sizeof(JetiExData[15].Value);
349
                break;
350
   case HOTT_WPL_NAME:
351
                ptr = (unsigned char *) WPL_Name;
352
                max = sizeof(WPL_Name)-1;
353
                break;
354
 
355
  }
356
 z = FromNaviCtrl.Param.Byte[0]; // Data allocation
357
 
358
 for(i=0; i < FromNaviCtrl.Param.Byte[1]; i++)
359
  {
360
   if(z >= max) break;
361
   ptr[z] = FromNaviCtrl.Param.Byte[2+i];
362
   z++;
363
  }
364
}
365
 
366
unsigned int BuildHoTT_Vario(void)
367
{
368
 unsigned int tmp = VARIO_ZERO;
369
 if(VarioCharacter == '+' || VarioCharacter == '-')
370
  {
371
   tmp = VARIO_ZERO + (AltitudeSetpointTrimming * EE_Parameter.Hoehe_Verstaerkung) / 3;
372
   if(tmp < VARIO_ZERO && tmp > VARIO_ZERO - 50) tmp = VARIO_ZERO - 50; // weil es sonst erst bei < 0,5m/sek piept
373
  }
374
 else
375
 if((VarioCharacter == ' ') && (FC_StatusFlags & FC_STATUS_FLY))
376
  {
377
   tmp = VARIO_ZERO + HoTTVarioMeter;
378
   if(tmp > VARIO_ZERO)
379
    {
380
     if(tmp < VARIO_ZERO + 100) tmp = VARIO_ZERO;
381
         else tmp -= 100;
382
        }
383
   if(tmp < VARIO_ZERO)
384
    {
385
     if(tmp > VARIO_ZERO - 100) tmp = VARIO_ZERO;
386
         else tmp += 100;
387
        }
388
  }
389
 else
390
 if(VarioCharacter == '^') tmp = VARIO_ZERO + FromNC_AltitudeSpeed * 10;
391
 else
392
 if(VarioCharacter == 'v') tmp = VARIO_ZERO - FromNC_AltitudeSpeed * 10;
393
 return(tmp);
394
}
395
 
396
//---------------------------------------------------------------
397
unsigned char HoTT_Telemety(unsigned char packet_request)
398
{
399
 unsigned char i = 0;
400
 static unsigned char SpeechMessage = 0;
401
  //Debug("rqst: %02X",packet_request);
402
 
403
 switch(packet_request)
404
 {
405
  case HOTT_VARIO_PACKET_ID:
406
                if(GPSPacket.WarnBeep == SpeechMessage) SpeechMessage = HoTT_Waring(); // Achtung: das ist richtig hier, damit der Varioton schon vorher abgestellt wird
407
 
408
                VarioPacket.Altitude = HoehenWert/100 + 500;  
409
                if(!SpeechMessage) VarioPacket.m_sec = BuildHoTT_Vario(); else VarioPacket.m_sec = VARIO_ZERO;
410
                VarioPacket.m_3sec = VarioPacket.m_sec;
411
                VarioPacket.m_10sec = VarioPacket.m_sec;
412
                if (VarioPacket.Altitude < VarioPacket.MinAltitude) VarioPacket.MinAltitude = VarioPacket.Altitude;
413
                if (VarioPacket.Altitude > VarioPacket.MaxAltitude) VarioPacket.MaxAltitude = VarioPacket.Altitude;            
414
                VarioPacket.WarnBeep = 0;//HoTT_Waring();
415
                HoTT_DataPointer = (unsigned char *) &VarioPacket;
416
        VarioPacket.FreeCharacters[0] = VarioCharacter;
417
    if(FC_StatusFlags2 & FC_STATUS2_CAREFREE) VarioPacket.FreeCharacters[1] = 'C'; else VarioPacket.FreeCharacters[1] = ' ';
418
//      VarioPacket.FreeCharacters[2] = ' ';
419
    if(NC_ErrorCode)
420
         {
421
                VarioPacket.Text[0] = NC_ErrorCode/10 + '0';
422
                VarioPacket.Text[1] = NC_ErrorCode%10 + '0';
423
                VarioPacket.Text[2] = ':';
424
                for(i=0; i<16;i++) VarioPacket.Text[i+3] = pgm_read_byte(&NC_ERROR_TEXT[NC_ErrorCode][i]);
425
                VarioPacket.Text[19] = ' ';
426
                VarioPacket.Text[20] = ' ';
427
         }
428
         else
429
         if(LowVoltageLandingActive) for(i=0; i<21;i++) VarioPacket.Text[i] = pgm_read_byte(&LANDING[i]); // no Error
430
     else
431
         if(FC_StatusFlags & FC_STATUS_LOWBAT) for(i=0; i<21;i++) VarioPacket.Text[i] = pgm_read_byte(&UNDERVOLTAGE[i]); // no Error
432
         else
433
         if(ShowSettingNameTime) // no Error
434
         {                  
435
          for(i=0; i<sizeof(SETTING);i++) VarioPacket.Text[i] = pgm_read_byte(&SETTING[i]);
436
      VarioPacket.Text[4] = '0' + ActiveParamSet;
437
          for(i=0; i<sizeof(EE_Parameter.Name);i++) VarioPacket.Text[i+7] = EE_Parameter.Name[i]; // no Error
438
      if(FC_StatusFlags3 & FC_STATUS3_BOAT)
439
                {
440
         VarioPacket.Text[17] = 'B';
441
         VarioPacket.Text[18] = 'O';
442
         VarioPacket.Text[19] = 'A';
443
         VarioPacket.Text[20] = 'T';
444
                }
445
          else
446
                {
447
         VarioPacket.Text[18] = ' ';
448
         VarioPacket.Text[19] = ' ';
449
         VarioPacket.Text[20] = ' ';
450
                }
451
         }
452
         else    
453
     if(NaviData_WaypointNumber)
454
         {    
455
          unsigned int tmp_int;
456
      unsigned char tmp;
457
      VarioPacket.Text[0] = 'W'; VarioPacket.Text[1] = 'P';
458
      VarioPacket.Text[2] = ' ';
459
      VarioPacket.Text[3] = '0'+(NaviData_WaypointIndex) / 10;
460
      VarioPacket.Text[4] = '0'+(NaviData_WaypointIndex) % 10;
461
      VarioPacket.Text[5] = '/';
462
      VarioPacket.Text[6] = '0'+(NaviData_WaypointNumber) / 10;
463
      VarioPacket.Text[7] = '0'+(NaviData_WaypointNumber) % 10;
464
      VarioPacket.Text[8] = ' ';
465
          tmp_int = NaviData_TargetDistance;
466
      if(tmp_int > 1000) { VarioPacket.Text[9] = '0'+(tmp_int) / 1000; tmp_int %= 1000;}
467
          else VarioPacket.Text[9] = ' ';
468
      if(tmp_int > 100) { VarioPacket.Text[10] = '0'+(tmp_int) / 100; tmp_int %= 100;}
469
          else VarioPacket.Text[10] = ' ';
470
      VarioPacket.Text[11] = '0'+(tmp_int) / 10;
471
      VarioPacket.Text[12] = '0'+(tmp_int) % 10;
472
      VarioPacket.Text[13] = 'm';
473
      VarioPacket.Text[14] = ' ';
474
      tmp = NaviData_TargetHoldTime;
475
          if(tmp > 100) { VarioPacket.Text[15] = '0'+(tmp) / 100; tmp %= 100;} else VarioPacket.Text[15] = ' ';
476
      VarioPacket.Text[16] = '0'+(tmp) / 10;
477
      VarioPacket.Text[17] = '0'+(tmp) % 10;
478
      VarioPacket.Text[18] = 's';
479
      VarioPacket.Text[19] = ' ';
480
      VarioPacket.Text[20] = ' ';
481
         }
482
         else
483
         if(NC_To_FC_Flags & NC_TO_FC_SIMULATION_ACTIVE)
484
         {
485
          for(i=0; i<21;i++) VarioPacket.Text[i] = pgm_read_byte(&SIMULATION[i]);
486
         }
487
         else
488
         if(!CalibrationDone)
489
         {
490
          for(i=0; i<17;i++) VarioPacket.Text[i] = pgm_read_byte(&MIKROKOPTER[i+2]); // no Error and not calibrated
491
      VarioPacket.Text[16] = '0'+VERSION_MAJOR;
492
      VarioPacket.Text[17] = '.';
493
      VarioPacket.Text[18] = '0'+VERSION_MINOR/10;
494
      VarioPacket.Text[19] = '0'+VERSION_MINOR%10;
495
      VarioPacket.Text[20] = 'a'+VERSION_PATCH;
496
         }
497
         else
498
         {
499
          if(FC_StatusFlags3 & FC_STATUS3_BOAT) for(i=0; i<21;i++) VarioPacket.Text[i] = pgm_read_byte(&BOAT_MODE[i]); // no Error
500
          else  for(i=0; i<21;i++) VarioPacket.Text[i] = pgm_read_byte(&MIKROKOPTER[i]); // no Error
501
          if(FC_StatusFlags3 & FC_STATUS3_REDUNDANCE_AKTIVE)  VarioPacket.Text[0] = 'R';
502
         }
503
                return(sizeof(VarioPacket));
504
                break;
505
 
506
  case HOTT_GPS_PACKET_ID:
507
                GPSPacket.Altitude = HoehenWert/100 + 500;  
508
//              GPSPacket.Distance = GPSInfo.HomeDistance/10;  // macht die NC
509
//              GPSPacket.Heading = GPSInfo.HomeBearing/2;     // macht die NC
510
//              GPSPacket.Speed = (GPSInfo.Speed * 36) / 10;   // macht die NC
511
                GPSPacket.WarnBeep = SpeechMessage;
512
                if(!GPSPacket.WarnBeep) GPSPacket.m_sec = BuildHoTT_Vario(); else GPSPacket.m_sec = VARIO_ZERO;
513
                GPSPacket.m_3sec = 120;
514
                GPSPacket.NumOfSats = GPSInfo.NumOfSats;
515
                if(GPSInfo.Flags & FLAG_DIFFSOLN) GPSPacket.SatFix = 'D';
516
                else
517
        if(GPSInfo.SatFix == SATFIX_3D) GPSPacket.SatFix = ' ';
518
                else GPSPacket.SatFix = '!';
519
                HoTT_DataPointer = (unsigned char *) &GPSPacket;
520
                GPSPacket.FreeCharacters[0] = NC_GPS_ModeCharacter;
521
                GPSPacket.FreeCharacters[2] = GPSPacket.SatFix;
522
                GPSPacket.HomeDirection = GPSInfo.HomeBearing / 2;//230;
523
                return(sizeof(GPSPacket));  
524
                break;
525
  case HOTT_ELECTRIC_AIR_PACKET_ID:
526
                GetHottestBl();
527
                ElectricAirPacket.Altitude = HoehenWert/100 + 500;
528
                ElectricAirPacket.Battery1 = UBat;
529
                ElectricAirPacket.Battery2 = UBat;
530
                ElectricAirPacket.VoltageCell1 = CompassCorrected / 2;
531
                ElectricAirPacket.VoltageCell8 = ElectricAirPacket.VoltageCell1;
532
                ElectricAirPacket.VoltageCell6 = GPSInfo.HomeBearing / 2;
533
                ElectricAirPacket.VoltageCell7 = GPSInfo.HomeDistance/20;
534
                ElectricAirPacket.VoltageCell13 = ElectricAirPacket.VoltageCell6;
535
                ElectricAirPacket.VoltageCell14 = ElectricAirPacket.VoltageCell7;
536
        if(!SpeechMessage) ElectricAirPacket.m_sec = BuildHoTT_Vario(); else ElectricAirPacket.m_sec = VARIO_ZERO;
537
                ElectricAirPacket.m_3sec = 120;
538
                ElectricAirPacket.InputVoltage = UBat;
539
                ElectricAirPacket.Temperature1 = MinBlTemperture + 20;
540
                ElectricAirPacket.Temperature2 = MaxBlTemperture + 20;
541
                ElectricAirPacket.Capacity = Capacity.UsedCapacity/10;
542
                ElectricAirPacket.WarnBeep = 0;//HoTT_Waring();
543
//ElectricAirPacket.WarnBeep = SpeechMessage;
544
                ElectricAirPacket.Current = Capacity.ActualCurrent;
545
                HoTT_DataPointer = (unsigned char *) &ElectricAirPacket;
546
                ElectricAirPacket.FlightTimeMinutes = FlugSekunden / 60;
547
                ElectricAirPacket.FlightTimeSeconds = FlugSekunden % 60;
548
                return(sizeof(ElectricAirPacket));
549
                break;
550
  case HOTT_GENERAL_PACKET_ID:
551
                GetHottestBl();
552
                HoTTGeneral.Rpm = GPSInfo.HomeDistance/100;
553
                HoTTGeneral.VoltageCell1 = CompassCorrected / 2;
554
                HoTTGeneral.VoltageCell2 = KompassValue / 2;
555
                //HoTTGeneral.VoltageCell3 = Magnetstaerke -> macht NC
556
                //HoTTGeneral.VoltageCell4 = Inclinition -> macht NC
557
                HoTTGeneral.VoltageCell5 = DebugOut.Analog[28]; // I2C ErrorCounter
558
                HoTTGeneral.VoltageCell6 = GPSInfo.HomeBearing / 2;
559
                if(UBat > BattLowVoltageWarning + 2) HoTTGeneral.FuelPercent = (UBat - (BattLowVoltageWarning + 2)) * 3;
560
                else HoTTGeneral.FuelPercent = 0;
561
                if(HoTTGeneral.FuelPercent > 100) HoTTGeneral.FuelPercent = 100;
562
                HoTTGeneral.FuelCapacity = NC_ErrorCode;//HoehenWert/100; // Oelpegel
563
//              if(HoTTGeneral.FuelCapacity < 0) HoTTGeneral.FuelCapacity = 0;
564
                HoTTGeneral.Altitude = HoehenWert/100 + 500;
565
                HoTTGeneral.Battery1 = UBat;
566
                HoTTGeneral.Battery2 = UBat;
567
                if(!SpeechMessage) HoTTGeneral.m_sec =  BuildHoTT_Vario(); else  HoTTGeneral.m_sec = VARIO_ZERO;
568
                HoTTGeneral.m_3sec = 120 + SpeechMessage;
569
                HoTTGeneral.InputVoltage = UBat;
570
                HoTTGeneral.Temperature1 = MinBlTemperture + 20;
571
                HoTTGeneral.Temperature2 = MaxBlTemperture + 20;
572
                HoTTGeneral.Capacity = Capacity.UsedCapacity/10;
573
HoTTGeneral.WarnBeep = 0;
574
                HoTTGeneral.Current = Capacity.ActualCurrent;
575
//HoTTGeneral.ErrorNumber = HoTTErrorCode();
576
                HoTT_DataPointer = (unsigned char *) &HoTTGeneral;
577
                return(sizeof(HoTTGeneral));
578
                break;
579
  default: return(0);
580
  }            
581
}
582
 
583
//---------------------------------------------------------------
584
void HoTT_Menu(void)
585
{
586
 static unsigned char line, page = 0,show_current = 0,show_mag = 0, show_poti = 0,hyterese = 1;
587
 unsigned char tmp;
588
 HoTTVarioMeter = (HoTTVarioMeter * 7 + VarioMeter) / 8;
589
 static int delay;
590
 
591
// if(HottKeyboard) {beeptime = 1000;};  
592
 
593
 switch(page)
594
 {
595
  case 0:
596
  switch(line++)
597
  {
598
        case 0:  
599
                if(FC_StatusFlags & FC_STATUS_LOWBAT)
600
                         HoTT_printfxy_BLINK(0,0,"  %2i.%1iV  ",UBat/10, UBat%10)
601
                        else
602
                         HoTT_printfxy(0,0,"  %2i.%1iV  ",UBat/10, UBat%10)
603
 
604
                        if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG)
605
                          {
606
                           if(HoehenReglerAktiv)        HoTT_printfxy_INV(10,0,"ALT:%4im %c", (int16_t)(HoehenWert/100),VarioCharacter)
607
                           else                                         HoTT_printfxy(10,0,"ALT:%4im  ", (int16_t)(HoehenWert/100))
608
                           }
609
            else    HoTT_printfxy(10,0,"ALT:---- ");
610
                        break;
611
        case 1:  
612
                if(FC_StatusFlags & FC_STATUS_LOWBAT)
613
                         HoTT_printfxy_BLINK(0,1,"  %2i:%02i  ",FlugSekunden/60,FlugSekunden%60)
614
            else   HoTT_printfxy(0,1,"  %2i:%02i  ",FlugSekunden/60,FlugSekunden%60);                      
615
                        HoTT_printfxy(10,1,"DIR: %3d%c",CompassCorrected, HoTT_GRAD);
616
                        if(FC_StatusFlags2 & FC_STATUS2_CAREFREE) HoTT_printfxy_INV(20,1,"C") else HoTT_printfxy(20,1," ");
617
            break;
618
        case 2:
619
                if(FC_StatusFlags & FC_STATUS_LOWBAT)
620
                         HoTT_printfxy_BLINK(0,2,"  %5i  ",Capacity.UsedCapacity)
621
            else   HoTT_printfxy(0,2,"  %5i  ",Capacity.UsedCapacity);                     
622
                        HoTT_printfxy(12,2,"I:%2i.%1iA ",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10);
623
                        break;
624
        case 3:
625
                        HoTT_printfxy(9,0,":");
626
                        HoTT_printfxy(9,1,":");
627
                        HoTT_printfxy(9,2,":");
628
                        HoTT_printfxy(0,3,"---------+-----------");
629
 
630
//                      HoTT_printfxy(0,3,"---------------------");
631
                        HoTT_printfxy(0,6,"---------------------");
632
                        break;
633
        case 4:  
634
                        if(NaviDataOkay)
635
                        {
636
                                HoTT_printfxy(9,4,":");
637
                                HoTT_printfxy(0,4,"SAT:%2d ",GPSInfo.NumOfSats);
638
                            HoTT_printfxy(10,4,"DIST:%3dm",GPSInfo.HomeDistance/10);
639
                                switch (GPSInfo.SatFix)
640
                                {
641
                                        case SATFIX_3D:
642
                                                        if(GPSInfo.Flags & FLAG_DIFFSOLN) HoTT_printfxy(7,4,"D ")
643
                                                        else HoTT_printfxy(7,4,"3D");
644
                                                break;
645
                                        default:
646
                                                HoTT_printfxy_BLINK(7,4,"!!");
647
                                                break;
648
                                }      
649
                        }
650
                        else
651
                        {                    
652
                                Hott_ClearLine(4);
653
                        }
654
                        break;
655
        case 5:
656
                        if(NaviDataOkay)
657
                        {
658
                        if(show_mag)
659
                          {
660
                                HoTT_printfxy(0,5,"MAG:%3u%% ",EarthMagneticField);
661
                            HoTT_printfxy(12,5,"HM:%3d%c %c", GPSInfo.HomeBearing, HoTT_GRAD, NC_GPS_ModeCharacter);
662
                                HoTT_printfxy(9,5,"incl:%2d%c(%2i)",EarthMagneticInclination, HoTT_GRAD,EarthMagneticInclinationTheoretic);
663
              }
664
                         else
665
                          {
666
                                HoTT_printfxy(0,5,"    %2um/s:  HM:%3d%c %c",GPSInfo.Speed, GPSInfo.HomeBearing, HoTT_GRAD, NC_GPS_ModeCharacter);
667
                          }    
668
            }
669
                        else Hott_ClearLine(5);
670
                        break;
671
        case 6:
672
                        break;
673
        case 7: if(NC_ErrorCode)
674
                  {
675
                           if(HoTTBlink && NC_ErrorCode < MAX_ERR_NUMBER)
676
                            {
677
                             Hott_ClearLine(7);
678
                             HoTT_printfxy_INV(0,7,"ERR: %2d !",NC_ErrorCode);
679
                            }
680
                                else
681
                                {
682
                                 HoTT_printfxy(0,7,"ERR: ");     _printf_P(&LIBFC_HoTT_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0);};
683
                                }
684
                        else
685
                        if(FC_StatusFlags & FC_STATUS_LOWBAT) HoTT_printfxy(1,7,"!! LiPo voltage !!")
686
                        else HoTT_printfxy(0,7," www.MikroKopter.de  ");
687
                        break;
688
        case 8: //ASCIIPacket.WarnBeep = HoTT_Waring();
689
                        // ASCIIPacket.WarnBeep = Parameter_UserParam1;
690
        case 9:
691
        case 10:
692
        case 11:
693
        case 12:
694
        case 13:
695
        case 14:  
696
        case 15:  
697
        case 16:  
698
                        if(HottKeyboard == HOTT_KEY_DOWN) { LIBFC_HoTT_Clear(); page = 5; line = 0;}
699
                        else
700
                        if(HottKeyboard == HOTT_KEY_SET) { if(show_mag) show_mag = 0; else show_mag = 1;}
701
                        else
702
                        if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page = 1; line = 0;};
703
                        HottKeyboard = 0;
704
                        break;
705
   default:  line = 0;
706
                        break;
707
  }
708
  break;
709
  case 1:
710
  switch(line++)
711
  {
712
        case 0:  
713
                if(FC_StatusFlags & FC_STATUS_LOWBAT)
714
                         HoTT_printfxy_BLINK(0,0," %2i:%02i  %2i.%1iV %4imAh",FlugSekunden/60,FlugSekunden%60,UBat/10, UBat%10,Capacity.UsedCapacity)
715
            else   HoTT_printfxy(0,0," %2i:%02i  %2i.%1iV %4imAh",FlugSekunden/60,FlugSekunden%60,UBat/10, UBat%10,Capacity.UsedCapacity);                         
716
                        break;
717
        case 1:  
718
                        HoTT_printfxy(0,1,"DIR:%3d%c",CompassCorrected, HoTT_GRAD);
719
                        if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG)
720
                          {
721
                           if(HoehenReglerAktiv)        HoTT_printfxy_INV(10,1,"ALT:%4im", (int16_t)(HoehenWert/100))
722
                           else                                         HoTT_printfxy(10,1,"ALT:%4im", (int16_t)(HoehenWert/100))
723
                           }
724
            else    HoTT_printfxy(10,1,"ALT:---- ");
725
                        HoTT_printfxy(20,1,"%c",VarioCharacter);
726
            break;
727
        case 2:
728
                        if(NaviDataOkay)
729
                        {
730
                          HoTT_printfxy(1,2,"HM:%3d%c  DIST:%3dm %c", GPSInfo.HomeBearing, HoTT_GRAD, GPSInfo.HomeDistance/10, NC_GPS_ModeCharacter);
731
            }
732
                        else
733
                        {
734
                         Hott_ClearLine(2);
735
                        }
736
                        break;
737
        case 3:
738
                        HoTT_printfxy(0,3,"PWR:%2i.%1iA (%iW) ",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10,Capacity.ActualPower);
739
                        if(FC_StatusFlags2 & FC_STATUS2_CAREFREE) HoTT_printfxy_INV(19,3,"CF") else HoTT_printfxy(19,3,"  ");
740
                        break;
741
        case 4:  
742
                        if(NaviDataOkay)
743
                        {
744
                                HoTT_printfxy(0,4,"GPS:%2um/s SAT:%d ",GPSInfo.Speed,GPSInfo.NumOfSats);
745
                                switch (GPSInfo.SatFix)
746
                                {
747
                                        case SATFIX_3D:
748
                                                HoTT_printfxy(16,4,"  3D ");
749
                                                break;
750
                                        //case SATFIX_2D:
751
                                        //case SATFIX_NONE:
752
                                        default:
753
                                                HoTT_printfxy_BLINK(16,4,"NOFIX");
754
                                                break;
755
                                }      
756
                                if(GPSInfo.Flags & FLAG_DIFFSOLN)
757
                                {
758
                                        HoTT_printfxy(16,4,"DGPS ");
759
                                }
760
                        }
761
                        else
762
                        {                    //012345678901234567890
763
                                HoTT_printfxy(0,4,"   No NaviCtrl       ");
764
                        }
765
                        break;
766
        case 5:
767
                        if(show_current)
768
                         {
769
//                              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);
770
                                HoTT_printfxy(0,5,"%2i.%i %2i.%i %2i.%i %2i.%iA", BL3_Current(0)/10,BL3_Current(0)%10,BL3_Current(1)/10,BL3_Current(1)%10,BL3_Current(2)/10,BL3_Current(2)%10,BL3_Current(3)/10,BL3_Current(3)%10);
771
                         }
772
                         else
773
                         {
774
                                HoTT_printfxy(0,5,"%3i %3i %3i %3i%cC", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature,HoTT_GRAD);
775
                         }
776
                        break;
777
        case 6:
778
                        if(show_current)
779
                         {
780
                    if(RequiredMotors == 4) Hott_ClearLine(6);
781
                                else
782
//                              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)
783
                                if(RequiredMotors == 6)  HoTT_printfxy(0,6,"%2i.%i %2i.%iA", BL3_Current(4)/10,BL3_Current(4)%10, BL3_Current(5)/10,BL3_Current(5)%10)
784
                                else
785
//                              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);
786
                                if(RequiredMotors > 6)   HoTT_printfxy(0,6,"%2i.%i %2i.%i %2i.%i %2i.%iA", BL3_Current(4)/10,BL3_Current(4)%10,BL3_Current(5)/10,BL3_Current(5)%10,BL3_Current(6)/10,BL3_Current(6)%10,BL3_Current(7)/10,BL3_Current(7)%10,BL3_Current(8)/10,BL3_Current(8)%10);
787
             }
788
                         else
789
                         {
790
                    if(RequiredMotors == 4) Hott_ClearLine(6);
791
                                else
792
                                if(RequiredMotors == 6)  HoTT_printfxy(0,6,"%3i %3i%cC        ", Motor[4].Temperature, Motor[5].Temperature,HoTT_GRAD)
793
                                else
794
                                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);
795
             }
796
                        break;
797
        case 7: if(NC_ErrorCode)
798
                  {
799
                           if(HoTTBlink && NC_ErrorCode < MAX_ERR_NUMBER)
800
                            {
801
                             Hott_ClearLine(7);
802
                             HoTT_printfxy_INV(0,7,"ERR: %2d !",NC_ErrorCode);
803
                            }
804
                                else
805
                                {
806
                                 HoTT_printfxy(0,7,"ERR: ");     _printf_P(&LIBFC_HoTT_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0);};
807
                                }
808
                        else
809
                        if(FC_StatusFlags & FC_STATUS_LOWBAT) HoTT_printfxy(1,7,"!! LiPo voltage !!")
810
                        else HoTT_printfxy(0,7," www.MikroKopter.de  ");
811
                        break;
812
        case 8: // ASCIIPacket.WarnBeep = HoTT_Waring();
813
                        // ASCIIPacket.WarnBeep = Parameter_UserParam1;
814
        case 9:
815
        case 10:
816
        case 11:
817
        case 12:
818
        case 13:
819
        case 14:  
820
        case 15:  
821
        case 16:  
822
                        if(HottKeyboard == HOTT_KEY_SET) { if(show_current) show_current = 0; else show_current = 1;   Hott_ClearLine(5);  Hott_ClearLine(6);}
823
                        else
824
                        if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page++; line = 0;}
825
                        else
826
                        if(HottKeyboard == HOTT_KEY_RIGHT) { LIBFC_HoTT_Clear(); page--; line = 0;}
827
//if(HottKeyboard) HoTT_printfxy(15,6,"%KEY:%02x ",HottKeyboard);
828
                        HottKeyboard = 0;
829
                        break;
830
   default:  line = 0;
831
                        break;
832
  }
833
  break;
834
  case 2:
835
  switch(line++)
836
  {
837
        case 0:  
838
                        HoTT_printfxy_INV(0,0,"Setting:%u %s ",ActiveParamSet,EE_Parameter.Name);
839
                        break;
840
    case 1: HoTT_printfxy(0,1,"Min:%2i.%1iV %s ",BattLowVoltageWarning/10, BattLowVoltageWarning%10, Mixer.Name);
841
                        break;
842
    case 2:  HoTT_printfxy(0,2,"ALT:");
843
                 if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG)
844
                 {
845
                          if(!(EE_Parameter.GlobalConfig & CFG_HOEHEN_SCHALTER)) HoTT_printf("POTI:%3u ", Parameter_HoehenSchalter)
846
                          else
847
                          {
848
                           if(Parameter_HoehenSchalter > 50) HoTT_printf("(ON)  ") else HoTT_printf("(OFF) ");
849
                           if((Parameter_ExtraConfig & CFG2_HEIGHT_LIMIT)) HoTT_printf("LIMIT", Parameter_HoehenSchalter)
850
                           else HoTT_printf("VARIO", Parameter_HoehenSchalter);
851
                          }
852
                         }
853
                        else
854
                                HoTT_printf("DISABLED");
855
                        break;
856
    case 3: HoTT_printfxy(0,3,"CF:");
857
                        if(!EE_Parameter.CareFreeChannel) HoTT_printf("DISABLED")
858
                        else
859
                         {
860
                          if(CareFree)  HoTT_printf(" (ON) ") else HoTT_printf(" (OFF)");
861
                          if(EE_Parameter.ExtraConfig & CFG_LEARNABLE_CAREFREE) HoTT_printf(" TEACH");
862
                         }
863
                        break;
864
    case 4: HoTT_printfxy(0,4,"GPS:");
865
                    if(!(Parameter_GlobalConfig & CFG_GPS_AKTIV)) HoTT_printf("DISABLED")
866
                        else
867
                         {
868
                          tmp = GetChannelValue(EE_Parameter.NaviGpsModeChannel);
869
                          if(tmp < 50) HoTT_printf("(FREE)")
870
                          else
871
                          if(tmp >= 180) HoTT_printf("(HOME)")
872
                          else
873
                          if(EE_Parameter.ExtraConfig & CFG_GPS_AID) HoTT_printf("(AID) ")
874
                          else HoTT_printf("(HOLD)")
875
                         }
876
                        if(EE_Parameter.FailSafeTime) HoTT_printfxy(10,4," FS:%usek ",EE_Parameter.FailSafeTime)
877
 
878
                        break;
879
    case 5: HoTT_printfxy(0,5,"HOME ALT:");
880
                        if(EE_Parameter.ComingHomeAltitude) HoTT_printf("%um",EE_Parameter.ComingHomeAltitude) else HoTT_printf("HOLD ");
881
                        break;
882
        case 6:
883
                        if(!show_poti)
884
                         {
885
              HoTT_printfxy(0,6,"Ni:%4i Ro:%4i C:%3i",ChannelNick,ChannelRoll, Parameter_ServoNickControl);
886
                      HoTT_printfxy(0,7,"Gs:%4i Ya:%4i ",ChannelGas+127,ChannelYaw);
887
                         }
888
                        else
889
                         {
890
              HoTT_printfxy(0,6,"P1:%4i P2:%4i 3:%3i",Poti1,Poti2, Poti3);
891
                      HoTT_printfxy(0,7,"P4:%4i P5:%4i 6:%3i",Poti4,Poti5, Poti6);
892
                         }
893
 
894
                        break;
895
    case 7: //HoTT_printfxy(0,6,"WARNINGS:");
896
                        if(HoTTBlink)
897
                        {
898
                         LIBFC_HoTT_SetPos(6 * 21);
899
                         if(!(Parameter_GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV)) HoTT_printf_BLINK("COUPLING OFF! ");
900
                         if(EE_Parameter.BitConfig & (CFG_LOOP_LINKS | CFG_LOOP_RECHTS | CFG_LOOP_UNTEN | CFG_LOOP_OBEN)) HoTT_printf_BLINK("LOOPING! ");
901
                         if(Parameter_GlobalConfig & CFG_HEADING_HOLD) HoTT_printf_BLINK("HH! ");
902
                         if(!(Parameter_GlobalConfig & CFG_KOMPASS_AKTIV)) HoTT_printf_BLINK("COMPASS OFF! ");
903
                        }
904
                        break;
905
    case 8: //ASCIIPacket.WarnBeep = HoTT_Waring();
906
                        break;
907
    case 9:
908
    case 10:
909
    case 11:
910
    case 12:
911
    case 13:
912
    case 14:
913
    case 15:
914
    case 16:
915
                        if(HottKeyboard == HOTT_KEY_SET) { if(show_poti) show_poti = 0; else show_poti = 1;   Hott_ClearLine(6);  Hott_ClearLine(7);}
916
                        else
917
                        if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page++; line = 0;}
918
                        else
919
                        if(HottKeyboard == HOTT_KEY_RIGHT) { LIBFC_HoTT_Clear(); page--; line = 0;};
920
                        HottKeyboard = 0;
921
                        break;
922
   default:  line = 0;
923
                        break;
924
  }
925
  break;
926
  case 3:
927
  switch(line++)
928
  {
929
        static unsigned char load_waypoint_tmp2 = 1, changed2;
930
        case 0:  
931
                        HoTT_printfxy(0,0,"Load Waypoints");
932
                        HoTT_printfxy(0,1,"(Relative Positions)");
933
//                      HoTT_printfxy(0,1,"(Absolute)"); 
934
                        break;
935
    case 1:
936
                        if(NaviData_WaypointNumber)     HoTT_printfxy(0,6,"Active WP:%2d/%d ",NaviData_WaypointIndex,NaviData_WaypointNumber)
937
                        else HoTT_printfxy(0,6,"No WPs active     ")
938
                        break;
939
    case 2:
940
                         HoTT_printfxy(0,7,"%2i.%1iV ",UBat/10, UBat%10)
941
                         HoTT_printfxy(11,7,"%s",WPL_Name)
942
    case 3:
943
    case 4:
944
    case 5:
945
                        if(load_waypoint_tmp2)
946
                         {
947
                          if(changed2 && HoTTBlink) HoTT_printfxy(10,3,"   ")
948
                          else HoTT_printfxy(10,3,"%2i   ",load_waypoint_tmp2);
949
                          HoTT_printfxy(0,3,"Load list:")
950
                         }
951
                        else
952
                         {
953
                          HoTT_printfxy(0,3,"Load list: -- ");
954
                         }
955
                         if(NaviData_MaxWpListIndex == 0) HoTT_printfxy(0,4,"No SD-Card   ")
956
                         else
957
                         {
958
                          if(GPSInfo.SatFix == SATFIX_3D)
959
                           {
960
                            if(changed2 && load_waypoint_tmp2) HoTT_printfxy(0,4,"(Set -> Load)")
961
                            else HoTT_printfxy(0,4,"             ");
962
                                if(HottKeyboard == HOTT_KEY_SET) { if(load_waypoint_tmp2) ToNC_Load_WP_List = load_waypoint_tmp2 | 128; changed2 = 0;}
963
                           } else HoTT_printfxy(0,4,"!No GPS-Fix! ");
964
                         }
965
                        if(HottKeyboard == HOTT_KEY_UP && load_waypoint_tmp2 < NaviData_MaxWpListIndex) { changed2 = 1; load_waypoint_tmp2++;HoTTBlink = 0;}
966
                        if(HottKeyboard == HOTT_KEY_DOWN && load_waypoint_tmp2 > 1) { changed2 = 1; load_waypoint_tmp2--;HoTTBlink = 0;};
967
                        if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page++; line = 0;}
968
                        if(HottKeyboard == HOTT_KEY_RIGHT) { LIBFC_HoTT_Clear(); page--; line = 0;};
969
                        HottKeyboard = 0;
970
                        break;
971
   default:  line = 0;
972
                        break;
973
  }
974
  break;
975
  case 4:
976
  switch(line++)
977
  {
978
        static unsigned char load_waypoint_tmp = 1, changed;
979
        case 0:  
980
                        HoTT_printfxy(0,0,"Load Waypoints");
981
                        HoTT_printfxy(0,1,"(Fixed Positions)");
982
                        break;
983
    case 1:
984
                        if(NaviData_WaypointNumber)     HoTT_printfxy(0,6,"Active WP:%2d/%d ",NaviData_WaypointIndex,NaviData_WaypointNumber)
985
                        else HoTT_printfxy(0,6,"No WPs active    ")
986
                        break;
987
    case 2:
988
                         HoTT_printfxy(0,7,"%2i.%1iV ",UBat/10, UBat%10)
989
                         HoTT_printfxy(11,7,"%s",WPL_Name)
990
    case 3:
991
    case 4:
992
    case 5:
993
                        HoTT_printfxy(0,3,"Load list:")
994
                        if(load_waypoint_tmp)
995
                         {
996
                          if(changed && HoTTBlink) HoTT_printfxy(10,3,"   ")
997
                          else HoTT_printfxy(10,3,"%2d (FIX)",load_waypoint_tmp);
998
                         }
999
                        else
1000
                         {
1001
                          HoTT_printfxy(10,3," --")
1002
                         }
1003
 
1004
                         if(NaviData_MaxWpListIndex == 0) HoTT_printfxy(0,4,"No SD-Card   ")
1005
                         else
1006
                         {
1007
                            if(changed && load_waypoint_tmp) HoTT_printfxy(0,4,"(Set -> Load)")
1008
                            else HoTT_printfxy(0,4,"             ");
1009
                         }
1010
                        if(HottKeyboard == HOTT_KEY_UP && load_waypoint_tmp < NaviData_MaxWpListIndex) { changed = 1; load_waypoint_tmp++; HoTTBlink = 0;}
1011
                        if(HottKeyboard == HOTT_KEY_DOWN && load_waypoint_tmp > 1) { changed = 1; load_waypoint_tmp--; HoTTBlink = 0;};
1012
                        if(HottKeyboard == HOTT_KEY_SET) { if(load_waypoint_tmp) ToNC_Load_WP_List = load_waypoint_tmp; changed = 0;}
1013
                        if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page++; line = 0;}
1014
                        if(HottKeyboard == HOTT_KEY_RIGHT) { LIBFC_HoTT_Clear(); page--; line = 0;};
1015
                        HottKeyboard = 0;
1016
                        break;
1017
   default:  line = 0;
1018
                        break;
1019
  }
1020
  break;
1021
  case 5:
1022
  switch(line++)
1023
  {
1024
    static unsigned char wp_tmp, changed;
1025
        case 0:  
1026
                        HoTT_printfxy(0,0,"Store single Position");
1027
//                      HoTT_printfxy(0,1,"(Fixed Positions)"); 
1028
                        break;
1029
    case 1:
1030
                    HoTT_printfxy(0,2," %2i.%1iV ",UBat/10, UBat%10)
1031
                        HoTT_printfxy(0,3," %2i:%02i ",FlugSekunden/60,FlugSekunden%60);                           
1032
//                      HoTT_printfxy(0,4,"Dist:%3dm",NaviData_TargetDistance)
1033
                        break;
1034
    case 2:
1035
                        HoTT_printfxy(11,2,"ALT:%4im", (int16_t)(HoehenWert/100))              
1036
                        HoTT_printfxy(11,3,"DIR: %3d%c",CompassCorrected, HoTT_GRAD);
1037
                        HoTT_printfxy(11,4,"Cam: %3i",Parameter_ServoNickControl);
1038
                        break;
1039
    case 3:
1040
    case 4:
1041
    case 5:
1042
                    HoTT_printfxy(0,6,"Store point:")
1043
                        if(wp_tmp)
1044
                         {
1045
                          if(changed && HoTTBlink) HoTT_printfxy(13,6,"   ")
1046
                          else HoTT_printfxy(13,6,"%2d ",wp_tmp);
1047
                         }
1048
                        else
1049
                         {
1050
                          HoTT_printfxy(13,6,"--")
1051
                         }
1052
 
1053
                    if(GPSInfo.SatFix == SATFIX_3D)
1054
                    {
1055
                         if(NaviData_MaxWpListIndex == 0) HoTT_printfxy(0,7,"No SD-Card   ")
1056
                         else
1057
                         {
1058
                            if(changed && wp_tmp) HoTT_printfxy(0,7,"(Set -> Store)")
1059
                            else Hott_ClearLine(7);
1060
                         }
1061
                         if(HottKeyboard == HOTT_KEY_SET) { if(wp_tmp) ToNC_Store_SingePoint = wp_tmp; changed = 0;}
1062
                    }
1063
            else HoTT_printfxy(0,7,"!No GPS-Fix! ");
1064
 
1065
                        if(HottKeyboard == HOTT_KEY_UP && wp_tmp < NaviData_MaxWpListIndex) { changed = 1; wp_tmp++; HoTTBlink = 0;}
1066
                        if(HottKeyboard == HOTT_KEY_DOWN && wp_tmp > 1) { changed = 1; wp_tmp--; HoTTBlink = 0;};
1067
                        if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page++; line = 0;}
1068
                        if(HottKeyboard == HOTT_KEY_RIGHT) { LIBFC_HoTT_Clear(); page--; line = 0;};
1069
                        HottKeyboard = 0;
1070
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1071
// Bedienung per Taster am Sender
1072
  if(Parameter_UserParam5 > 120)  // 
1073
   {
1074
    hyterese = 2;
1075
    if(CheckDelay(delay)) { wp_tmp = 0; hyterese = 1;}
1076
   }
1077
  else
1078
  if(Parameter_UserParam5 < 100)  
1079
   {
1080
        delay = SetDelay(2500);
1081
        if(hyterese == 2 && (wp_tmp < NaviData_MaxWpListIndex))
1082
         {
1083
          wp_tmp++;
1084
          ToNC_Store_SingePoint = wp_tmp;
1085
          changed = 0;
1086
         }
1087
    hyterese = 0;
1088
   }
1089
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1090
                        break;
1091
   default:  line = 0;
1092
                        break;
1093
  }
1094
  break;
1095
  case 6:
1096
  switch(line++)
1097
  {
1098
    static unsigned char wp_tmp, changed;
1099
        case 0:  
1100
                        HoTT_printfxy(0,0,"Load single Position");
1101
//                      HoTT_printfxy(0,1,"(Fixed Positions)"); 
1102
                        break;
1103
    case 1:
1104
                    HoTT_printfxy(0,2," %2i.%1iV ",UBat/10, UBat%10)
1105
                        HoTT_printfxy(0,3," %2i:%02i ",FlugSekunden/60,FlugSekunden%60);                           
1106
//                      HoTT_printfxy(0,4,"Dist:%3dm",NaviData_TargetDistance)
1107
                    if(NaviData_WaypointNumber) HoTT_printfxy(0,5,"WP:%2d/%d Dist:%3dm ",NaviData_WaypointIndex,NaviData_WaypointNumber,NaviData_TargetDistance)
1108
                    else Hott_ClearLine(5);
1109
                        break;
1110
    case 2:
1111
                        if(FromNC_AltitudeSpeed)
1112
                          HoTT_printfxy(8,2,"ALT:%4i/%im ", (int16_t)(HoehenWert/100),(int16_t)(FromNC_AltitudeSetpoint/100))
1113
                        else
1114
                          HoTT_printfxy(8,2,"ALT:%4im    ",(int16_t)(HoehenWert/100))
1115
 
1116
                        HoTT_printfxy(8,3,"DIR: %3d%c",CompassCorrected, HoTT_GRAD);
1117
                        HoTT_printfxy(8,4,"Cam: %3i",Parameter_ServoNickControl);
1118
                        break;
1119
//                       HoTT_printfxy(11,7,"%s",WPL_Name)
1120
    case 3:
1121
    case 4:                                      
1122
    case 5:
1123
                  if(HottKeyboard) DebugOut.Analog[17]++;
1124
                  HoTT_printfxy(0,6,"load point:")
1125
                        if(wp_tmp)
1126
                         {
1127
                          if(changed && HoTTBlink) HoTT_printfxy(11,6,"   ")
1128
                          else HoTT_printfxy(11,6,"%2d",wp_tmp);
1129
                         }
1130
                        else
1131
                         {
1132
                          HoTT_printfxy(11,6,"--")
1133
                         }
1134
 
1135
                         if(NaviData_MaxWpListIndex == 0) HoTT_printfxy(0,7,"No SD-Card   ")
1136
                         else
1137
                         {
1138
                            if(changed && wp_tmp) HoTT_printfxy(0,7,"(Set -> Load)")
1139
                            else
1140
                                {
1141
                                 Hott_ClearLine(7);
1142
                                 if(NaviData_WaypointNumber) HoTT_printfxy(0,7,"%s",WPL_Name);
1143
                                }
1144
                         }
1145
                        if(HottKeyboard == HOTT_KEY_UP && wp_tmp < NaviData_MaxWpListIndex) { changed = 1; wp_tmp++; HoTTBlink = 0;}
1146
                        if(HottKeyboard == HOTT_KEY_DOWN && wp_tmp > 1) { changed = 1; wp_tmp--; HoTTBlink = 0;};
1147
                        if(HottKeyboard == HOTT_KEY_SET) { if(wp_tmp) ToNC_Load_SingePoint = wp_tmp; changed = 0;}
1148
                        if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page++; line = 0;}
1149
                        if(HottKeyboard == HOTT_KEY_RIGHT) { LIBFC_HoTT_Clear(); page--; line = 0;};
1150
                        HottKeyboard = 0;
1151
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1152
// Bedienung per Taster am Sender
1153
  if(Parameter_UserParam5 > 120)  // 
1154
   {
1155
    hyterese = 2;
1156
    if(CheckDelay(delay)) { wp_tmp = 0; hyterese = 1;}
1157
   }
1158
  else
1159
  if(Parameter_UserParam5 < 100)  
1160
   {
1161
        delay = SetDelay(2500);
1162
        if(hyterese == 2 && (wp_tmp < NaviData_MaxWpListIndex))
1163
         {
1164
          wp_tmp++;
1165
          ToNC_Load_SingePoint = wp_tmp;
1166
          changed = 0;
1167
         }
1168
    hyterese = 0;
1169
   }
1170
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1171
                        break;
1172
   default:  line = 0;
1173
                        break;
1174
  }
1175
  break;
1176
  case 7:
1177
  switch(line++)
1178
  {
1179
        static unsigned char i=0,test=0,set=0;
1180
 
1181
        case 0: HoTT_printfxy(0,0,"Motortest / Setpoints");break;
1182
        case 1: //HoTT_printfxy(0,1,"Motor Setpoint Strom ");
1183
    case 2:
1184
    case 3:
1185
        case 4: i=((line-2)*2)+1;
1186
                        if(MotorenEin)
1187
                        {
1188
                                HoTT_printfxy(0,line,"M%i=%2i%2i.%iA M%i=%2i%2i.%iA",i,Motor[i-1].SetPoint,Motor[i-1].Current/10,Motor[i-1].Current%10,i+1,Motor[i].SetPoint,Motor[i].Current/10,Motor[i].Current%10);
1189
                        }
1190
                        else
1191
                        {
1192
                                HoTT_printfxy(0,line,"M%i=%2i%2i.%iA M%i=%2i%2i.%iA",i,MotorTest[i-1],Motor[i-1].Current/10,Motor[i-1].Current%10,i+1,MotorTest[i],Motor[i].Current/10,Motor[i].Current%10);
1193
                        }
1194
                        break;
1195
    case 5: if(test)
1196
                        {
1197
                                HoTT_printfxy(0,6,"!!!Motortest Aktiv!!!");
1198
                        }
1199
        case 6: if(test)
1200
                        {
1201
                                PC_MotortestActive = 254;
1202
                                HoTT_printfxy(0,7,"Motor %i",test);
1203
                                MotorTest[test-1]=set;
1204
                        }
1205
    case 7:
1206
    case 8:
1207
    case 9:
1208
    case 10:
1209
    case 11:
1210
    case 12:
1211
    case 13:
1212
    case 14:
1213
    case 15:
1214
    case 16:
1215
                        if(HottKeyboard == HOTT_KEY_RIGHT)
1216
                        {
1217
                                if(test)
1218
                                {
1219
                                        set=0;
1220
                                        MotorTest[test-1]=set;
1221
                                        if(test<8) test++;
1222
                                }
1223
                                else
1224
                                {
1225
                                        LIBFC_HoTT_Clear();
1226
                                        page--;
1227
                                        line=0;
1228
                                }
1229
                        }                              
1230
                        else
1231
                        if(HottKeyboard == HOTT_KEY_LEFT)
1232
                        {
1233
                                if(test)
1234
                                {
1235
                                        set=0;
1236
                                        MotorTest[test-1]=set;
1237
                                        if(test>1) test--;
1238
                                }
1239
                                else
1240
                                {
1241
                                        LIBFC_HoTT_Clear();
1242
                                        page++;
1243
                                        line = 0;
1244
                                }
1245
                        }
1246
                        else
1247
                        if((HottKeyboard == HOTT_KEY_UP) && (set <98 ) && test) set+=2;//GESCHW
1248
                        else
1249
                        if((HottKeyboard == HOTT_KEY_DOWN) && (set >0  ) && test) set-=2;
1250
                        else
1251
                        if((HottKeyboard == HOTT_KEY_SET) &&  !MotorenEin)
1252
                        {
1253
                                if(test) test = 0; else test = 1;
1254
                                set=0;
1255
                                Hott_ClearLine(6);  Hott_ClearLine(7);
1256
                        }
1257
                        HottKeyboard = 0;
1258
                        break;
1259
   default:  line = 0;
1260
                        break;
1261
        //HoTT_printfxy(10 ,line,"I");
1262
        //line++;
1263
  }
1264
  break;
1265
  case 8:
1266
  switch(line++)
1267
  {
1268
#define MD_OFF 1
1269
#define MD_CAL 2
1270
#define MD_SAV 3
1271
        static unsigned char mode=MD_OFF,cursor=MD_OFF;
1272
 
1273
        case 0: HoTT_printfxy(0,0,"ACC calibration");break;
1274
        case 1: HoTT_printfxy(0,2,"ACC:   N:%3i R:%3i ",NeutralAccX,NeutralAccY);
1275
        case 2: HoTT_printfxy(0,3,"Stick:   (%i/%i)     ",ChannelNick,ChannelRoll);
1276
        case 3: if(ChannelNick || ChannelRoll)  HoTT_printfxy(7,3,"!!");
1277
                        break;
1278
        case 4: HoTT_printfxy(2,4,"Off");break;
1279
    case 5: HoTT_printfxy(2,5,"Calibrate");break;
1280
        case 6: HoTT_printfxy(2,6,"Save          ");
1281
                        if(mode == MD_SAV && cursor == MD_SAV)
1282
                         {
1283
                          HoTT_printfxy(7,6,"(SET)");
1284
                         }
1285
                        else if((mode == MD_CAL) && !((NC_GPS_ModeCharacter == ' ') || (NC_GPS_ModeCharacter == '/') || (NC_GPS_ModeCharacter == '-')))
1286
                         {
1287
                                HoTT_printfxy(2,6,"Swich GPS off!");   
1288
                         }     
1289
                        break;
1290
    case 7:
1291
    case 8: HoTT_printfxy(0,cursor+3,">");break;
1292
    case 9: HoTT_printfxy(1,mode+3,"*");break;
1293
    case 10:
1294
    case 11:
1295
    case 12:
1296
    case 13:
1297
    case 14:
1298
    case 15:
1299
    case 16:
1300
                        if(HottKeyboard == HOTT_KEY_RIGHT)
1301
                        {
1302
                                switch(mode)
1303
                                {
1304
                                        case MD_OFF: LIBFC_HoTT_Clear();
1305
                                                        page--; // leave menu
1306
                                                        line = 0;
1307
                                                        break;
1308
                                        case MD_CAL: NeutralAccY++;
1309
                                                        break;
1310
                                        case MD_SAV: break;
1311
                                        default: mode=MD_OFF;break;
1312
                                }
1313
                        }
1314
                        else
1315
                        if(HottKeyboard == HOTT_KEY_LEFT)
1316
                        {
1317
                                switch(mode)
1318
                                {
1319
                                        case MD_OFF: LIBFC_HoTT_Clear();
1320
                                                        page++;  // leave menu
1321
                                                        line = 0;
1322
                                                        break;
1323
                                        case MD_CAL: NeutralAccY--;
1324
                                                        break;
1325
                                        case MD_SAV: break;
1326
                                        default: mode=MD_OFF;
1327
                                                        break;
1328
                                }                              
1329
                        }
1330
                        else
1331
                        if(HottKeyboard == HOTT_KEY_UP)
1332
                        {
1333
                                switch(mode)
1334
                                {
1335
                                        case MD_CAL: NeutralAccX++;
1336
                                                        break;
1337
                                        case MD_OFF:
1338
                                        case MD_SAV: if(cursor>1) {HoTT_printfxy(0,cursor+3," ");cursor--;}
1339
                                                        HoTT_printfxy(2,6,"     ");
1340
                                                        break;
1341
                                        default: mode=MD_OFF;
1342
                                                        break;
1343
                                }
1344
                        }
1345
                        else
1346
                        if(HottKeyboard == HOTT_KEY_DOWN)
1347
                        {
1348
                                switch(mode)
1349
                                {
1350
                                        case MD_CAL:    NeutralAccX--;
1351
                                                                break;
1352
                                        case MD_SAV:
1353
                                        case MD_OFF:    if(cursor<MD_SAV) {HoTT_printfxy(0,cursor+3," ");cursor++;}
1354
                                                                break;
1355
                                        default:        mode=MD_OFF;
1356
                                                                break;
1357
                                }
1358
                        }
1359
                        else
1360
                        if(HottKeyboard == HOTT_KEY_SET)
1361
                        {
1362
                                switch(mode)
1363
                                {
1364
                                        case MD_OFF: HoTT_printfxy(1,mode+3," ");
1365
                                                        mode = cursor;
1366
                                                        if(mode == MD_CAL && !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
1367
                                                        break;
1368
                                        case MD_CAL: HoTT_printfxy(1,mode+3," ");
1369
                                                        mode = MD_OFF;
1370
                                                        break;
1371
                                        case MD_SAV:
1372
                                                        Hott_ClearLine(7);
1373
                                                        if(cursor == MD_SAV)
1374
                                                        {
1375
                                                                if(!MotorenEin)
1376
                                                                {
1377
/*                                                                      BoatNeutralNick = AdNeutralNick;
1378
                                                                        BoatNeutralRoll = AdNeutralRoll;
1379
                                                                        BoatNeutralGier = AdNeutralGier;
1380
                                                                        SetParamWord(PID_ACC_NICK, (uint16_t)NeutralAccX);
1381
                                                                        SetParamWord(PID_ACC_ROLL, (uint16_t)NeutralAccY);
1382
                                                                        SetParamWord(PID_GYRO_NICK,(uint16_t)BoatNeutralNick);
1383
                                                                        SetParamWord(PID_GYRO_ROLL,(uint16_t)BoatNeutralRoll);
1384
                                                                        SetParamWord(PID_GYRO_YAW,(uint16_t)BoatNeutralGier);
1385
*/
1386
                                                                        StoreNeutralToEeprom();
1387
                                                                        HoTT_printfxy(7,6," okay ");
1388
                                                                        HoTT_printfxy(1,mode+3," ");
1389
                                                                        mode = MD_OFF;
1390
                                                                }
1391
                                                                else
1392
                                                                {
1393
                                                                        HoTT_printfxy(0,7,"Motors running!!!");
1394
                                                                        mode = MD_OFF;
1395
                                                                }
1396
                                                        }
1397
                                                        else
1398
                                                        {
1399
                                                                HoTT_printfxy(1,mode+3," ");
1400
                                                                mode=cursor;
1401
                                                        }
1402
                                                        break;
1403
                                        default: mode=MD_OFF;
1404
                                                        break;
1405
                                }
1406
                        }
1407
                        HottKeyboard = 0;
1408
                        break;
1409
   default:  line = 0;
1410
                        break;
1411
        //HoTT_printfxy(10 ,line,"I");
1412
        //line++;
1413
  }
1414
  break;
1415
/*
1416
//------------------------------------------------------------------------------------------
1417
// HoTT-Plus
1418
//------------------------------------------------------------------------------------------
1419
  case 9:
1420
  switch(line++)
1421
  {
1422
        case 0: HoTT_printfxy(0,0,"I2C Schwerpunkt GAS");
1423
                        break;
1424
        case 1: HoTT_printfxy(0,1,"I2C%3i%3i%3i%3i",Motor[0].State & MOTOR_STATE_ERROR_MASK,Motor[1].State & MOTOR_STATE_ERROR_MASK, Motor[2].State & MOTOR_STATE_ERROR_MASK, Motor[3].State & MOTOR_STATE_ERROR_MASK);
1425
                        break;
1426
    case 2: HoTT_printfxy(0,2,"   %3i%3i%3i%3i",Motor[4].State & MOTOR_STATE_ERROR_MASK,Motor[5].State & MOTOR_STATE_ERROR_MASK, Motor[6].State & MOTOR_STATE_ERROR_MASK, Motor[7].State & MOTOR_STATE_ERROR_MASK);
1427
                        break;
1428
 
1429
        case 3:  {                       //0123456789ABCDEF
1430
                                int r=0;
1431
                                int n=0;
1432
                                int g=0;
1433
                                n=SummeNick >> 9;
1434
                                r=SummeRoll >> 9;
1435
                                g=Mess_Integral_Gier >> 9;
1436
 
1437
                                HoTT_printfxy(0,5,"%3iN   %3iR   %3iG",n ,r ,g);
1438
                        }
1439
 
1440
                        break;
1441
    case 4: {                       //0123456789ABCDEF
1442
                                HoTT_printfxy(0,4,"+  ^   +  <");
1443
                        }
1444
                        break;
1445
    case 5: {                       //0123456789ABCDEF
1446
                                HoTT_printfxy(0,6,"-  v   -  >");
1447
                        }
1448
                        break;
1449
        case 6: HoTT_printfxy(0,7,"%3i=HG/4 %3i=Gas",HoverGas/4,StickGas);
1450
 
1451
                        break;
1452
    case 7:
1453
    case 8:
1454
    case 9:
1455
    case 10:
1456
    case 11:
1457
    case 12:
1458
    case 13:
1459
    case 14:
1460
    case 15:
1461
    case 16:
1462
                        if(HottKeyboard == HOTT_KEY_RIGHT) { LIBFC_HoTT_Clear(); page--; line = 0;}
1463
                        else
1464
                        if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page++; line = 0;}
1465
                        HottKeyboard = 0;
1466
                        break;
1467
   default:  line = 0;
1468
                        break;
1469
  }
1470
  break;
1471
//---------------------------------------------------------------------------------------------------
1472
  case 10:
1473
{  
1474
        static signed char i=0,j=0,Changepos=0;                  
1475
 
1476
        if(line==9)
1477
        {
1478
                line=0;
1479
                if(HottKeyboard == HOTT_KEY_SET   ) { if(Changepos) Changepos = 0; else Changepos = 1;}
1480
                else
1481
                if(Changepos)
1482
                {
1483
                        unsigned char temp=0;
1484
                        temp=(Changepos+j)-1;
1485
                        if((HottKeyboard == HOTT_KEY_RIGHT) && !((unsigned char)(*Parameter_List[temp].Variable + Parameter_List[temp].offset) >= Parameter_List[temp].max )) {*Parameter_List[temp].Variable += 1;}
1486
                        else
1487
                        if((HottKeyboard == HOTT_KEY_LEFT) && !((unsigned char)(*Parameter_List[temp].Variable + Parameter_List[temp].offset) <= Parameter_List[temp].min )) {*Parameter_List[temp].Variable -= 1;}
1488
                        else
1489
                        if(HottKeyboard == HOTT_KEY_UP  )
1490
                        {
1491
                                Changepos--;
1492
                                line = Changepos/2;
1493
                                if(Changepos< 1       ) {Changepos=16;}
1494
                        }
1495
                        else
1496
                        if(HottKeyboard == HOTT_KEY_DOWN)
1497
                        {
1498
                                Changepos++;
1499
                                line = Changepos/2;
1500
                                if(Changepos >= 17       ) {Changepos=1;}
1501
                        }
1502
                }
1503
                else
1504
                {
1505
                        if(HottKeyboard == HOTT_KEY_RIGHT) { LIBFC_HoTT_Clear(); page--; line = 0;}
1506
                        else
1507
                        if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page++; line = 0;}
1508
                        else
1509
                        if(HottKeyboard == HOTT_KEY_UP  )
1510
                        {
1511
                                j-=16;
1512
                                line = 0;
1513
                                if(j< 0       ) {j=0;}
1514
                        }
1515
                        else
1516
                        if(HottKeyboard == HOTT_KEY_DOWN)
1517
                        {
1518
                                LIBFC_HoTT_Clear();
1519
                                j+=16;
1520
                                line = 0;
1521
                                if(j+14> MAXPARAM       ) {j=MAXPARAM-15;}
1522
                        }
1523
                }
1524
 
1525
                Debug("line=%i Changepos=%i j=%i Key=%i",line,Changepos,j,HottKeyboard);
1526
                HottKeyboard = 0;
1527
        }
1528
 
1529
        HoTT_printfxy(10 ,line,"I");
1530
        i=(line*2)+(j);
1531
        if(Changepos==(line*2)+1)
1532
        {
1533
                HoTT_printfxy(0 ,line,">%3i=%-5.5s%",(unsigned char)(*Parameter_List[i  ].Variable + Parameter_List[i  ].offset),&Parameter_List[i  ].name);
1534
        }
1535
        else
1536
        {
1537
                HoTT_printfxy(0 ,line," %3i=%-5.5s%",(unsigned char)(*Parameter_List[i  ].Variable + Parameter_List[i  ].offset),&Parameter_List[i  ].name);
1538
        }
1539
        if(Changepos==(line*2)+2)
1540
        {
1541
                HoTT_printfxy(11,line,">%3i=%-5.5s%",(unsigned char)(*Parameter_List[i+1].Variable + Parameter_List[i+1].offset),&Parameter_List[i+1].name);
1542
        }
1543
        else
1544
        {
1545
                HoTT_printfxy(11,line," %3i=%-5.5s%",(unsigned char)(*Parameter_List[i+1].Variable + Parameter_List[i+1].offset),&Parameter_List[i+1].name);
1546
        }
1547
 
1548
        line++;
1549
 
1550
}
1551
  break;
1552
  case 11:
1553
  switch(line++)
1554
  {
1555
        case 0: HoTT_printfxy(0,0,"Setting speichern");
1556
                        break;
1557
        case 1: HoTT_printfxy(0,1,"Setting%1i= %-11.11s",GetActiveParamSet(),EE_Parameter.Name);
1558
                        break;                    //123456789012345678901
1559
    case 2: HoTT_printfxy(0,2,"Speichern nach Set %i",settingdest);
1560
                        break;
1561
    case 3: HoTT_printfxy(0,4,"\"SET\" zum speichern");
1562
                        break;
1563
    case 4: HoTT_printfxy(0,5,"^ v zum auswaehlen");
1564
                        break;
1565
    case 5:  
1566
        case 6:  
1567
    case 7:
1568
    case 8:
1569
    case 9:
1570
    case 10:
1571
    case 11:
1572
    case 12:
1573
    case 13:
1574
    case 14:
1575
    case 15:
1576
    case 16:
1577
                        if(HottKeyboard == HOTT_KEY_RIGHT) { LIBFC_HoTT_Clear(); page--; line = 0;}
1578
                        else
1579
                        if(HottKeyboard == HOTT_KEY_LEFT) { LIBFC_HoTT_Clear(); page++; line = 0;}
1580
                        else
1581
                        if((HottKeyboard == HOTT_KEY_UP) & (settingdest <5 )) settingdest++;
1582
                        else
1583
                        if((HottKeyboard == HOTT_KEY_DOWN) & (settingdest >1  )) settingdest--;
1584
                        else
1585
                        if((HottKeyboard == HOTT_KEY_SET) &&  !MotorenEin)
1586
                        {
1587
                                ParamSet_WriteToEEProm(settingdest);
1588
                                //JetiBeep = jetibeepcode[GetActiveParamSet()-1];
1589
                                Piep(GetActiveParamSet(),120);
1590
                                HoTT_printfxy(0,7,"Gespeichert!");  
1591
                        }
1592
                        HottKeyboard = 0;
1593
                        break;
1594
   default:  line = 0;
1595
                        break;
1596
  }
1597
  break;
1598
//------------------------------------------------------------------------------------------
1599
 // HoTT-Plus
1600
//------------------------------------------------------------------------------------------
1601
*/
1602
  default:  page = 0;
1603
  break;
1604
 }
1605
}
1606
 
1607
#endif
1608
 
1609
 
1610