Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1734 | - | 1 | /***************************************************************************** |
2 | * Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
||
3 | * Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
||
4 | * Copyright (C) 2011 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 | |||
35 | #include "cpu.h" |
||
36 | #include <avr/io.h> |
||
37 | #include <avr/pgmspace.h> |
||
38 | #include <util/delay.h> |
||
39 | #include <stdlib.h> |
||
40 | #include <string.h> |
||
41 | #include <avr/eeprom.h> |
||
42 | #include <stdbool.h> |
||
43 | #include <avr/wdt.h> |
||
44 | #include "lcd.h" |
||
45 | #include "main.h" |
||
46 | #include "timer.h" |
||
47 | #include "eeprom.h" |
||
48 | #include "Wi232.h" |
||
49 | #include "mk-data-structs.h" |
||
50 | #include "connect.h" |
||
51 | |||
52 | |||
53 | //-------------------------------------------------------------- |
||
54 | // |
||
55 | |||
56 | uint8_t EE_LowBat EEMEM = 137; // 13,7V |
||
57 | uint8_t EE_DisplayTimeout EEMEM = 0; // Display immer an |
||
58 | uint8_t EE_DisplayLanguage EEMEM = 254; // Default ungesetzt |
||
59 | uint8_t EE_WiTXRXChannel EEMEM = 1; // Kanal 1 MK Standard |
||
60 | uint8_t EE_WiNetworkGroup EEMEM = 66; // Gruppe 66 MK Standard |
||
61 | uint8_t EE_WiNetworkMode EEMEM = NetMode_Normal; // MK Standard; |
||
62 | uint8_t EE_WiTXTO EEMEM = TWaitTime16; // MK Standard |
||
63 | uint8_t EE_WiUartMTU EEMEM = UartMTU64; // MK Standard |
||
64 | uint8_t EE_LCD_Orientation EEMEM = 0; // normale Ansicht |
||
65 | uint8_t EE_LCD_DisplayMode EEMEM = 0; // Normal |
||
66 | uint8_t EE_LCD_Kontrast EEMEM = 27; // Kontrast normal |
||
67 | uint8_t EE_LCD_Helligkeit EEMEM = 100; // Helligkeit in %gkeit in % |
||
68 | uint8_t EE_USBBT EEMEM = 0; // USB Betrieb |
||
69 | uint8_t EE_U02SV2 EEMEM = 1; // SV2 (Kabel) Standard |
||
70 | uint8_t EE_Debug EEMEM = 0; // kein Debug |
||
71 | uint8_t EE_UseWi EEMEM = true; // Wi.232 eingebaut? |
||
72 | uint8_t EE_UseBT EEMEM = true; // BT-222 eingebaut? |
||
73 | uint8_t EE_BTIsSlave EEMEM = true; // BT-222 Slave gesetzt? |
||
74 | uint8_t EE_WiIsSet EEMEM = false; // Flag für die Initialisierung Wi232 |
||
75 | uint8_t EE_BTIsSet EEMEM = false; // Flag für die Initialisierung Bluetooth |
||
76 | uint8_t EE_PKT_IdleBeep EEMEM = 0; // kein Piepsen bei Inaktivität |
||
77 | uint8_t EE_PKT_StartInfo EEMEM = true; // Startinformationen anzeigen |
||
78 | uint16_t EE_Lipo_UOffset EEMEM = 0; // Offset für die Lipospannugsmessung |
||
79 | uint8_t EE_PKT_Accutyp EEMEM = true; // True = Lipo, False = LiON |
||
80 | uint8_t EE_OSD_RCErrorbeep EEMEM = true; //Empfangsausffallwarnung im OSD Screen |
||
81 | uint8_t EE_OSD_InvertOut EEMEM = false; // Invertierte Anzeige Out1 und Out2 |
||
82 | uint8_t EE_OSD_LEDform EEMEM = 1; // Form der Anzeige ( + oder schwarz) |
||
83 | uint8_t EE_OSD_SendOSD EEMEM = false; // Sende OSD-Daten an SV2 |
||
84 | uint8_t EE_OSD_Fallspeed EEMEM = 0; // Maximal Sinkrate, für Warnmeldung |
||
85 | uint8_t EE_OSD_VarioBeep EEMEM = 1; // Vario Beep im OSD Screen |
||
86 | uint8_t EE_OSD_HomeMKView EEMEM = true; // Home Circle from MK-View |
||
87 | uint16_t EE_OSD_mAh_Warning EEMEM = 10000; //Warnschwelle für mAh |
||
88 | uint8_t EE_OSD_ScreenMode EEMEM = 0; //Variante des OSD-Screen |
||
89 | uint8_t EE_OSD_LipoBar EEMEM = 0; //Bargraphanzeige für MK Lipo |
||
90 | uint8_t EE_PKT_Baudrate EEMEM = Wi232_57600; // Baudrate für BT und Wi232, siehe Wi223.h |
||
91 | uint16_t EE_FM_Refresh EEMEM = 500; // FollowMe interval |
||
92 | uint16_t EE_FM_Speed EEMEM = 30; // FollowMe Speed in m/s *0.1 |
||
93 | uint16_t EE_FM_Radius EEMEM = 5; // Waypoint Tolerance Radius in meter |
||
94 | |||
95 | uint8_t EEMEM EE_BTPin[bt_pin_length + 1]; |
||
96 | uint8_t EEMEM EE_BTName[bt_name_length + 1]; |
||
97 | |||
98 | uint8_t EEMEM EE_gps_UsedDevName[20]; // benutztes GPS Device Name |
||
99 | uint8_t EEMEM EE_gps_UsedMac[14]; // benutztes GPS Device Mac Adresse |
||
100 | uint8_t EEMEM EE_gps_UseGPS; // ist GPS aktiv? |
||
101 | uint8_t EEMEM EE_gps_UsedGPSMouse; // GPS Maustyp |
||
102 | |||
103 | uint32_t EE_LastLongitude EEMEM = 0; |
||
104 | uint32_t EE_LastLatitude EEMEM = 0; |
||
105 | |||
106 | WPListDirectory EEWPDirectory[NumberOfWPLists] EEMEM; |
||
107 | WayPoints EEWayPointList[NumberOfWaypoints] EEMEM; |
||
108 | |||
109 | |||
110 | uint8_t EE_PKTVersion EEMEM = EEpromVersion; |
||
111 | |||
112 | |||
113 | volatile uint8_t DisplayTimeout; |
||
114 | volatile uint8_t DisplayLanguage; |
||
115 | volatile uint8_t WiTXRXChannel; |
||
116 | volatile uint8_t WiNetworkGroup; |
||
117 | volatile uint8_t WiNetworkMode; |
||
118 | volatile uint8_t WiTXTO; |
||
119 | volatile uint8_t WiUartMTU; |
||
120 | volatile uint8_t LCD_ORIENTATION; |
||
121 | volatile uint8_t LCD_DisplayMode; |
||
122 | volatile uint8_t LCD_Kontrast; |
||
123 | volatile uint8_t LCD_Helligkeit; |
||
124 | volatile uint8_t USBBT; |
||
125 | volatile uint8_t U02SV2; |
||
126 | volatile uint8_t Debug; |
||
127 | volatile uint8_t UseWi; // Wi232 wird genutzt |
||
128 | volatile uint8_t UseBT; // BT wird genutzt |
||
129 | |||
130 | volatile uint8_t WiIsSet; // Wi232 ist initialisiert |
||
131 | volatile uint8_t BTIsSet; // BT ist initialisiert |
||
132 | volatile uint8_t BTIsSlave; // Slave Flag |
||
133 | char bt_pin[bt_pin_length + 1]; // BT Pinnummer |
||
134 | char bt_name[bt_name_length + 1]; // BT Name |
||
135 | |||
136 | char gps_UsedDevName[20]; // benutztes GPS Device Name |
||
137 | char gps_UsedMac[14]; // benutztes GPS Device Mac Adresse |
||
138 | volatile uint8_t gps_UseGPS; // ist GPS aktiv? |
||
139 | volatile uint8_t gps_UsedGPSMouse; // GPS Maustyp |
||
140 | |||
141 | volatile uint32_t LastLongitude; // Letzte Position |
||
142 | volatile uint32_t LastLatitude; |
||
143 | volatile uint8_t PKT_IdleBeep; |
||
144 | volatile uint8_t PKT_StartInfo; |
||
145 | volatile uint16_t Lipo_UOffset; // Offset für die Lipospannugsmessung |
||
146 | volatile uint8_t PKT_Accutyp; // verwendeter Akkutyp |
||
147 | volatile uint8_t OSD_RCErrorbeep; //Empfangsausffallwarnung im OSD Screen |
||
148 | volatile uint8_t OSD_InvertOut; // Out1/2 invertiert anzeigen |
||
149 | volatile uint8_t OSD_LEDform; // Form der Anzeige ( + oder schwarz) |
||
150 | volatile uint8_t OSD_SendOSD; // OSD Daten an SV2 senden |
||
151 | volatile uint8_t OSD_Fallspeed; // maximale Sinkrate |
||
152 | volatile uint8_t OSD_VarioBeep; // Vario Beep im OSD Screen |
||
153 | volatile uint8_t OSD_HomeMKView; // Home Circle from MK-View |
||
154 | volatile uint16_t OSD_mAh_Warning; // mAh Warnschwelle |
||
155 | volatile uint8_t OSD_ScreenMode; //Variante des OSD-Screen |
||
156 | volatile uint8_t OSD_LipoBar; //Bargraphanzeige für MK Lipo |
||
157 | volatile uint8_t PKT_Baudrate; // Baudrate für BT und Wi232 |
||
158 | volatile uint16_t FM_Refresh; // FollowMe interval |
||
159 | volatile uint16_t FM_Speed; // FollowMe Speed in m/s *0.1 |
||
160 | volatile uint16_t FM_Radius; // Waypoint Tolerance Radius in meter |
||
161 | volatile WayPoints PKTWayPoint; // Waypointdaten für einen Waypoint |
||
162 | volatile WPListDirectory PKTWayPointDirectory; // Inhaltsverzeichnis der Listen |
||
163 | |||
164 | |||
165 | |||
166 | //-------------------------------------------------------------- |
||
167 | // |
||
168 | void WriteWiInitFlag(void) |
||
169 | { |
||
170 | WiIsSet = true; |
||
171 | eeprom_write_byte(&EE_WiIsSet, WiIsSet); |
||
172 | |||
173 | } |
||
174 | |||
175 | |||
176 | //-------------------------------------------------------------- |
||
177 | // |
||
178 | void WriteBTInitFlag(void) |
||
179 | { |
||
180 | BTIsSet = true; |
||
181 | eeprom_write_byte(&EE_BTIsSet, BTIsSet); |
||
182 | |||
183 | } |
||
184 | //-------------------------------------------------------------- |
||
185 | // |
||
186 | void WriteBTSlaveFlag(void) |
||
187 | { |
||
188 | BTIsSlave = true; |
||
189 | eeprom_write_byte(&EE_BTIsSlave, BTIsSlave); |
||
190 | |||
191 | } |
||
192 | //-------------------------------------------------------------- |
||
193 | // |
||
194 | void WriteBTMasterFlag(void) |
||
195 | { |
||
196 | BTIsSlave = false; |
||
197 | eeprom_write_byte(&EE_BTIsSlave, BTIsSlave); |
||
198 | |||
199 | } |
||
200 | //-------------------------------------------------------------- |
||
201 | // |
||
202 | void ReadLastPosition(void) |
||
203 | |||
204 | { |
||
205 | LastLongitude = eeprom_read_dword(&EE_LastLongitude); |
||
206 | LastLatitude = eeprom_read_dword(&EE_LastLatitude); |
||
207 | } |
||
208 | |||
209 | |||
210 | //-------------------------------------------------------------- |
||
211 | // |
||
212 | void WriteLastPosition(uint32_t ELongitude,uint32_t ELatitude) |
||
213 | |||
214 | { |
||
215 | |||
216 | eeprom_write_dword(&EE_LastLongitude,ELongitude); |
||
217 | eeprom_write_dword(&EE_LastLatitude,ELatitude); |
||
218 | } |
||
219 | |||
220 | |||
221 | //-------------------------------------------------------------- |
||
222 | // |
||
223 | void ReadParameter (void) |
||
224 | { |
||
225 | if (eeprom_read_byte(&EE_PKTVersion) == EEpromVersion) |
||
226 | |||
227 | { |
||
228 | MK_LowBat = eeprom_read_byte (&EE_LowBat); |
||
229 | DisplayTimeout = eeprom_read_byte (&EE_DisplayTimeout); |
||
230 | DisplayLanguage = eeprom_read_byte (&EE_DisplayLanguage); |
||
231 | WiTXRXChannel = eeprom_read_byte (&EE_WiTXRXChannel); |
||
232 | WiNetworkGroup = eeprom_read_byte (&EE_WiNetworkGroup); |
||
233 | WiNetworkMode = eeprom_read_byte (&EE_WiNetworkMode); |
||
234 | WiTXTO = eeprom_read_byte (&EE_WiTXTO); |
||
235 | WiUartMTU = eeprom_read_byte (&EE_WiUartMTU); |
||
236 | LCD_ORIENTATION = eeprom_read_byte (&EE_LCD_Orientation); |
||
237 | LCD_DisplayMode = eeprom_read_byte (&EE_LCD_DisplayMode); |
||
238 | LCD_Kontrast = eeprom_read_byte (&EE_LCD_Kontrast); |
||
239 | LCD_Helligkeit = eeprom_read_byte (&EE_LCD_Helligkeit); |
||
240 | USBBT = eeprom_read_byte (&EE_USBBT); |
||
241 | U02SV2 = eeprom_read_byte (&EE_U02SV2); |
||
242 | Debug = eeprom_read_byte (&EE_Debug); |
||
243 | UseWi = eeprom_read_byte (&EE_UseWi); |
||
244 | UseBT = eeprom_read_byte (&EE_UseBT); |
||
245 | WiIsSet = eeprom_read_byte (&EE_WiIsSet); |
||
246 | BTIsSet = eeprom_read_byte (&EE_BTIsSet); |
||
247 | BTIsSlave = eeprom_read_byte (&EE_BTIsSlave); |
||
248 | PKT_IdleBeep = eeprom_read_byte (&EE_PKT_IdleBeep); |
||
249 | PKT_StartInfo = eeprom_read_byte (&EE_PKT_StartInfo); |
||
250 | Lipo_UOffset = eeprom_read_word (&EE_Lipo_UOffset); |
||
251 | PKT_Accutyp = eeprom_read_byte (&EE_PKT_Accutyp); |
||
252 | OSD_RCErrorbeep = eeprom_read_byte (&EE_OSD_RCErrorbeep); |
||
253 | OSD_InvertOut = eeprom_read_byte (&EE_OSD_InvertOut); |
||
254 | OSD_LEDform = eeprom_read_byte (&EE_OSD_LEDform); |
||
255 | OSD_SendOSD = eeprom_read_byte (&EE_OSD_SendOSD); |
||
256 | OSD_Fallspeed = eeprom_read_byte (&EE_OSD_Fallspeed); |
||
257 | OSD_VarioBeep = eeprom_read_byte (&EE_OSD_VarioBeep); |
||
258 | OSD_HomeMKView = eeprom_read_byte (&EE_OSD_HomeMKView); |
||
259 | OSD_mAh_Warning = eeprom_read_word (&EE_OSD_mAh_Warning); |
||
260 | OSD_ScreenMode = eeprom_read_byte (&EE_OSD_ScreenMode); |
||
261 | OSD_LipoBar = eeprom_read_byte (&EE_OSD_LipoBar); |
||
262 | PKT_Baudrate = eeprom_read_byte (&EE_PKT_Baudrate); |
||
263 | FM_Refresh = eeprom_read_word (&EE_FM_Refresh); |
||
264 | FM_Speed = eeprom_read_word (&EE_FM_Speed); |
||
265 | FM_Radius = eeprom_read_word (&EE_FM_Radius); |
||
266 | |||
267 | New_Baudrate = PKT_Baudrate; // Merkzellen setzen |
||
268 | Old_Baudrate = PKT_Baudrate; |
||
269 | eeprom_read_block ((void*)&bt_pin, (const void*)&EE_BTPin, bt_pin_length); |
||
270 | eeprom_read_block ((void*)&bt_name, (const void*)&EE_BTName, bt_name_length); |
||
271 | eeprom_read_block ((void*)&gps_UsedDevName, (const void*)&EE_gps_UsedDevName, 20); |
||
272 | eeprom_read_block ((void*)&gps_UsedMac, (const void*)&EE_gps_UsedMac, 14); |
||
273 | gps_UseGPS = eeprom_read_byte (&EE_gps_UseGPS); |
||
274 | gps_UsedGPSMouse = eeprom_read_byte (&EE_gps_UsedGPSMouse); |
||
275 | LastLongitude = eeprom_read_dword (&EE_LastLongitude); |
||
276 | LastLatitude = eeprom_read_dword (&EE_LastLatitude); |
||
277 | } |
||
278 | |||
279 | else |
||
280 | Delete_EEPROM(); |
||
281 | |||
282 | } |
||
283 | |||
284 | //-------------------------------------------------------------- |
||
285 | void Delete_EEPROM(void) |
||
286 | { |
||
287 | // EEPROM auf Default setzen |
||
288 | |||
289 | lcd_cls(); |
||
290 | lcd_printp_at (0, 0, PSTR(" EEPROM Parameter "), 2); |
||
291 | lcd_printp_at (0, 1, PSTR("werden auf"), 0); |
||
292 | lcd_printp_at (0, 2, PSTR("Standardwerte gesetzt"), 0); |
||
293 | |||
294 | MK_LowBat = 137; // 13,7V |
||
295 | DisplayTimeout = 0; // Display immer an |
||
296 | DisplayLanguage = 1; // default englisch |
||
297 | WiTXRXChannel = 1; // Kanal 1 MK Standard |
||
298 | WiNetworkGroup = 66; // Gruppe 66 MK Standard |
||
299 | WiNetworkMode = NetMode_Normal; // MK Standard |
||
300 | WiTXTO = TWaitTime16; // MK Standard |
||
301 | WiUartMTU = UartMTU64; // MK Standard |
||
302 | LCD_ORIENTATION = 0; // normale Ansicht |
||
303 | LCD_DisplayMode = 0; // Normal |
||
304 | LCD_Kontrast = 20; // Kontrast normal |
||
305 | LCD_Helligkeit = 100; // Helligkeit in % |
||
306 | USBBT = 0; // USB Betrieb |
||
307 | U02SV2 = 0; // SV2 (Kabel) Standard |
||
308 | Debug = 0; // kein Debug |
||
309 | UseWi = true; // Wi.232 eingebaut? |
||
310 | UseBT = true; // BT-222 eingebaut? |
||
311 | WiIsSet = false; // Flag für die Initialisierung Wi232 |
||
312 | BTIsSet = false; // Flag für die Initialisierung Bluetooth |
||
313 | BTIsSlave = true; // Slave Flag setzen |
||
314 | PKT_IdleBeep = 0; // kein Piepsen bei Inaktivität |
||
315 | PKT_StartInfo = true; // Startnformationen anzeigen |
||
316 | PKT_Accutyp = true; // True = Lipo, False= LiON |
||
317 | OSD_RCErrorbeep = true; // OSD Receiveerrorbeep |
||
318 | OSD_InvertOut = false; // LED Anzeige invertiren |
||
319 | OSD_LEDform = 1; // Form der Anzeige ( + oder schwarz) |
||
320 | OSD_SendOSD = false; // OSD Daten an SV2 |
||
321 | OSD_Fallspeed = 40; // maximale Sinkrate |
||
322 | OSD_VarioBeep = 1; // Vario Beep ein |
||
323 | OSD_HomeMKView = true; // Home Circle from MK View |
||
324 | OSD_mAh_Warning = 10000; //mAh Warnschwelle |
||
325 | OSD_ScreenMode = 0; // Variante des OSD Screen |
||
326 | OSD_LipoBar = 0; //Bargraphanzeige für MK Lipo |
||
327 | PKT_Baudrate = Wi232_57600; //Baudrate für BT und Wi232 |
||
328 | Lipo_UOffset = 6000; // Offset für PKT-Lipomessung |
||
329 | FM_Refresh = 500; // FollowMe interval |
||
330 | FM_Speed = 30; // FollowMe Speed in m/s *0.1 |
||
331 | FM_Radius = 5; // Waypoint Tolerance Radius in meter |
||
332 | |||
333 | |||
334 | LastLongitude = 88199720; |
||
335 | LastLatitude = 522039630; |
||
336 | eeprom_write_dword(&EE_LastLongitude,LastLongitude); |
||
337 | eeprom_write_dword(&EE_LastLatitude,LastLatitude); |
||
338 | |||
339 | strcpy_P(bt_pin, PSTR("0000")); |
||
340 | eeprom_write_block ((const void*)&bt_pin, (void*)&EE_BTPin, bt_pin_length); |
||
341 | |||
342 | strcpy_P(bt_name, PSTR("PKT Cebra ")); // Wenn Name kürzer als "bt_name_length" mit Leerzeichen auffüllen |
||
343 | eeprom_write_block ((const void*)&bt_name, (void*)&EE_BTName, bt_name_length); |
||
344 | |||
345 | for(uint8_t i = 0; i < 20; i++) |
||
346 | { |
||
347 | gps_UsedDevName[i] = 0; // benutztes GPS Device Name |
||
348 | } |
||
349 | for(uint8_t i = 0; i < 14; i++) |
||
350 | { |
||
351 | gps_UsedMac[i] = '0'; // benutztes GPS Device Mac Adresse |
||
352 | } |
||
353 | gps_UseGPS = false; // ist GPS aktiv? |
||
354 | gps_UsedGPSMouse = 0; |
||
355 | |||
356 | eeprom_write_byte(&EE_WiIsSet,WiIsSet); |
||
357 | eeprom_write_byte(&EE_BTIsSet,BTIsSet); |
||
358 | eeprom_write_byte(&EE_PKTVersion,EEpromVersion); |
||
359 | |||
360 | WriteParameter(); |
||
361 | |||
362 | // lcd_printp_at (0, 4, PSTR("Waypoints loeschen"), 0); |
||
363 | // EEWayPointList_Clear(); |
||
364 | |||
365 | lcd_printp_at (0, 6, PSTR("!!Check Parameter!! "), 0); |
||
366 | lcd_printp_at (18, 7, PSTR("OK"), 0); |
||
367 | set_beep ( 200, 0x0080, BeepNormal); |
||
368 | do{} |
||
369 | while (!(get_key_short (1 << KEY_ENTER))); |
||
370 | // _delay_ms(500); |
||
371 | //#if defined HWVERSION3_9 |
||
372 | // clr_V_On(); |
||
373 | //#else |
||
374 | // |
||
375 | // wdt_enable( WDTO_250MS ); |
||
376 | // while (1) |
||
377 | // {;} |
||
378 | //#endif |
||
379 | } |
||
380 | |||
381 | |||
382 | //-------------------------------------------------------------- |
||
383 | // |
||
384 | void WriteParameter (void) |
||
385 | { |
||
386 | eeprom_write_byte (&EE_LowBat, MK_LowBat); |
||
387 | eeprom_write_byte (&EE_DisplayTimeout, DisplayTimeout); |
||
388 | eeprom_write_byte (&EE_DisplayLanguage, DisplayLanguage); |
||
389 | eeprom_write_byte (&EE_WiTXRXChannel, WiTXRXChannel); |
||
390 | eeprom_write_byte (&EE_WiNetworkGroup, WiNetworkGroup); |
||
391 | eeprom_write_byte (&EE_WiNetworkMode, WiNetworkMode); |
||
392 | eeprom_write_byte (&EE_WiTXTO, WiTXTO); |
||
393 | eeprom_write_byte (&EE_WiUartMTU, WiUartMTU); |
||
394 | eeprom_write_byte (&EE_LCD_Orientation, LCD_ORIENTATION); |
||
395 | eeprom_write_byte (&EE_LCD_DisplayMode, LCD_DisplayMode); |
||
396 | eeprom_write_byte (&EE_LCD_Kontrast, LCD_Kontrast); |
||
397 | eeprom_write_byte (&EE_LCD_Helligkeit, LCD_Helligkeit); |
||
398 | eeprom_write_byte (&EE_USBBT, USBBT); |
||
399 | eeprom_write_byte (&EE_U02SV2, U02SV2); |
||
400 | eeprom_write_byte (&EE_Debug, Debug); |
||
401 | eeprom_write_byte (&EE_UseWi, UseWi); |
||
402 | eeprom_write_byte (&EE_UseBT, UseBT); |
||
403 | eeprom_write_byte (&EE_WiIsSet, WiIsSet); |
||
404 | eeprom_write_byte (&EE_BTIsSet, BTIsSet); |
||
405 | eeprom_write_byte (&EE_BTIsSlave, BTIsSlave); |
||
406 | eeprom_write_byte (&EE_PKT_IdleBeep, PKT_IdleBeep); |
||
407 | eeprom_write_byte (&EE_PKT_StartInfo, PKT_StartInfo); |
||
408 | eeprom_write_word (&EE_Lipo_UOffset,Lipo_UOffset); |
||
409 | eeprom_write_byte (&EE_PKT_Accutyp, PKT_Accutyp); |
||
410 | eeprom_write_byte (&EE_OSD_RCErrorbeep, OSD_RCErrorbeep); |
||
411 | eeprom_write_byte (&EE_OSD_InvertOut, OSD_InvertOut); |
||
412 | eeprom_write_byte (&EE_OSD_LEDform, OSD_LEDform); |
||
413 | eeprom_write_byte (&EE_OSD_SendOSD, OSD_SendOSD); |
||
414 | eeprom_write_byte (&EE_OSD_Fallspeed, OSD_Fallspeed); |
||
415 | eeprom_write_byte (&EE_OSD_VarioBeep, OSD_VarioBeep); |
||
416 | eeprom_write_byte (&EE_OSD_HomeMKView, OSD_HomeMKView); |
||
417 | eeprom_write_word (&EE_OSD_mAh_Warning, OSD_mAh_Warning); |
||
418 | eeprom_write_byte (&EE_OSD_ScreenMode, OSD_ScreenMode); |
||
419 | eeprom_write_byte (&EE_OSD_LipoBar, OSD_LipoBar); |
||
420 | eeprom_write_byte (&EE_PKT_Baudrate, PKT_Baudrate); |
||
421 | eeprom_write_word (&EE_FM_Refresh,FM_Refresh); |
||
422 | eeprom_write_word (&EE_FM_Speed,FM_Speed); |
||
423 | eeprom_write_word (&EE_FM_Radius,FM_Radius); |
||
424 | |||
425 | eeprom_write_block ((const void*)&bt_pin, (void*)&EE_BTPin, bt_pin_length); |
||
426 | eeprom_write_block ((const void*)&bt_name, (void*)&EE_BTName, bt_name_length); |
||
427 | |||
428 | eeprom_write_block ((const void*)&gps_UsedDevName, (void*)&EE_gps_UsedDevName, 20); |
||
429 | eeprom_write_block ((const void*)&gps_UsedMac, (void*)&EE_gps_UsedMac, 14); |
||
430 | eeprom_write_byte (&EE_gps_UseGPS,gps_UseGPS); |
||
431 | eeprom_write_byte (&EE_gps_UsedGPSMouse,gps_UsedGPSMouse); |
||
432 | |||
433 | } |
||
434 | |||
435 | |||
436 | |||
437 | |||
438 | //-------------------------------------------------------------- |
||
439 | // |
||
440 | void EEWayPointList_Clear(void) // löschen der Waypointliste im EEProm |
||
441 | { |
||
442 | uint8_t i; |
||
443 | PKTWayPoint.Waypoint.Position.Latitude = 0; |
||
444 | PKTWayPoint.Waypoint.Position.Longitude = 0; |
||
445 | PKTWayPoint.Waypoint.Position.Altitude = 0; |
||
446 | PKTWayPoint.Waypoint.Heading = 361; |
||
447 | |||
448 | for(i = 0; i < MAX_WPLIST_LEN; i++) |
||
449 | { |
||
450 | PKTWayPointDirectory.WPList.WPDirectory[i] = 0; |
||
451 | } |
||
452 | |||
453 | for(i = 0; i < NumberOfWaypoints; i++) |
||
454 | { |
||
455 | lcd_printp (PSTR("."), 0); |
||
456 | eeprom_write_byte (&EEWayPointList[i].WPIndex, i); |
||
457 | eeprom_write_byte (&EEWayPointList[i].Waypoint.Position.Status, INVALID); |
||
458 | eeprom_write_block ((const void*)&PKTWayPoint.Waypoint.Position.Latitude, (void*)&EEWayPointList[i].Waypoint.Position.Latitude, sizeof(EEWayPointList[i].Waypoint.Position.Latitude)); |
||
459 | eeprom_write_block ((const void*)&PKTWayPoint.Waypoint.Position.Longitude, (void*)&EEWayPointList[i].Waypoint.Position.Longitude, sizeof(EEWayPointList[i].Waypoint.Position.Longitude)); |
||
460 | eeprom_write_block ((const void*)&PKTWayPoint.Waypoint.Position.Altitude, (void*)&EEWayPointList[i].Waypoint.Position.Altitude, sizeof(EEWayPointList[i].Waypoint.Position.Altitude)); |
||
461 | eeprom_write_block ((const void*)&PKTWayPoint.Waypoint.Heading, (void*)&EEWayPointList[i].Waypoint.Heading, sizeof(EEWayPointList[i].Waypoint.Heading)); |
||
462 | |||
463 | 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 |
||
464 | 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 |
||
465 | eeprom_write_byte (&EEWayPointList[i].Waypoint.Type, POINT_TYPE_INVALID); |
||
466 | eeprom_write_byte (&EEWayPointList[i].Waypoint.Event_Flag, 0); // future implementation |
||
467 | eeprom_write_byte (&EEWayPointList[i].Waypoint.AltitudeRate, 0); // no change of setpoint |
||
468 | } |
||
469 | |||
470 | for(i = 0; i < NumberOfWPLists; i++) |
||
471 | { |
||
472 | lcd_printp (PSTR("."), 0); |
||
473 | eeprom_write_byte (&EEWPDirectory[i].WPList.WPListnumber, i); |
||
474 | eeprom_write_byte (&EEWPDirectory[i].WPList.WPListAktiv, false); |
||
475 | eeprom_write_byte (&EEWPDirectory[i].WPList.POI_CAM_NICK_CTR, 0); |
||
476 | eeprom_write_byte (&EEWPDirectory[i].WPList.UsePOI, 0); |
||
477 | eeprom_write_block ((const void*)&PKTWayPointDirectory.WPList.WPDirectory, (void*)&EEWPDirectory[i].WPList.WPDirectory, sizeof(EEWPDirectory[i].WPList.WPDirectory)); |
||
478 | |||
479 | } |
||
480 | lcd_printp (PSTR("\r\n"), 0); |
||
481 | |||
482 | } |