Subversion Repositories Projects

Rev

Rev 2212 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2136 - 1
/*****************************************************************************
2
 *   Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de                  *
3
 *   Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net                  *
4
 *   Copyright (C) 2013 Christian "Cebra" Brandtner, brandtner@brandtner.net *
5
 *   Copyright (C) 2011 Harald Bongartz                                      *
6
 *                                                                           *
7
 *   This program is free software; you can redistribute it and/or modify    *
8
 *   it under the terms of the GNU General Public License as published by    *
9
 *   the Free Software Foundation; either version 2 of the License.          *
10
 *                                                                           *
11
 *   This program is distributed in the hope that it will be useful,         *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
14
 *   GNU General Public License for more details.                            *
15
 *                                                                           *
16
 *   You should have received a copy of the GNU General Public License       *
17
 *   along with this program; if not, write to the                           *
18
 *   Free Software Foundation, Inc.,                                         *
19
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
20
 *                                                                           *
21
 *                                                                           *
22
 *   Credits to:                                                             *
23
 *   Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN  *
24
 *                          http://www.mikrokopter.de                        *
25
 *   Gregor "killagreg" Stobrawa for his version of the MK code              *
26
 *   Thomas Kaiser "thkais" for the original project. See                    *
27
 *                          http://www.ft-fanpage.de/mikrokopter/            *
28
 *                          http://forum.mikrokopter.de/topic-4061-1.html    *
29
 *   Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code *
30
 *                          http://www.mylifesucks.de/oss/c-osd/             *
31
 *   Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility*
32
 *****************************************************************************/
33
//############################################################################
34
//# HISTORY  eeprom.c
35
//#
2214 - 36
//# 14.10.2015 Starter
37
//# - chg: rename FM_Azimuth and FM_Distance to FM_Offest_lat and FM_Offset_long
38
//#
2136 - 39
//# 03.08.2015 CB
40
//# - chg: Obsolete Parameter geändert und für FollowMe verwendet, EEprom Version bleibt gleich
41
//#        Parameter FM_Refresh in FM_Azimuth geändert
42
//#        Parameter hyst_u_min in FM_Distance geändert
43
//#        Initialisierung der neuen Parameter hinzugefügt
44
//#
45
//# 17.06.2014 OG
46
//# - chg: ReadParameter() - Updatecode auf 139
47
//#
48
//# 13.06.2014 OG
49
//# - chg: Delete_EEPROM(() Unterstuetzung Config.PKTOffTimeout (ehemals LCD_DisplayMode)
50
//#
51
//# 30.05.2014 OG
52
//# - chg: Delete_EEPROM() Config.Lipo_UOffset auf 10000 gesetzt (vorher 8500)
53
//#
54
//# 26.05.2014 OG
55
//# - chg: Config.LCD_DisplayMode als "OBSOLETE" markiert
56
//#
57
//# 14.05.2014 OG
58
//# - chg: include "../mk/paramset.h" geaendert auf "../mksettings/paramset.h"
59
//#
60
//# 07.05.2014 OG
61
//# - chg: EEpromversion erhoeht auf 138
62
//#        -> keine neuen Parameter, neue Version nur fuer geanderte
63
//#           Initialisierung von MKParam_Favs
64
//# - fix: ReadParameter() - Vorbelegung von Config.MKParam_Favs von 255 auf 0 geaendert
65
//#        ab EEprom-Version 138
66
//# - fix: Delete_EEPROM() - Vorbelegung von Config.MKParam_Favs von 255 auf 0 geaendert
67
//# - fix: ReadParameter() - Kommentare zu Version 136 und 137 korrigiert
68
//#        bzgl. der PKT-Versionsangabe und Datum ergaenzt
69
//#
70
//# 06.04.2014 OG
71
//# - chg: ReadParameter(): umgestellt auf lcdx_printp_center()
72
//# - chg: EEpromversion erhoeht auf 137
73
//# - add: ReadParameter(): upgrade Config.Wlan_HomeSSID, Config.Wlan_HomePassword
74
//# - add: ReadParameter(): upgrade Config.UseBLE, Config.MKParam_Favs
75
//# - add: Delete_EEPROM(): init von Config.Wlan_HomeSSID, Config.Wlan_HomePassword
76
//#
77
//# 01.04.2014 OG
78
//# - add: Delete_EEPROM(): init von Config.UseBLE
79
//# - add: Delete_EEPROM(): init von Config.MKParam_Favs
80
//#
81
//# 27.03.2014 OG
82
//# - chg: ReadParameter() Niederländisch wird auf Englisch umgeschaltet
83
//#         -> Vorbereitung zum entfernen der Niederländischen Sprache
84
//#
85
//# 11.02.2014 Cebra
86
//# - add: Delete EEProm: Config.OSD_ShowCellU = false;
87
//#
88
//# 03.02.2014 OG
89
//# - add: Config.OSD_ShowCellU in ReadParameter (EEpromversion 0x87)
90
//#
91
//# 30.01.2014 OG
92
//# - add: Unterstuetzung fuer USE_BLUETOOTH
93
//#
94
//# 07.07.2013 OG
95
//# - chg: Strings fuer WLan gekuerzt
96
//#
97
//# 04.07.2013 Cebra
98
//# - add: neue Parameter fuer Wlan; EEpromversion erhoeht auf 0x85
99
//#
100
//# 04.07.2013 OG
101
//# - add: Config.OSD_UseScreen; Epromversion erhoeht auf 0x84
102
//#
103
//# 03.07.2013 OG
104
//# - chg: ReadParameter() - PKT-Upgrade restrukturiert bzgl. inkrementelle
105
//#        Updates vorheriger Versionen
106
//#
107
//# 02.07.2013 Cebra
108
//# - add: neue Parameter fuer Wlan; EEpromversion erhoeht auf 83
109
//#
110
//# 02.07.2013 OG
111
//# - chg: frei geworden: Config.OSD_HomeMKView (nicht mehr benoetigt)
112
//#
113
//# 26.06.2013 OG
114
//# - chg: frei geworden: Config.PKT_StartInfo (nicht mehr benoetigt)
115
//#
116
//# 24.06.2013 OG
117
//# - fix: ReadParameter(): ergaenzt um bt_fixname() um ggf. ungueltige
118
//#        Zeichen im Bluetooth-Namen zu eliminieren
119
//#
120
//# 23.06.2013 OG
121
//# - chg: Delete_EEPROM(): Default von Config.Lipo_UOffset von 6000 auf 8500 gesetzt
122
//# - chg: Delete_EEPROM(): Default von Config.bt_name auf "PKT" gekuerzt
123
//# - chg: Delete_EEPROM(): Config.bt_name -> nicht mehr mit Leerzeichen auffuellen!
124
//#
125
//# 20.06.2013 CB
126
//# - chg: EEPROM Versionsänderung auf 82 wegen Wechsel LCD_Orientation zu OSD_ShowMKSetting
127
//#
128
//# 15.06.2013 OG
129
//# - chg: Config.LCD_ORIENTATION zu Config.OSD_ShowMKSetting
130
//#
131
//# 13.06.2013 OG
132
//# - fix: Config.PKT_Accutyp hinzugefuegt in Delete_EEPROM()
133
//# - chg: Default GPS-LastPosition auf 0/0 gesetzt in Delete_EEPROM()
134
//# - chg: Default Config.PKT_StartInfo auf false gesetzt in Delete_EEPROM()
135
//# - chg: Code Layout
136
//#
137
//# 31.05.2013 CB
138
//# - chg: EEPROM Strukturänderung auf Version 81, Versionsanpassung angepasst
139
//#
140
//# 05.05.2013 Cebra
141
//# - add: PKT Zeitsetup EEPROM Parameter
142
//# 28.03.2013 CB
143
//# - add: save and upgrade OSD_Statistic, GPS_User, MKErr_Log in EEProm structure variable
144
//############################################################################
145
 
146
#include "../cpu.h"
147
#include <avr/io.h>
148
#include <avr/pgmspace.h>
149
#include <util/delay.h>
150
#include <stdio.h>
151
#include <stdlib.h>
152
#include <string.h>
153
#include <stdarg.h>
154
#include <avr/interrupt.h>
155
#include <avr/eeprom.h>
156
#include <stdbool.h>
157
#include <avr/wdt.h>
158
#include "../lcd/lcd.h"
159
#include "../main.h"
160
#include "../timer/timer.h"
161
#include "eeprom.h"
162
#include "../wi232/Wi232.h"
163
#include "../setup/setup.h"
164
#include "../bluetooth/bluetooth.h"
165
#include "../mk-data-structs.h"
166
#include "../connect.h"
167
#include "../tracking/ng_servo.h"
168
#include "../tracking/tracking.h"
169
#include "../osd/osd.h"
170
#include "../uart/uart1.h"
171
#include "../messages.h"
172
#include "../osd/osddata.h"
173
#include "../mksettings/paramset.h"
174
 
175
//------------------------------------------------------------------------------------------
176
 
177
ST EEMEM EEStruct;
178
 
179
ST Config;
180
 
181
 
182
//#############################################################
183
// ANMERKUNG OG:
184
//
185
// es ware besser wenn die gesamte Config-struct zum PC
186
// gesendet wird anstatt aufbreitete Textlines. Das spart
187
// Speicher im PKT (der ist limitiert).
188
//
189
// Die Aufbereitung der Daten (Umrechnungen) kann dann auf
190
// der PC Seite erfolgen.
191
//
192
// Nachteil dabei: wenn sich die Config-struct des PKT
193
// ändert muss auch das PKT-Tool auf dem PC angepasst werden.
194
//
195
//CB: deshalb ist das auch jetzt auskommentiert
196
//
197
//#############################################################
198
 
199
 
200
//char printbuff[100];
201
 
202
//void print_data_int8( const char *text, int8_t *variable)
203
//{
204
//  sprintf(printbuff, "%d", *variable);
205
//  uart1_puts_p(text); uart1_puts(printbuff); uart1_puts("\r\n");
206
//}
207
////
208
////
209
//void print_data_uint8( const char *text, uint8_t *variable)
210
//{
211
//  sprintf(printbuff, "%d", *variable);
212
//  uart1_puts_p(text); uart1_puts(printbuff); uart1_puts("\r\n");
213
//}
214
//
215
//
216
//void print_data_uint16( const char *text, uint16_t *variable)
217
//{
218
//  sprintf(printbuff, "%d", *variable);
219
//  uart1_puts_p(text); uart1_puts(printbuff); uart1_puts("\r\n");
220
//}
221
//
222
//
223
//void print_data_int16( const char *text, int16_t *variable)
224
//{
225
//  sprintf(printbuff, "%d", *variable);
226
//  uart1_puts_p(text); uart1_puts(printbuff); uart1_puts("\r\n");
227
//}
228
//
229
//
230
//void print_data_char( const char *text, char *variable, uint8_t length)
231
//{
232
//  uart1_puts_p(text);
233
//  uart1_puts(variable);
234
//  uart1_puts("\r\n");
235
//}
236
//
237
//
238
//void print_time( const char *text, PKTdatetime_t variable)
239
//{
240
//    uart1_puts_p(text);
241
//    sprintf(printbuff, "%d", variable.day);
242
//    uart1_puts(printbuff);
243
//    uart1_puts(".");
244
//    sprintf(printbuff, "%d", variable.month);
245
//    uart1_puts(printbuff);
246
//    uart1_puts(".");
247
//    sprintf(printbuff, "%d", variable.year);
248
//    uart1_puts(printbuff);
249
////    uart1_puts(" ");
250
////    sprintf(printbuff, "%d", variable.seconds);
251
////    uart1_puts(printbuff);
252
//    uart1_puts("\r\n");
253
//}
254
//
255
//
256
//
257
//void print_OSD_Statistic(void)
258
//{
259
//  print_time (PSTR("begin_StatTime:"),Config.OSD_Statistic.begin_StatTime);
260
//  print_time (PSTR("end_StatTime:"),Config.OSD_Statistic.end_StatTime);
261
//  print_data_uint16 (PSTR("total_FlyTime:"),&Config.OSD_Statistic.total_FlyTime);
262
//  print_data_uint16 (PSTR("last_FlyTime:"),&Config.OSD_Statistic.last_FlyTime);
263
//  print_data_uint16 (PSTR("count_Errorcode:"),&Config.OSD_Statistic.count_Errorcode);
264
//  print_data_int16 (PSTR("max_Altimeter:"),&Config.OSD_Statistic.max_Altimeter);
265
//  print_data_uint16 (PSTR("max_GroundSpeed:"),&Config.OSD_Statistic.max_GroundSpeed);
266
//  print_data_uint16 (PSTR("max_Distance:"),&Config.OSD_Statistic.max_Distance);
267
//  print_data_uint16 (PSTR("max_Current:"),&Config.OSD_Statistic.max_Current);
268
//  print_data_uint16 (PSTR("max_Capacity:"),&Config.OSD_Statistic.max_Capacity);
269
//  print_data_int16 (PSTR("max_Variometer:"),&Config.OSD_Statistic.max_Variometer);
270
//  print_data_int8 (PSTR("max_AngleNick:"),&Config.OSD_Statistic.max_AngleNick);
271
//  print_data_int8 (PSTR("max_AngleRoll:"),&Config.OSD_Statistic.max_AngleRoll);
272
//  print_data_uint8 (PSTR("RC Quality:"),&Config.OSD_Statistic.max_RCQuality);
273
//  print_data_int16 (PSTR("max_TopSpeed:"),&Config.OSD_Statistic.max_TopSpeed);
274
//  print_data_int8 (PSTR("min_AngleNick:"),&Config.OSD_Statistic.min_AngleNick);
275
//  print_data_int8 (PSTR("min_AngleRoll:"),&Config.OSD_Statistic.min_AngleRoll);
276
//  print_data_uint8 (PSTR("min_RCQuality:"),&Config.OSD_Statistic.min_RCQuality);
277
//  print_data_uint8 (PSTR("min_UBat:"),&Config.OSD_Statistic.min_UBat);
278
//  print_data_uint8 (PSTR("LiPoCells:"),&Config.OSD_Statistic.LiPoCells);
279
//  print_data_uint8 (PSTR("BL_Count:"),&Config.OSD_Statistic.BL_Count);
280
//}
281
 
282
 
283
 
284
//void SendConfigData(void)
285
//{
286
 
287
//  print_data_uint8 (strGet(START_VERSIONCHECK),&Config.Version );
288
//  print_data_uint8 (strGet(LOWBAT),&Config.MK_LowBat );
289
//  print_data_uint8 (strGet(LOWBAT),&Config.DisplayTimeout );
290
//  print_data_uint8 (strGet(LOWBAT),&Config.DisplayLanguage );
291
//  print_data_uint8 (strGet(WITXRX),&Config.WiTXRXChannel);
292
//  print_data_uint8 (strGet(WINETWG),&Config.WiNetworkGroup);
293
//  print_data_uint8 (strGet(WINETWM),&Config.WiNetworkMode);
294
//  print_data_uint8 (strGet(WITIMEOUT),&Config.WiTXTO);
295
//  print_data_uint8 (strGet(WIUART),&Config.WiUartMTU);
296
//  print_data_uint8 (strGet(DISPLAY8),&Config.OSD_ShowMKSetting);
297
//  print_data_uint8 (strGet(DISPLAY7),&Config.LCD_DisplayMode);
298
//  print_data_uint8 (strGet(DISPLAY6),&Config.LCD_Kontrast);
299
//  print_data_uint8 (strGet(DISPLAY5),&Config.LCD_Helligkeit);
300
//  print_data_uint8 (PSTR("USB-Betrieb:"),&Config.USBBT);
301
//  print_data_uint8 (PSTR("Uart-FC/Wi:"),&Config.U02SV2);
302
//  print_data_uint8 (PSTR("PKT-Debug:"),&Config.Debug);
303
//  print_data_uint8 (PSTR("Wi232 eingebaut:"),&Config.UseWi);
304
//  print_data_uint8 (PSTR("BTM222 eingebaut:"),&Config.UseBT);
305
//  print_data_uint8 (PSTR("Wi232 ok:"),&Config.WiIsSet);
306
//  print_data_uint8 (PSTR("BTM222 ok:"),&Config.BTIsSet);
307
//  print_data_uint8 (PSTR("BTM222 Slave:"),&Config.BTIsSlave);
308
//
309
//  print_data_char (PSTR("BTM222 Pin:"),&Config.bt_pin[0],bt_pin_length );
310
//  print_data_char (PSTR("BTM222 Name:"),&Config.bt_name[0],bt_name_length);
311
//  print_data_char (PSTR("BTM222 REID:"),&Config.RE_ID[0],RE_ID_length );
312
//  print_data_char (PSTR("BTM222 MAC:"),&Config.bt_Mac[0],bt_mac_length);
313
//  print_data_char (PSTR("GPS DevName:"),&Config.gps_UsedDevName[0],20);
314
//  print_data_char (PSTR("GPS MAC:"),&Config.gps_UsedMac[0],14);
315
//
316
//   print_data_int32 (PSTR("LastLongitude:"),&Config.LastLongitude);
317
////  print_data_int32(PSTR("LastLatitude:"),&Config.LastLatitude);
318
//
319
//  print_data_uint8 (PSTR("PKT_IdleBeep:"),&Config.PKT_IdleBeep);
320
//  print_data_uint8 (strGet(DISPLAY2),&Config.PKT_StartInfo);
321
//  print_data_uint16 (strGet(LIPO3),&Config.Lipo_UOffset);
322
//  print_data_uint8 (strGet(LIPO2),&Config.PKT_Accutyp);
323
//  print_data_uint8 (strGet(DISPLAY9),&Config.OSD_RCErrorbeep);
324
//  print_data_uint8 (strGet(OSD_Invert_Out),&Config.OSD_InvertOut);
325
//  print_data_uint8 (strGet(OSD_LED_Form),&Config.OSD_LEDform);
326
//  print_data_uint8 (strGet(OSD_Send_OSD),&Config.OSD_SendOSD);
327
//  print_data_uint8 (strGet(FALLSPEED),&Config.OSD_Fallspeed);
328
//  print_data_uint8 (strGet(OSD_VARIOBEEP),&Config.OSD_VarioBeep);
329
//  print_data_uint8 (strGet(OSD_HOMEMKVIEW),&Config.OSD_HomeMKView);
330
//  print_data_uint16 (strGet(OSD_MAHWARNING),&Config.OSD_mAh_Warning);
331
//  print_data_uint8 (strGet(OSD_SCREENMODE),&Config.OSD_ScreenMode);
332
//  print_data_uint8 (strGet(OSD_LIPOBAR),&Config.OSD_LipoBar);
333
//  print_data_uint8 (strGet(PKT_BAUDRATE),&Config.PKT_Baudrate);
334
//  print_data_uint16 (strGet(FOLLOWME_1),&Config.FM_Refresh);
335
//  print_data_uint16 (strGet(FOLLOWME_2),&Config.FM_Speed);
336
//  print_data_uint16 (strGet(FOLLOWME_3),&Config.FM_Radius);
337
//  print_data_uint8 (strGet(HWSOUND),&Config.HWSound);
338
//  print_data_uint8 (strGet(HWBEEPER),&Config.HWBeeper);
339
//  print_data_uint8 (PSTR("sIdxSteps:"),&Config.sIdxSteps);
340
//  print_data_uint8 (strGet(SV_TEST3),&Config.servo_frame);
341
//  print_data_uint8 (strGet(SV_SINGLESTEP),&Config.single_step);
342
//  print_data_uint8 (strGet(SV_COUNTTEST),&Config.repeat);
343
//  print_data_uint8 (strGet(SV_PAUSEEND),&Config.pause);
344
//  print_data_uint8 (strGet(SV_PAUSEINC),&Config.pause_step);
345
////  print_data_int8 (,&Config.tracking);
346
////  print_data_int8 (,&Config.track_tx);
347
//  print_data_uint16 (PSTR("Stick1_min:"),&Config.stick_min[0]);
348
//  print_data_uint16 (PSTR("Stick2_min:"),&Config.stick_min[1]);
349
//  print_data_uint16 (PSTR("Stick3_min:"),&Config.stick_min[2]);
350
//  print_data_uint16 (PSTR("Stick4_min:"),&Config.stick_min[3]);
351
//  print_data_uint16 (PSTR("Stick5_min:"),&Config.stick_min[4]);
352
//  print_data_uint16 (PSTR("Stick1_max:"),&Config.stick_max[0]);
353
//  print_data_uint16 (PSTR("Stick2_max:"),&Config.stick_max[1]);
354
//  print_data_uint16 (PSTR("Stick3_max:"),&Config.stick_max[2]);
355
//  print_data_uint16 (PSTR("Stick4_max:"),&Config.stick_max[3]);
356
//  print_data_uint16 (PSTR("Stick5_max:"),&Config.stick_max[4]);
357
//  print_data_uint8 (PSTR("Stick1_typ:"),&Config.stick_typ[0]);
358
//  print_data_uint8 (PSTR("Stick2_typ:"),&Config.stick_typ[1]);
359
//  print_data_uint8 (PSTR("Stick3_typ:"),&Config.stick_typ[2]);
360
//  print_data_uint8 (PSTR("Stick4_typ:"),&Config.stick_typ[3]);
361
//  print_data_uint8 (PSTR("Stick5_typ:"),&Config.stick_typ[4]);
362
//  print_data_uint8 (PSTR("Stick1_neutral:"),&Config.stick_neutral[0]);
363
//  print_data_uint8 (PSTR("Stick2_neutral"),&Config.stick_neutral[1]);
364
//  print_data_uint8 (PSTR("Stick3_neutral:"),&Config.stick_neutral[2]);
365
//  print_data_uint8 (PSTR("Stick4_neutral:"),&Config.stick_neutral[3]);
366
//  print_data_uint8 (PSTR("Stick5_neutral:"),&Config.stick_neutral[4]);
367
//  print_data_uint8 (strGet(LIPO_MESSUNG),&Config.Lipomessung);
368
//  print_OSD_Statistic();
369
//}
370
 
371
 
372
//--------------------------------------------------------------
373
//--------------------------------------------------------------
374
void WriteWiInitFlag(void)
375
{
376
       Config.WiIsSet = true;
377
}
378
 
379
 
380
//--------------------------------------------------------------
381
//--------------------------------------------------------------
382
void WriteBTInitFlag(void)
383
{
384
     Config.BTIsSet = true;
385
}
386
//--------------------------------------------------------------
387
//--------------------------------------------------------------
388
void WriteWLInitFlag(void)
389
{
390
     Config.WLIsSet = true;
391
}
392
 
393
//--------------------------------------------------------------
394
//--------------------------------------------------------------
395
void WriteBTSlaveFlag(void)
396
{
397
     Config.BTIsSlave = true;
398
}
399
 
400
 
401
//--------------------------------------------------------------
402
//--------------------------------------------------------------
403
void WriteBTMasterFlag(void)
404
{
405
     Config.BTIsSlave = false;
406
}
407
 
408
 
409
//--------------------------------------------------------------
410
//--------------------------------------------------------------
411
void WriteLastPosition( uint32_t ELongitude, uint32_t ELatitude)
412
 
413
{
414
    Config.LastLongitude = ELongitude;
415
    Config.LastLatitude  = ELatitude;
416
}
417
 
418
 
419
 
420
//--------------------------------------------------------------
421
//--------------------------------------------------------------
422
void ReadParameter( void )
423
{
424
    eeprom_read_block( (void*)&Config, (const void*)&EEStruct, sizeof(ST) );
425
 
426
    // DEBUG !!
427
    //Config.Version = 0x82;
428
    //WriteParameter();
429
    //return;
430
 
431
 
432
    //-------------------
433
    // ggf. ungueltige Zeichen aus dem
434
    // Bluetooth-Namen eliminieren
435
    //-------------------
436
    #ifdef USE_BLUETOOTH
437
    bt_fixname();
438
    #endif
439
 
440
    //-------------------
441
    // 27.03.2014 OG
442
    // Als Vorbereitung die Niederländische Sprache
443
    // zu entfernen wird hier ggf. Niederländisch
444
    // auf Englisch umgeschaltet
445
    //-------------------
446
    if( Config.DisplayLanguage == 2 )   // 2 = ehemals Niederländisch
447
        Config.DisplayLanguage = 1;     // -> wird zu 1 = Englisch
448
 
449
    //-------------------
450
    // 0. EEprom-Version nicht geaendert
451
    //-------------------
452
    if( Config.Version == EEpromVersion )                   // nichts zu tun...
453
    {
454
        return;                                             // !!! EXIT !!!
455
    }
456
 
457
 
458
    //-------------------
459
    // 1. PKT-Upgrade NICHT Update faehig
460
    //    ODER Downgrade
461
    //
462
    // 0x77 = PKT Version 3.6.6a
463
    //-------------------
464
    if( (Config.Version < 0x77) || (Config.Version > EEpromVersion) )
465
    {
466
        Delete_EEPROM();
467
        return;                                             // !!! EXIT !!!
468
    }
469
 
470
 
471
    //-------------------
472
    // 2. PKT-Upgrade
473
    //-------------------
474
 
475
    //++++++++++++++++++++++++++++
476
    // bei Eeprom-Versionwechsel
477
    // IMMER loeschen
478
    //++++++++++++++++++++++++++++
479
#ifdef USE_WAYPOINTS
480
    PointList_Clear();                                      // Init Waypoints
481
#endif
482
    STAT_Init();                                            // Init OSD Statistik
483
    GPS_User_Init();                                        // Init GPS Positionen
484
    MKErr_Log_Init();                                       // Init MK Errorlog
485
 
486
 
487
    //++++++++++++++++++++++++++++
488
    // inkrementelle Updates
489
    //++++++++++++++++++++++++++++
490
 
491
    //-----------------------------
492
    //--- ab PKT v3.6.9bX6
493
    //-----------------------------
494
    if( Config.Version < 0x81 )
495
    {
496
        Config.timezone   = 1;
497
        Config.summertime = 1;
498
    }
499
 
500
    //-----------------------------
501
    //--- ab PKT v3.7.0b
502
    //-----------------------------
503
    if( Config.Version < 0x82 )
504
    {
505
        Config.OSD_ShowMKSetting = true;
506
    }
507
 
508
    //-----------------------------
509
    //--- ab PKT v3.7.0e
510
    //-----------------------------
511
    if( Config.Version < 0x83 )
512
    {
513
        Config.UseWL   = false;
514
        Config.WLIsSet = false;
515
        strcpy_P( Config.Wlan_SSID    , PSTR("PKT"));       // Wlan
516
        strcpy_P( Config.Wlan_Password, PSTR("12345678"));  // Wlan
517
    }
518
 
519
    //-----------------------------
520
    //--- ab PKT v3.7.0eX1
521
    //-----------------------------
522
    if( Config.Version < 0x84 )
523
    {
524
        Config.OSD_UseScreen = 0xffffffff;                  // alle verfuegbaren OSD-Screens eingeschaltet
525
    }
526
 
527
    //-----------------------------
528
    //--- ab PKT v3.7.0f
529
    //-----------------------------
530
    if( Config.Version < 0x85 )
531
    {
532
       Config.Wlan_DHCP    = 0;
533
       Config.Wlan_WPA     = 0;
534
       Config.Wlan_Adhoc   = true;
535
       Config.Wlan_Channel = 1;
536
       strcpy_P( Config.Wlan_IP     , PSTR("169.254.001.001"));
537
       strcpy_P( Config.Wlan_Netmask, PSTR("255.255.000.000"));
538
       strcpy_P( Config.Wlan_Gateway, PSTR("169.254.001.001"));
539
    }
540
 
541
    //-----------------------------
542
    //--- ab PKT v3.7.3cX5
543
    //-----------------------------
544
    if( Config.Version < 0x87 )
545
    {
546
        Config.OSD_ShowCellU = false;                      //
547
    }
548
 
549
 
550
    //-----------------------------
551
    //--- 01.04.2014 OG
552
    //--- ab PKT v3.7.4aX7
553
    //-----------------------------
554
    if( Config.Version < 136 )
555
    {
556
        Config.UseBLE = false;                                              // Bluetooth 4 LowPower wird genutzt (RedBearLab BLE Mini) wird an SV2 genutzt (SV2 Patch erforderlich)
557
        memset( Config.MKParam_Favs, param_EOF, MAX_MKPARAM_FAVORITES );    // Array von MK-Parameter Favoriten des Benutzers
558
    }
559
 
560
 
561
    //-----------------------------
562
    //--- 06.04.2014 OG
563
    //--- ab PKT v3.7.4aX8
564
    //-----------------------------
565
    if( Config.Version < 137 )
566
    {
567
        strcpy_P( Config.Wlan_HomeSSID    , PSTR(""));                      // WiFly Home-Wlan: SSID (Home-WLAN)
568
        strcpy_P( Config.Wlan_HomePassword, PSTR(""));                      // WiFly Home-Wlan: Passwort (Home-WLAN)
569
    }
570
 
571
 
572
    //-----------------------------
573
    //--- 07.05.2014 OG
574
    //--- ab PKT v3.80bX3
575
    //-----------------------------
576
    if( Config.Version < 138 )
577
    {
578
        memset( Config.MKParam_Favs, 0, MAX_MKPARAM_FAVORITES );            // Array von MK-Parameter Favoriten des Benutzers (Vorbelegung jetzt 0)
579
    }
580
 
581
 
582
    //-----------------------------
583
    //--- 17.06.2014 OG
584
    //--- ab PKT v3.80cX5
585
    //-----------------------------
586
    if( Config.Version < 139 )
587
    {
588
        Config.PKTOffTimeout = 0;                                           // autom. PKT ausschalten nach n Minuten (0=immer an)
589
    }
590
 
591
 
592
 
593
    //-------------------
594
    // 3. Update Message
595
    //-------------------
596
    Config.Version = EEpromVersion;                         // Update EEPROM version number
597
    sei();
598
 
599
    lcd_cls();
600
    lcdx_printp_center( 2, PSTR("EEProm updated to"), MNORMAL, 0,0);
601
    lcdx_printp_center( 3, PSTR("new Version")      , MNORMAL, 0,0);
602
    lcdx_printp_center( 5, PSTR("check settings!")  , MNORMAL, 0,0);
603
    lcd_printp_at (18, 7, PSTR("OK")                , MNORMAL);         // Keyline
604
 
605
    while( !get_key_press(1 << KEY_ENTER) );
606
    WriteParameter();
607
    cli();
608
}
609
 
610
 
611
 
612
//--------------------------------------------------------------
613
//--------------------------------------------------------------
614
void WriteParameter( void )
615
{
616
    copy_line(7);
617
    lcd_printp_at( 0, 7, PSTR("   Write EEPROM    "), MNORMAL);
618
    eeprom_update_block( (const void*)&Config, (void*)&EEStruct, sizeof(ST) );
619
    paste_line(7);
620
}
621
 
622
 
623
 
624
//--------------------------------------------------------------
625
//--------------------------------------------------------------
626
void Delete_EEPROM( void )
627
{
628
    uint8_t i;
629
 
630
    // EEPROM auf Default setzen
631
 
632
    lcd_cls();
633
    lcd_printp_at( 0, 0, PSTR(" EEPROM Parameter    "), MINVERS);
634
    lcd_printp_at( 0, 1, PSTR("werden auf")           , MNORMAL);
635
    lcd_printp_at( 0, 2, PSTR("Standardwerte gesetzt"), MNORMAL);
636
 
637
    Config.MK_LowBat        = 137;                              // 13,7V
638
    Config.DisplayTimeout   = 0;                                // Display immer an (autom. LCD ausschalten nach n Minuten)
639
    Config.DisplayLanguage  = 5;                                // default undefined
640
    Config.WiTXRXChannel    = 1;                                // Kanal 1 MK Standard
641
    Config.WiNetworkGroup   = 66;                               // Gruppe 66  MK Standard
642
    Config.WiNetworkMode    = NetMode_Normal;                   // MK Standard
643
    Config.WiTXTO           = TWaitTime16;                      // MK Standard
644
    Config.WiUartMTU        = UartMTU64;                        // MK Standard
645
    Config.OSD_ShowMKSetting= true;                             // Anzeige MK-Setting beim OSD Start
646
    Config.PKTOffTimeout    = 0;                                // PKT immer an (autom. PKT ausschalten nach n Minuten)
647
    Config.LCD_Kontrast     = 20;                               // Kontrast normal
648
    Config.LCD_Helligkeit   = 100;                              // Helligkeit in %
649
    Config.USBBT            = 0;                                // USB Betrieb
650
    Config.U02SV2           = 0;                                // SV2 (Kabel) Standard
651
    Config.Debug            = 0;                                // kein Debug
652
    Config.UseWi            = false;                            // Wi.232 eingebaut?
653
    Config.UseBT            = false;                            // BT-222 eingebaut?
654
    Config.WiIsSet          = false;                            // Flag für die Initialisierung Wi232
655
    Config.BTIsSet          = false;                            // Flag für die Initialisierung Bluetooth
656
    Config.BTIsSlave        = true;                             // Slave Flag setzen
657
    Config.PKT_IdleBeep     = 0;                                // kein Piepsen bei Inaktivität
658
    Config.PKT_StartInfo    = false;                            //   * FREI * (ehemals: PKT Startinfo anzeigen)
659
    Config.OSD_RCErrorbeep  = true;                             // OSD Receiveerrorbeep
660
    Config.OSD_InvertOut    = false;                            // LED Anzeige invertiren
661
    Config.OSD_LEDform      = 1;                                // Form der Anzeige ( + oder schwarz)
662
    Config.OSD_SendOSD      = false;                            // OSD Daten an SV2
663
    Config.OSD_Fallspeed    = 40;                               // maximale Sinkrate
664
    Config.OSD_VarioBeep    = 1;                                // Vario Beep ein
665
    Config.OSD_HomeMKView   = true;                             //   * FREI * (ehemals: Home Circle from MK View)
666
    Config.OSD_mAh_Warning  = 10000;                            // mAh Warnschwelle
667
    Config.OSD_ScreenMode   = 0;                                // Variante des OSD Screen
668
    Config.OSD_LipoBar      = 0;                                // Bargraphanzeige für MK Lipo
669
    Config.PKT_Baudrate     = Baud_57600;                       // Baudrate für BT und Wi232
670
    Config.PKT_Accutyp      = true;                             // verwendeter Akkutyp (true=Lipo, false=LiON)
671
    Config.Lipo_UOffset     = 10000;                            // Offset für PKT-Lipomessung
2214 - 672
    Config.FM_Offest_Latitude       = 0;                                // FollowMe Azimuth
673
    Config.FM_Offset_Longitude      = 0;                                // FollowMe Distance
2136 - 674
    Config.FM_Speed         = 30;                               // FollowMe Speed in m/s *0.1
675
    Config.FM_Radius        = 5;                                // Waypoint Tolerance Radius in meter
676
    Config.HWSound          = 0;                                // Hardware Sounderweiterung an PD7
677
    Config.HWBeeper         = 1;                                // Hardware Beeper an PC7
678
    Config.Volume           = 0;                                // Lautstaerke
679
    Config.LastLongitude    = 0x00000000;
680
    Config.LastLatitude     = 0x00000000;
681
 
682
    strcpy_P(Config.bt_pin , PSTR("0000"));
683
    strcpy_P(Config.bt_name, PSTR("PKT"));                      // Bluetooth-Name max. 10 Zeichen! - NICHT mit Leerzeichen auffüllen (bt_name_length)
684
    strcpy_P(Config.bt_Mac , PSTR("0000-00-000000"));
685
    strcpy_P(Config.RE_ID  , PSTR("0000"));
686
 
687
    for( i = 0; i < 20; i++)
688
    {
689
       Config.gps_UsedDevName[i]      = 0;                      // benutztes GPS Device Name
690
    }
691
    for( i = 0; i < 14; i++)
692
    {
693
       Config.gps_UsedMac[i] = '0';                             // benutztes GPS Device Mac Adresse
694
    }
695
    Config.gps_UseGPS       = false;                            // ist GPS aktiv?
696
    Config.gps_UsedGPSMouse = GPS_Bluetoothmouse1;
697
 
698
  //Config.WiIsSet          = false;                            // 15.07.2013 CB doppelt drin
699
  //Config.BTIsSet          = false;
700
    Config.Version          = EEpromVersion;
701
    Config.sIdxSteps        = STEPS_255;
702
    Config.servo[0].rev     = SERVO_REV;
703
    Config.servo[0].min     = SERVO_I0_RIGHT;
704
    Config.servo[0].max     = SERVO_I0_LEFT;
705
    Config.servo[0].mid     = SERVO_I0_MIDDLE;
706
    Config.servo[1].rev     = SERVO_REV;
707
    Config.servo[1].min     = SERVO_I0_RIGHT;
708
    Config.servo[1].max     = SERVO_I0_LEFT;
709
    Config.servo[1].mid     = SERVO_I0_MIDDLE;
710
    Config.servo_frame      = SERVO_PERIODE;
711
    Config.single_step      = SINGLE_STEP;                      // nur bei Test-Servo
712
    Config.repeat           = REPEAT;                           // nur bei Test-Servo
713
    Config.pause            = PAUSE;                            // nur bei Test-Servo
714
    Config.pause_step       = PAUSE_STEP;                       // nur bei Test-Servo
715
    Config.tracking         = TRACKING_MIN;
716
    Config.track_hyst       = TRACKING_HYSTERESE;
717
    Config.track_tx         = 0;
718
 
719
    for( i=0; i<5; i++)
720
    {
721
       Config.stick_min[i]      = 30+i;                         // Joystick
722
       Config.stick_max[i]      = 270+i;                        // Joystick
723
       Config.stick_typ[i]      = 0;                            // Joystick
724
       Config.stick_dir[i]      = 0;                            // Joystick
725
       Config.stick_neutral[i]  = 0;                            // Joystick
726
    }
727
 
728
    Config.Lipomessung          = true;
729
 
730
    Config.timezone             = 1;
731
    Config.summertime           = 1;
732
 
733
    strcpy_P( Config.Wlan_SSID    , PSTR("PKT"));               // Wlan
734
    strcpy_P( Config.Wlan_Password, PSTR("12345678"));          // Wlan
735
    Config.WLIsSet              = false;                        // Wlan
736
    Config.UseWL                = false;
737
    Config.OSD_UseScreen        = 0xffffffff;                   // alle OSD-Screens eingeschaltet
738
    Config.Wlan_DHCP            = 0;                            // kein DHCP
739
    Config.Wlan_WPA             = 0;                            // 0 = adhoc 1= WPA2
740
    Config.Wlan_Adhoc           = true;                         // Adhoc
741
    Config.Wlan_Channel         = 1;                            // Wlan Channel
742
    strcpy_P( Config.Wlan_IP     , PSTR("169.254.001.001"));
743
    strcpy_P( Config.Wlan_Netmask, PSTR("255.255.000.000"));
744
    strcpy_P( Config.Wlan_Gateway, PSTR("169.254.001.001"));
745
    Config.OSD_ShowCellU        = false;
746
    Config.UseBLE               = false;
747
 
748
    memset( Config.MKParam_Favs, 0, MAX_MKPARAM_FAVORITES );    // Favoriten MK-Parameter (Anzahl: MAX_MKPARAM_FAVORITES = 10)
749
 
750
    strcpy_P( Config.Wlan_HomeSSID    , PSTR(""));              // WiFly Home-Wlan: SSID (Home-WLAN)
751
    strcpy_P( Config.Wlan_HomePassword, PSTR(""));              // WiFly Home-Wlan: Passwort (Home-WLAN)
752
 
753
    //-------------------------------------------------
754
    //-------------------------------------------------
755
#ifdef USE_WAYPOINTS
756
    PointList_Clear();
757
#endif
758
    STAT_Init();                                                // Init OSD Statistik
759
    GPS_User_Init();                                            // Init GPS Positionen
760
    MKErr_Log_Init();                                           // Init MK Errorlog
761
 
762
    WriteParameter();
763
 
764
    //lcd_printp_at (0, 4, PSTR("Waypoints loeschen"), 0);
765
    //EEWayPointList_Clear();
766
 
767
    lcd_printp_at( 0, 6, PSTR("!!Check Parameter!! "), MNORMAL);
768
    lcd_printp_at(18, 7, PSTR("OK")                  , MNORMAL);
769
    sei();
770
    set_beep( 200, 0x0080, BeepNormal);
771
 
772
    while( !get_key_press (1 << KEY_ENTER) );
773
 
774
 
775
//#if defined HWVERSION3_9
776
    clr_V_On();
777
//#else
778
//
779
//  wdt_enable( WDTO_250MS );
780
//                  while (1)
781
//                  {;}
782
//#endif
783
}
784
 
785
 
786
//--------------------------------------------------------------
787
//
788
//void EEWayPointList_Clear(void)           // löschen der Waypointliste im EEProm
789
//{
790
//  uint8_t i;
791
//  PKTWayPoint.Waypoint.Position.Latitude = 0;
792
//  PKTWayPoint.Waypoint.Position.Longitude = 0;
793
//  PKTWayPoint.Waypoint.Position.Altitude = 0;
794
//  PKTWayPoint.Waypoint.Heading = 361;
795
 
796
//  for(i = 0; i < MAX_WPLIST_LEN; i++)
797
//  {
798
//      PKTWayPointDirectory.WPList.WPDirectory[i] = 0;
799
//  }
800
 
801
//  for(i = 0; i < NumberOfWaypoints; i++)
802
//  {
803
//      lcd_printp (PSTR("."), 0);
804
//      eeprom_write_byte (&EEWayPointList[i].WPIndex, i);
805
//      eeprom_write_byte (&EEWayPointList[i].Waypoint.Position.Status, INVALID);
806
//      eeprom_write_block ((const void*)&PKTWayPoint.Waypoint.Position.Latitude, (void*)&EEWayPointList[i].Waypoint.Position.Latitude, sizeof(EEWayPointList[i].Waypoint.Position.Latitude));
807
//      eeprom_write_block ((const void*)&PKTWayPoint.Waypoint.Position.Longitude, (void*)&EEWayPointList[i].Waypoint.Position.Longitude, sizeof(EEWayPointList[i].Waypoint.Position.Longitude));
808
//      eeprom_write_block ((const void*)&PKTWayPoint.Waypoint.Position.Altitude, (void*)&EEWayPointList[i].Waypoint.Position.Altitude, sizeof(EEWayPointList[i].Waypoint.Position.Altitude));
809
//      eeprom_write_block ((const void*)&PKTWayPoint.Waypoint.Heading, (void*)&EEWayPointList[i].Waypoint.Heading, sizeof(EEWayPointList[i].Waypoint.Heading));
810
//
811
//      eeprom_write_byte (&EEWayPointList[i].Waypoint.ToleranceRadius, 0);     // in meters, if the MK is within that range around the target, then the next target is triggered
812
//      eeprom_write_byte (&EEWayPointList[i].Waypoint.HoldTime, 0);            // in seconds, if the was once in the tolerance area around a WP, this time defines the delay before the next WP is triggered
813
//      eeprom_write_byte (&EEWayPointList[i].Waypoint.Type, POINT_TYPE_INVALID);
814
//      eeprom_write_byte (&EEWayPointList[i].Waypoint.Event_Flag, 0);          // future implementation
815
//      eeprom_write_byte (&EEWayPointList[i].Waypoint.AltitudeRate, 0);        // no change of setpoint
816
//  }
817
 
818
//  for(i = 0; i < NumberOfWPLists; i++)
819
//  {
820
//      lcd_printp (PSTR("."), 0);
821
//      eeprom_write_byte (&EEWPDirectory[i].WPList.WPListnumber, i);
822
//      eeprom_write_byte (&EEWPDirectory[i].WPList.WPListAktiv, false);
823
//      eeprom_write_byte (&EEWPDirectory[i].WPList.POI_CAM_NICK_CTR, 0);
824
//      eeprom_write_byte (&EEWPDirectory[i].WPList.UsePOI, 0);
825
//      eeprom_write_block ((const void*)&PKTWayPointDirectory.WPList.WPDirectory, (void*)&EEWPDirectory[i].WPList.WPDirectory, sizeof(EEWPDirectory[i].WPList.WPDirectory));
826
//
827
//  }
828
//  lcd_printp (PSTR("\r\n"), 0);
829
 
830
//}