Rev 1701 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1701 | Rev 1703 | ||
---|---|---|---|
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Copyright (c) Holger Buss, Ingo Busker |
2 | // + Copyright (c) Holger Buss, Ingo Busker |
3 | // + Nur für den privaten Gebrauch |
3 | // + Nur für den privaten Gebrauch |
4 | // + porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed |
4 | // + porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed |
5 | // + www.MikroKopter.com |
5 | // + www.MikroKopter.com |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
7 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
7 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
8 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
8 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
9 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
9 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
10 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
10 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
11 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
11 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
12 | // + Verkauf von Luftbildaufnahmen, usw. |
12 | // + Verkauf von Luftbildaufnahmen, usw. |
13 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
13 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
14 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
14 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
15 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
15 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
16 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
16 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
17 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
17 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
18 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
18 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
19 | // + eindeutig als Ursprung verlinkt werden |
19 | // + eindeutig als Ursprung verlinkt werden |
20 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
20 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
21 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
21 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
22 | // + Benutzung auf eigene Gefahr |
22 | // + Benutzung auf eigene Gefahr |
23 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
23 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
24 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
24 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
25 | // + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
25 | // + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
26 | // + mit unserer Zustimmung zulässig |
26 | // + mit unserer Zustimmung zulässig |
27 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
27 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
28 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
28 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
29 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
29 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
30 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
30 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
31 | // + this list of conditions and the following disclaimer. |
31 | // + this list of conditions and the following disclaimer. |
32 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
32 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
33 | // + from this software without specific prior written permission. |
33 | // + from this software without specific prior written permission. |
34 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
34 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
35 | // + for non-commercial use (directly or indirectly) |
35 | // + for non-commercial use (directly or indirectly) |
36 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
36 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
37 | // + with our written permission |
37 | // + with our written permission |
38 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
38 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
39 | // + clearly linked as origin |
39 | // + clearly linked as origin |
40 | // + * porting to systems other than hardware from www.mikrokopter.de is not allowed |
40 | // + * porting to systems other than hardware from www.mikrokopter.de is not allowed |
41 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
41 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
42 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
42 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
43 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
44 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
44 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
45 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
45 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
46 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
46 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
47 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
47 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
48 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
48 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
49 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
49 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
50 | // + POSSIBILITY OF SUCH DAMAGE. |
50 | // + POSSIBILITY OF SUCH DAMAGE. |
51 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
51 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
52 | 52 | ||
53 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
53 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
54 | // + Contant Values |
54 | // + Contant Values |
55 | // + 0-250 -> normale Values |
55 | // + 0-250 -> normale Values |
56 | // + 251 -> Poti1 |
56 | // + 251 -> Poti1 |
57 | // + 252 -> Poti2 |
57 | // + 252 -> Poti2 |
58 | // + 253 -> Poti3 |
58 | // + 253 -> Poti3 |
59 | // + 254 -> Poti4 |
59 | // + 254 -> Poti4 |
60 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
60 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
61 | 61 | ||
62 | #ifndef EEMEM |
62 | #ifndef EEMEM |
63 | #define EEMEM __attribute__ ((section (".eeprom"))) |
63 | #define EEMEM __attribute__ ((section (".eeprom"))) |
64 | #endif |
64 | #endif |
65 | 65 | ||
66 | 66 | ||
67 | #include <avr/eeprom.h> |
67 | #include <avr/eeprom.h> |
68 | #include <string.h> |
68 | #include <string.h> |
69 | #include "eeprom.h" |
69 | #include "eeprom.h" |
70 | #include "uart.h" |
70 | #include "uart.h" |
71 | #include "led.h" |
71 | #include "led.h" |
72 | #include "main.h" |
72 | #include "main.h" |
73 | #include "fc.h" |
73 | #include "fc.h" |
74 | #include "twimaster.h" |
74 | #include "twimaster.h" |
75 | 75 | ||
76 | paramset_t EE_Parameter; |
76 | paramset_t EE_Parameter; |
77 | MixerTable_t Mixer; |
77 | MixerTable_t Mixer; |
78 | uint8_t RequiredMotors; |
78 | uint8_t RequiredMotors; |
79 | 79 | ||
80 | 80 | ||
81 | uint8_t RAM_Checksum(uint8_t* pBuffer, uint16_t len) |
81 | uint8_t RAM_Checksum(uint8_t* pBuffer, uint16_t len) |
82 | { |
82 | { |
83 | uint8_t crc = 0xAA; |
83 | uint8_t crc = 0xAA; |
84 | uint16_t i; |
84 | uint16_t i; |
85 | 85 | ||
86 | for(i=0; i<len; i++) |
86 | for(i=0; i<len; i++) |
87 | { |
87 | { |
88 | crc += pBuffer[i]; |
88 | crc += pBuffer[i]; |
89 | } |
89 | } |
90 | return crc; |
90 | return crc; |
91 | } |
91 | } |
92 | 92 | ||
93 | uint8_t EEProm_Checksum(uint16_t EEAddr, uint16_t len) |
93 | uint8_t EEProm_Checksum(uint16_t EEAddr, uint16_t len) |
94 | { |
94 | { |
95 | uint8_t crc = 0xAA; |
95 | uint8_t crc = 0xAA; |
96 | uint16_t off; |
96 | uint16_t off; |
97 | 97 | ||
98 | for(off=0; off<len; off++) |
98 | for(off=0; off<len; off++) |
99 | { |
99 | { |
100 | crc += eeprom_read_byte((uint8_t*)(EEAddr + off));; |
100 | crc += eeprom_read_byte((uint8_t*)(EEAddr + off));; |
101 | } |
101 | } |
102 | return crc; |
102 | return crc; |
103 | } |
103 | } |
104 | 104 | ||
105 | void ParamSet_DefaultStickMapping(void) |
105 | void ParamSet_DefaultStickMapping(void) |
106 | { |
106 | { |
107 | EE_Parameter.Kanalbelegung[K_GAS] = 1; |
107 | EE_Parameter.Kanalbelegung[K_GAS] = 1; |
108 | EE_Parameter.Kanalbelegung[K_ROLL] = 2; |
108 | EE_Parameter.Kanalbelegung[K_ROLL] = 2; |
109 | EE_Parameter.Kanalbelegung[K_NICK] = 3; |
109 | EE_Parameter.Kanalbelegung[K_NICK] = 3; |
110 | EE_Parameter.Kanalbelegung[K_GIER] = 4; |
110 | EE_Parameter.Kanalbelegung[K_GIER] = 4; |
111 | EE_Parameter.Kanalbelegung[K_POTI1] = 5; |
111 | EE_Parameter.Kanalbelegung[K_POTI1] = 5; |
112 | EE_Parameter.Kanalbelegung[K_POTI2] = 6; |
112 | EE_Parameter.Kanalbelegung[K_POTI2] = 6; |
113 | EE_Parameter.Kanalbelegung[K_POTI3] = 7; |
113 | EE_Parameter.Kanalbelegung[K_POTI3] = 7; |
114 | EE_Parameter.Kanalbelegung[K_POTI4] = 8; |
114 | EE_Parameter.Kanalbelegung[K_POTI4] = 8; |
115 | EE_Parameter.Kanalbelegung[K_POTI5] = 9; |
115 | EE_Parameter.Kanalbelegung[K_POTI5] = 9; |
116 | EE_Parameter.Kanalbelegung[K_POTI6] = 10; |
116 | EE_Parameter.Kanalbelegung[K_POTI6] = 10; |
117 | EE_Parameter.Kanalbelegung[K_POTI7] = 11; |
117 | EE_Parameter.Kanalbelegung[K_POTI7] = 11; |
118 | EE_Parameter.Kanalbelegung[K_POTI8] = 12; |
118 | EE_Parameter.Kanalbelegung[K_POTI8] = 12; |
119 | } |
119 | } |
120 | 120 | ||
121 | 121 | ||
122 | /***************************************************/ |
122 | /***************************************************/ |
123 | /* Default Values for parameter set 1 */ |
123 | /* Default Values for parameter set 1 */ |
124 | /***************************************************/ |
124 | /***************************************************/ |
125 | void ParamSet_DefaultSet1(void) // sport |
125 | void ParamSet_DefaultSet1(void) // sport |
126 | { |
126 | { |
127 | EE_Parameter.Revision = EEPARAM_REVISION; |
127 | EE_Parameter.Revision = EEPARAM_REVISION; |
128 | 128 | ||
129 | if(PlatinenVersion >= 20) |
129 | if(PlatinenVersion >= 20) |
130 | { |
130 | { |
131 | EE_Parameter.Gyro_D = 10; |
131 | EE_Parameter.Gyro_D = 10; |
132 | EE_Parameter.Driftkomp = 0; |
132 | EE_Parameter.Driftkomp = 0; |
133 | EE_Parameter.GyroAccFaktor = 27; |
133 | EE_Parameter.GyroAccFaktor = 27; |
134 | EE_Parameter.WinkelUmschlagNick = 78; |
134 | EE_Parameter.WinkelUmschlagNick = 78; |
135 | EE_Parameter.WinkelUmschlagRoll = 78; |
135 | EE_Parameter.WinkelUmschlagRoll = 78; |
136 | } |
136 | } |
137 | else |
137 | else |
138 | { |
138 | { |
139 | EE_Parameter.Gyro_D = 3; |
139 | EE_Parameter.Gyro_D = 3; |
140 | EE_Parameter.Driftkomp = 32; |
140 | EE_Parameter.Driftkomp = 32; |
141 | EE_Parameter.GyroAccFaktor = 30; |
141 | EE_Parameter.GyroAccFaktor = 30; |
142 | EE_Parameter.WinkelUmschlagNick = 85; |
142 | EE_Parameter.WinkelUmschlagNick = 85; |
143 | EE_Parameter.WinkelUmschlagRoll = 85; |
143 | EE_Parameter.WinkelUmschlagRoll = 85; |
144 | } |
144 | } |
145 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
145 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
146 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT | CFG2_VARIO_BEEP;// | CFG_SENSITIVE_RC |
146 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT | CFG2_VARIO_BEEP;// | CFG_SENSITIVE_RC |
147 | EE_Parameter.Hoehe_MinGas = 30; |
147 | EE_Parameter.Hoehe_MinGas = 30; |
148 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
148 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
149 | EE_Parameter.Hoehe_P = 15; // Wert : 0-32 |
149 | EE_Parameter.Hoehe_P = 15; // Wert : 0-32 |
150 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
150 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
151 | EE_Parameter.Hoehe_ACC_Wirkung = 00; // Wert : 0-247 |
151 | EE_Parameter.Hoehe_ACC_Wirkung = 00; // Wert : 0-247 |
152 | EE_Parameter.Hoehe_HoverBand = 8; // Wert : 0-247 |
152 | EE_Parameter.Hoehe_HoverBand = 8; // Wert : 0-247 |
153 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
153 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
154 | EE_Parameter.Hoehe_StickNeutralPoint = 0; // Wert : 0-247 (0 = Hover-Estimation) |
154 | EE_Parameter.Hoehe_StickNeutralPoint = 0; // Wert : 0-247 (0 = Hover-Estimation) |
155 | EE_Parameter.Hoehe_Verstaerkung = 20; // Wert : 0-50 |
155 | EE_Parameter.Hoehe_Verstaerkung = 20; // Wert : 0-50 |
156 | EE_Parameter.Stick_P = 14; // Wert : 1-20 |
156 | EE_Parameter.Stick_P = 14; // Wert : 1-20 |
157 | EE_Parameter.Stick_D = 16; // Wert : 0-20 |
157 | EE_Parameter.Stick_D = 16; // Wert : 0-20 |
158 | EE_Parameter.Gier_P = 12; // Wert : 1-20 |
158 | EE_Parameter.Gier_P = 12; // Wert : 1-20 |
159 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
159 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
160 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
160 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
161 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
161 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
162 | EE_Parameter.Gyro_P = 80; // Wert : 0-247 |
162 | EE_Parameter.Gyro_P = 80; // Wert : 0-247 |
163 | EE_Parameter.Gyro_I = 150; // Wert : 0-247 |
163 | EE_Parameter.Gyro_I = 150; // Wert : 0-247 |
164 | EE_Parameter.Gyro_Gier_P = 80; // Wert : 0-247 |
164 | EE_Parameter.Gyro_Gier_P = 80; // Wert : 0-247 |
165 | EE_Parameter.Gyro_Gier_I = 150; // Wert : 0-247 |
165 | EE_Parameter.Gyro_Gier_I = 150; // Wert : 0-247 |
166 | EE_Parameter.Gyro_Stability = 6; // Wert : 1-8 |
166 | EE_Parameter.Gyro_Stability = 6; // Wert : 1-8 |
167 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
167 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
168 | EE_Parameter.NotGas = 45; // Wert : 0-247 // Gaswert bei Empangsverlust |
168 | EE_Parameter.NotGas = 45; // Wert : 0-247 // Gaswert bei Empangsverlust |
169 | EE_Parameter.NotGasZeit = 90; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
169 | EE_Parameter.NotGasZeit = 90; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
170 | EE_Parameter.I_Faktor = 32; |
170 | EE_Parameter.I_Faktor = 32; |
171 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
171 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
172 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
172 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
173 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
173 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
174 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
174 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
175 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
175 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
176 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
176 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
177 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
177 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
178 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
178 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
179 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
179 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
180 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
180 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
181 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
181 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
182 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
182 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
183 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
183 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
184 | EE_Parameter.ServoNickRefresh = 6; |
184 | EE_Parameter.ServoNickRefresh = 6; |
185 | EE_Parameter.Servo3 = 125; |
185 | EE_Parameter.Servo3 = 125; |
186 | EE_Parameter.Servo4 = 125; |
186 | EE_Parameter.Servo4 = 125; |
187 | EE_Parameter.Servo5 = 125; |
187 | EE_Parameter.Servo5 = 125; |
188 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
188 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
189 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
189 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
190 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
190 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
191 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
191 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
192 | EE_Parameter.LoopGasLimit = 50; |
192 | EE_Parameter.LoopGasLimit = 50; |
193 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
193 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
194 | EE_Parameter.LoopHysterese = 50; |
194 | EE_Parameter.LoopHysterese = 50; |
195 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
195 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
196 | EE_Parameter.AchsKopplung1 = 90; |
196 | EE_Parameter.AchsKopplung1 = 90; |
197 | EE_Parameter.AchsKopplung2 = 80; |
197 | EE_Parameter.AchsKopplung2 = 80; |
198 | EE_Parameter.CouplingYawCorrection = 1; |
198 | EE_Parameter.CouplingYawCorrection = 1; |
199 | EE_Parameter.GyroAccAbgleich = 16; // 1/k; |
199 | EE_Parameter.GyroAccAbgleich = 16; // 1/k; |
200 | EE_Parameter.DynamicStability = 100; |
200 | EE_Parameter.DynamicStability = 100; |
201 | EE_Parameter.J16Bitmask = 95; |
201 | EE_Parameter.J16Bitmask = 95; |
202 | EE_Parameter.J17Bitmask = 243; |
202 | EE_Parameter.J17Bitmask = 243; |
203 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
203 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
204 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
204 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
205 | EE_Parameter.J16Timing = 15; |
205 | EE_Parameter.J16Timing = 15; |
206 | EE_Parameter.J17Timing = 15; |
206 | EE_Parameter.J17Timing = 15; |
207 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
207 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
208 | EE_Parameter.NaviGpsGain = 100; |
208 | EE_Parameter.NaviGpsGain = 100; |
209 | EE_Parameter.NaviGpsP = 90; |
209 | EE_Parameter.NaviGpsP = 90; |
210 | EE_Parameter.NaviGpsI = 90; |
210 | EE_Parameter.NaviGpsI = 90; |
211 | EE_Parameter.NaviGpsD = 90; |
211 | EE_Parameter.NaviGpsD = 90; |
212 | EE_Parameter.NaviGpsPLimit = 75; |
212 | EE_Parameter.NaviGpsPLimit = 75; |
213 | EE_Parameter.NaviGpsILimit = 75; |
213 | EE_Parameter.NaviGpsILimit = 75; |
214 | EE_Parameter.NaviGpsDLimit = 75; |
214 | EE_Parameter.NaviGpsDLimit = 75; |
215 | EE_Parameter.NaviGpsACC = 0; |
215 | EE_Parameter.NaviGpsACC = 0; |
216 | EE_Parameter.NaviGpsMinSat = 6; |
216 | EE_Parameter.NaviGpsMinSat = 6; |
217 | EE_Parameter.NaviStickThreshold = 8; |
217 | EE_Parameter.NaviStickThreshold = 8; |
218 | EE_Parameter.NaviWindCorrection = 90; |
218 | EE_Parameter.NaviWindCorrection = 90; |
219 | EE_Parameter.NaviSpeedCompensation = 30; |
219 | EE_Parameter.NaviSpeedCompensation = 30; |
220 | EE_Parameter.NaviOperatingRadius = 100; |
220 | EE_Parameter.NaviOperatingRadius = 100; |
221 | EE_Parameter.NaviAngleLimitation = 100; |
221 | EE_Parameter.NaviAngleLimitation = 100; |
222 | EE_Parameter.NaviPH_LoginTime = 2; |
222 | EE_Parameter.NaviPH_LoginTime = 2; |
223 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
223 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
224 | EE_Parameter.OrientationAngle = 0; |
224 | EE_Parameter.OrientationAngle = 0; |
225 | EE_Parameter.OrientationModeControl = 0; |
225 | EE_Parameter.OrientationModeControl = 0; |
226 | memcpy(EE_Parameter.Name, "Sport\0", 12); |
226 | memcpy(EE_Parameter.Name, "Sport\0", 12); |
227 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
227 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
228 | } |
228 | } |
229 | 229 | ||
230 | 230 | ||
231 | /***************************************************/ |
231 | /***************************************************/ |
232 | /* Default Values for parameter set 2 */ |
232 | /* Default Values for parameter set 2 */ |
233 | /***************************************************/ |
233 | /***************************************************/ |
234 | void ParamSet_DefaultSet2(void) // normal |
234 | void ParamSet_DefaultSet2(void) // normal |
235 | { |
235 | { |
236 | EE_Parameter.Revision = EEPARAM_REVISION; |
236 | EE_Parameter.Revision = EEPARAM_REVISION; |
237 | 237 | ||
238 | if(PlatinenVersion >= 20) |
238 | if(PlatinenVersion >= 20) |
239 | { |
239 | { |
240 | EE_Parameter.Gyro_D = 10; |
240 | EE_Parameter.Gyro_D = 10; |
241 | EE_Parameter.Driftkomp = 0; |
241 | EE_Parameter.Driftkomp = 0; |
242 | EE_Parameter.GyroAccFaktor = 27; |
242 | EE_Parameter.GyroAccFaktor = 27; |
243 | EE_Parameter.WinkelUmschlagNick = 78; |
243 | EE_Parameter.WinkelUmschlagNick = 78; |
244 | EE_Parameter.WinkelUmschlagRoll = 78; |
244 | EE_Parameter.WinkelUmschlagRoll = 78; |
245 | } |
245 | } |
246 | else |
246 | else |
247 | { |
247 | { |
248 | EE_Parameter.Gyro_D = 3; |
248 | EE_Parameter.Gyro_D = 3; |
249 | EE_Parameter.Driftkomp = 32; |
249 | EE_Parameter.Driftkomp = 32; |
250 | EE_Parameter.GyroAccFaktor = 30; |
250 | EE_Parameter.GyroAccFaktor = 30; |
251 | EE_Parameter.WinkelUmschlagNick = 85; |
251 | EE_Parameter.WinkelUmschlagNick = 85; |
252 | EE_Parameter.WinkelUmschlagRoll = 85; |
252 | EE_Parameter.WinkelUmschlagRoll = 85; |
253 | } |
253 | } |
254 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
254 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
255 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT | CFG2_VARIO_BEEP;// CFG_SENSITIVE_RC |
255 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT | CFG2_VARIO_BEEP;// CFG_SENSITIVE_RC |
256 | EE_Parameter.Hoehe_MinGas = 30; |
256 | EE_Parameter.Hoehe_MinGas = 30; |
257 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
257 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
258 | EE_Parameter.Hoehe_P = 15; // Wert : 0-32 |
258 | EE_Parameter.Hoehe_P = 15; // Wert : 0-32 |
259 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
259 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
260 | EE_Parameter.Hoehe_ACC_Wirkung = 0; // Wert : 0-247 |
260 | EE_Parameter.Hoehe_ACC_Wirkung = 0; // Wert : 0-247 |
261 | EE_Parameter.Hoehe_HoverBand = 8; // Wert : 0-247 |
261 | EE_Parameter.Hoehe_HoverBand = 8; // Wert : 0-247 |
262 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
262 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
263 | EE_Parameter.Hoehe_StickNeutralPoint = 0;// Wert : 0-247 (0 = Hover-Estimation) |
263 | EE_Parameter.Hoehe_StickNeutralPoint = 0;// Wert : 0-247 (0 = Hover-Estimation) |
264 | EE_Parameter.Hoehe_Verstaerkung = 15; // Wert : 0-50 |
264 | EE_Parameter.Hoehe_Verstaerkung = 15; // Wert : 0-50 |
265 | EE_Parameter.Stick_P = 10; // Wert : 1-20 |
265 | EE_Parameter.Stick_P = 10; // Wert : 1-20 |
266 | EE_Parameter.Stick_D = 16; // Wert : 0-20 |
266 | EE_Parameter.Stick_D = 16; // Wert : 0-20 |
267 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
267 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
268 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
268 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
269 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
269 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
270 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
270 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
271 | EE_Parameter.Gyro_P = 90; // Wert : 0-247 |
271 | EE_Parameter.Gyro_P = 90; // Wert : 0-247 |
272 | EE_Parameter.Gyro_I = 120; // Wert : 0-247 |
272 | EE_Parameter.Gyro_I = 120; // Wert : 0-247 |
273 | EE_Parameter.Gyro_Gier_P = 90; // Wert : 0-247 |
273 | EE_Parameter.Gyro_Gier_P = 90; // Wert : 0-247 |
274 | EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247 |
274 | EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247 |
275 | EE_Parameter.Gyro_Stability = 6; // Wert : 1-8 |
275 | EE_Parameter.Gyro_Stability = 6; // Wert : 1-8 |
276 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
276 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
277 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
277 | EE_Parameter.NotGas = 45; // Wert : 0-247 // Gaswert bei Empangsverlust |
278 | EE_Parameter.NotGasZeit = 60; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
278 | EE_Parameter.NotGasZeit = 90; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
279 | EE_Parameter.I_Faktor = 32; |
279 | EE_Parameter.I_Faktor = 32; |
280 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
280 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
281 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
281 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
282 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
282 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
283 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
283 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
284 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
284 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
285 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
285 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
286 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
286 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
287 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
287 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
288 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
288 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
289 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
289 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
290 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
290 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
291 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
291 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
292 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
292 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
293 | EE_Parameter.ServoNickRefresh = 6; |
293 | EE_Parameter.ServoNickRefresh = 6; |
294 | EE_Parameter.Servo3 = 125; |
294 | EE_Parameter.Servo3 = 125; |
295 | EE_Parameter.Servo4 = 125; |
295 | EE_Parameter.Servo4 = 125; |
296 | EE_Parameter.Servo5 = 125; |
296 | EE_Parameter.Servo5 = 125; |
297 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
297 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
298 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
298 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
299 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
299 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
300 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
300 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
301 | EE_Parameter.LoopGasLimit = 50; |
301 | EE_Parameter.LoopGasLimit = 50; |
302 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
302 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
303 | EE_Parameter.LoopHysterese = 50; |
303 | EE_Parameter.LoopHysterese = 50; |
304 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
304 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
305 | EE_Parameter.AchsKopplung1 = 90; |
305 | EE_Parameter.AchsKopplung1 = 90; |
306 | EE_Parameter.AchsKopplung2 = 80; |
306 | EE_Parameter.AchsKopplung2 = 80; |
307 | EE_Parameter.CouplingYawCorrection = 60; |
307 | EE_Parameter.CouplingYawCorrection = 60; |
308 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
308 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
309 | EE_Parameter.DynamicStability = 75; |
309 | EE_Parameter.DynamicStability = 75; |
310 | EE_Parameter.J16Bitmask = 95; |
310 | EE_Parameter.J16Bitmask = 95; |
311 | EE_Parameter.J17Bitmask = 243; |
311 | EE_Parameter.J17Bitmask = 243; |
312 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
312 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
313 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
313 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
314 | EE_Parameter.J16Timing = 20; |
314 | EE_Parameter.J16Timing = 20; |
315 | EE_Parameter.J17Timing = 20; |
315 | EE_Parameter.J17Timing = 20; |
316 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
316 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
317 | EE_Parameter.NaviGpsGain = 100; |
317 | EE_Parameter.NaviGpsGain = 100; |
318 | EE_Parameter.NaviGpsP = 90; |
318 | EE_Parameter.NaviGpsP = 90; |
319 | EE_Parameter.NaviGpsI = 90; |
319 | EE_Parameter.NaviGpsI = 90; |
320 | EE_Parameter.NaviGpsD = 90; |
320 | EE_Parameter.NaviGpsD = 90; |
321 | EE_Parameter.NaviGpsPLimit = 75; |
321 | EE_Parameter.NaviGpsPLimit = 75; |
322 | EE_Parameter.NaviGpsILimit = 75; |
322 | EE_Parameter.NaviGpsILimit = 75; |
323 | EE_Parameter.NaviGpsDLimit = 75; |
323 | EE_Parameter.NaviGpsDLimit = 75; |
324 | EE_Parameter.NaviGpsACC = 0; |
324 | EE_Parameter.NaviGpsACC = 0; |
325 | EE_Parameter.NaviGpsMinSat = 6; |
325 | EE_Parameter.NaviGpsMinSat = 6; |
326 | EE_Parameter.NaviStickThreshold = 8; |
326 | EE_Parameter.NaviStickThreshold = 8; |
327 | EE_Parameter.NaviWindCorrection = 90; |
327 | EE_Parameter.NaviWindCorrection = 90; |
328 | EE_Parameter.NaviSpeedCompensation = 30; |
328 | EE_Parameter.NaviSpeedCompensation = 30; |
329 | EE_Parameter.NaviOperatingRadius = 100; |
329 | EE_Parameter.NaviOperatingRadius = 100; |
330 | EE_Parameter.NaviAngleLimitation = 100; |
330 | EE_Parameter.NaviAngleLimitation = 100; |
331 | EE_Parameter.NaviPH_LoginTime = 2; |
331 | EE_Parameter.NaviPH_LoginTime = 2; |
332 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
332 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
333 | EE_Parameter.OrientationAngle = 0; |
333 | EE_Parameter.OrientationAngle = 0; |
334 | EE_Parameter.OrientationModeControl = 0; |
334 | EE_Parameter.OrientationModeControl = 0; |
335 | memcpy(EE_Parameter.Name, "Normal\0", 12); |
335 | memcpy(EE_Parameter.Name, "Normal\0", 12); |
336 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
336 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
337 | } |
337 | } |
338 | 338 | ||
339 | 339 | ||
340 | /***************************************************/ |
340 | /***************************************************/ |
341 | /* Default Values for parameter set 3 */ |
341 | /* Default Values for parameter set 3 */ |
342 | /***************************************************/ |
342 | /***************************************************/ |
343 | void ParamSet_DefaultSet3(void) // beginner |
343 | void ParamSet_DefaultSet3(void) // beginner |
344 | { |
344 | { |
345 | EE_Parameter.Revision = EEPARAM_REVISION; |
345 | EE_Parameter.Revision = EEPARAM_REVISION; |
346 | if(PlatinenVersion >= 20) |
346 | if(PlatinenVersion >= 20) |
347 | { |
347 | { |
348 | EE_Parameter.Gyro_D = 10; |
348 | EE_Parameter.Gyro_D = 10; |
349 | EE_Parameter.Driftkomp = 0; |
349 | EE_Parameter.Driftkomp = 0; |
350 | EE_Parameter.GyroAccFaktor = 27; |
350 | EE_Parameter.GyroAccFaktor = 27; |
351 | EE_Parameter.WinkelUmschlagNick = 78; |
351 | EE_Parameter.WinkelUmschlagNick = 78; |
352 | EE_Parameter.WinkelUmschlagRoll = 78; |
352 | EE_Parameter.WinkelUmschlagRoll = 78; |
353 | } |
353 | } |
354 | else |
354 | else |
355 | { |
355 | { |
356 | EE_Parameter.Gyro_D = 3; |
356 | EE_Parameter.Gyro_D = 3; |
357 | EE_Parameter.Driftkomp = 32; |
357 | EE_Parameter.Driftkomp = 32; |
358 | EE_Parameter.GyroAccFaktor = 30; |
358 | EE_Parameter.GyroAccFaktor = 30; |
359 | EE_Parameter.WinkelUmschlagNick = 85; |
359 | EE_Parameter.WinkelUmschlagNick = 85; |
360 | EE_Parameter.WinkelUmschlagRoll = 85; |
360 | EE_Parameter.WinkelUmschlagRoll = 85; |
361 | } |
361 | } |
362 | EE_Parameter.GlobalConfig = /*CFG_DREHRATEN_BEGRENZER |*/ CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
362 | EE_Parameter.GlobalConfig = /*CFG_DREHRATEN_BEGRENZER |*/ CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER; |
363 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT | CFG2_VARIO_BEEP;// | CFG_SENSITIVE_RC |
363 | EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT | CFG2_VARIO_BEEP;// | CFG_SENSITIVE_RC |
364 | EE_Parameter.Hoehe_MinGas = 30; |
364 | EE_Parameter.Hoehe_MinGas = 30; |
365 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
365 | EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1 |
366 | EE_Parameter.Hoehe_P = 15; // Wert : 0-32 |
366 | EE_Parameter.Hoehe_P = 15; // Wert : 0-32 |
367 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
367 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-247 |
368 | EE_Parameter.Hoehe_ACC_Wirkung = 0; // Wert : 0-247 |
368 | EE_Parameter.Hoehe_ACC_Wirkung = 0; // Wert : 0-247 |
369 | EE_Parameter.Hoehe_HoverBand = 8; // Wert : 0-247 |
369 | EE_Parameter.Hoehe_HoverBand = 8; // Wert : 0-247 |
370 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
370 | EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247 |
371 | EE_Parameter.Hoehe_StickNeutralPoint = 0;// Wert : 0-247 (0 = Hover-Estimation) |
371 | EE_Parameter.Hoehe_StickNeutralPoint = 0;// Wert : 0-247 (0 = Hover-Estimation) |
372 | EE_Parameter.Hoehe_Verstaerkung = 15; // Wert : 0-50 |
372 | EE_Parameter.Hoehe_Verstaerkung = 15; // Wert : 0-50 |
373 | EE_Parameter.Stick_P = 8; // Wert : 1-20 |
373 | EE_Parameter.Stick_P = 8; // Wert : 1-20 |
374 | EE_Parameter.Stick_D = 16; // Wert : 0-20 |
374 | EE_Parameter.Stick_D = 16; // Wert : 0-20 |
375 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
375 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
376 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
376 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
377 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
377 | EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
378 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
378 | EE_Parameter.KompassWirkung = 128; // Wert : 0-247 |
379 | EE_Parameter.Gyro_P = 100; // Wert : 0-247 |
379 | EE_Parameter.Gyro_P = 100; // Wert : 0-247 |
380 | EE_Parameter.Gyro_I = 120; // Wert : 0-247 |
380 | EE_Parameter.Gyro_I = 120; // Wert : 0-247 |
381 | EE_Parameter.Gyro_Gier_P = 100; // Wert : 0-247 |
381 | EE_Parameter.Gyro_Gier_P = 100; // Wert : 0-247 |
382 | EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247 |
382 | EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247 |
383 | EE_Parameter.Gyro_Stability = 6; // Wert : 1-8 |
383 | EE_Parameter.Gyro_Stability = 6; // Wert : 1-8 |
384 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
384 | EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50) |
385 | EE_Parameter.NotGas = 35; // Wert : 0-247 // Gaswert bei Empangsverlust |
385 | EE_Parameter.NotGas = 45; // Wert : 0-247 // Gaswert bei Empangsverlust |
386 | EE_Parameter.NotGasZeit = 60; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
386 | EE_Parameter.NotGasZeit = 90; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
387 | EE_Parameter.I_Faktor = 16; |
387 | EE_Parameter.I_Faktor = 16; |
388 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
388 | EE_Parameter.UserParam1 = 0; // zur freien Verwendung |
389 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
389 | EE_Parameter.UserParam2 = 0; // zur freien Verwendung |
390 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
390 | EE_Parameter.UserParam3 = 0; // zur freien Verwendung |
391 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
391 | EE_Parameter.UserParam4 = 0; // zur freien Verwendung |
392 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
392 | EE_Parameter.UserParam5 = 0; // zur freien Verwendung |
393 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
393 | EE_Parameter.UserParam6 = 0; // zur freien Verwendung |
394 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
394 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
395 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
395 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
396 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
396 | EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos |
397 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
397 | EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
398 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
398 | EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo |
399 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
399 | EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag |
400 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
400 | EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag |
401 | EE_Parameter.ServoNickRefresh = 6; |
401 | EE_Parameter.ServoNickRefresh = 6; |
402 | EE_Parameter.Servo3 = 125; |
402 | EE_Parameter.Servo3 = 125; |
403 | EE_Parameter.Servo4 = 125; |
403 | EE_Parameter.Servo4 = 125; |
404 | EE_Parameter.Servo5 = 125; |
404 | EE_Parameter.Servo5 = 125; |
405 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
405 | EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos |
406 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
406 | EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo |
407 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
407 | EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag |
408 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
408 | EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag |
409 | EE_Parameter.LoopGasLimit = 50; |
409 | EE_Parameter.LoopGasLimit = 50; |
410 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
410 | EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag |
411 | EE_Parameter.LoopHysterese = 50; |
411 | EE_Parameter.LoopHysterese = 50; |
412 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
412 | EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
413 | EE_Parameter.AchsKopplung1 = 90; |
413 | EE_Parameter.AchsKopplung1 = 90; |
414 | EE_Parameter.AchsKopplung2 = 80; |
414 | EE_Parameter.AchsKopplung2 = 80; |
415 | EE_Parameter.CouplingYawCorrection = 70; |
415 | EE_Parameter.CouplingYawCorrection = 70; |
416 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
416 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
417 | EE_Parameter.DynamicStability = 70; |
417 | EE_Parameter.DynamicStability = 70; |
418 | EE_Parameter.J16Bitmask = 95; |
418 | EE_Parameter.J16Bitmask = 95; |
419 | EE_Parameter.J17Bitmask = 243; |
419 | EE_Parameter.J17Bitmask = 243; |
420 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
420 | EE_Parameter.WARN_J16_Bitmask = 0xAA; |
421 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
421 | EE_Parameter.WARN_J17_Bitmask = 0xAA; |
422 | EE_Parameter.J16Timing = 30; |
422 | EE_Parameter.J16Timing = 30; |
423 | EE_Parameter.J17Timing = 30; |
423 | EE_Parameter.J17Timing = 30; |
424 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
424 | EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2 |
425 | EE_Parameter.NaviGpsGain = 100; |
425 | EE_Parameter.NaviGpsGain = 100; |
426 | EE_Parameter.NaviGpsP = 90; |
426 | EE_Parameter.NaviGpsP = 90; |
427 | EE_Parameter.NaviGpsI = 90; |
427 | EE_Parameter.NaviGpsI = 90; |
428 | EE_Parameter.NaviGpsD = 90; |
428 | EE_Parameter.NaviGpsD = 90; |
429 | EE_Parameter.NaviGpsPLimit = 75; |
429 | EE_Parameter.NaviGpsPLimit = 75; |
430 | EE_Parameter.NaviGpsILimit = 75; |
430 | EE_Parameter.NaviGpsILimit = 75; |
431 | EE_Parameter.NaviGpsDLimit = 75; |
431 | EE_Parameter.NaviGpsDLimit = 75; |
432 | EE_Parameter.NaviGpsACC = 0; |
432 | EE_Parameter.NaviGpsACC = 0; |
433 | EE_Parameter.NaviGpsMinSat = 6; |
433 | EE_Parameter.NaviGpsMinSat = 6; |
434 | EE_Parameter.NaviStickThreshold = 8; |
434 | EE_Parameter.NaviStickThreshold = 8; |
435 | EE_Parameter.NaviWindCorrection = 90; |
435 | EE_Parameter.NaviWindCorrection = 90; |
436 | EE_Parameter.NaviSpeedCompensation = 30; |
436 | EE_Parameter.NaviSpeedCompensation = 30; |
437 | EE_Parameter.NaviOperatingRadius = 100; |
437 | EE_Parameter.NaviOperatingRadius = 100; |
438 | EE_Parameter.NaviAngleLimitation = 100; |
438 | EE_Parameter.NaviAngleLimitation = 100; |
439 | EE_Parameter.NaviPH_LoginTime = 2; |
439 | EE_Parameter.NaviPH_LoginTime = 2; |
440 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
440 | EE_Parameter.Receiver = RECEIVER_SPEKTRUM; |
441 | EE_Parameter.OrientationAngle = 0; |
441 | EE_Parameter.OrientationAngle = 0; |
442 | EE_Parameter.OrientationModeControl = 0; |
442 | EE_Parameter.OrientationModeControl = 0; |
443 | memcpy(EE_Parameter.Name, "Beginner\0", 12); |
443 | memcpy(EE_Parameter.Name, "Beginner\0", 12); |
444 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
444 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
445 | } |
445 | } |
446 | 446 | ||
447 | /***************************************************/ |
447 | /***************************************************/ |
448 | /* Read Parameter from EEPROM as byte */ |
448 | /* Read Parameter from EEPROM as byte */ |
449 | /***************************************************/ |
449 | /***************************************************/ |
450 | uint8_t GetParamByte(uint16_t param_id) |
450 | uint8_t GetParamByte(uint16_t param_id) |
451 | { |
451 | { |
452 | return eeprom_read_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + param_id)); |
452 | return eeprom_read_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + param_id)); |
453 | } |
453 | } |
454 | 454 | ||
455 | /***************************************************/ |
455 | /***************************************************/ |
456 | /* Write Parameter to EEPROM as byte */ |
456 | /* Write Parameter to EEPROM as byte */ |
457 | /***************************************************/ |
457 | /***************************************************/ |
458 | void SetParamByte(uint16_t param_id, uint8_t value) |
458 | void SetParamByte(uint16_t param_id, uint8_t value) |
459 | { |
459 | { |
460 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + param_id), value); |
460 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + param_id), value); |
461 | } |
461 | } |
462 | 462 | ||
463 | /***************************************************/ |
463 | /***************************************************/ |
464 | /* Read Parameter from EEPROM as word */ |
464 | /* Read Parameter from EEPROM as word */ |
465 | /***************************************************/ |
465 | /***************************************************/ |
466 | uint16_t GetParamWord(uint16_t param_id) |
466 | uint16_t GetParamWord(uint16_t param_id) |
467 | { |
467 | { |
468 | return eeprom_read_word((uint16_t *)(EEPROM_ADR_PARAM_BEGIN + param_id)); |
468 | return eeprom_read_word((uint16_t *)(EEPROM_ADR_PARAM_BEGIN + param_id)); |
469 | } |
469 | } |
470 | 470 | ||
471 | /***************************************************/ |
471 | /***************************************************/ |
472 | /* Write Parameter to EEPROM as word */ |
472 | /* Write Parameter to EEPROM as word */ |
473 | /***************************************************/ |
473 | /***************************************************/ |
474 | void SetParamWord(uint16_t param_id, uint16_t value) |
474 | void SetParamWord(uint16_t param_id, uint16_t value) |
475 | { |
475 | { |
476 | eeprom_write_word((uint16_t*)(EEPROM_ADR_PARAM_BEGIN + param_id), value); |
476 | eeprom_write_word((uint16_t*)(EEPROM_ADR_PARAM_BEGIN + param_id), value); |
477 | } |
477 | } |
478 | 478 | ||
479 | /***************************************************/ |
479 | /***************************************************/ |
480 | /* Read Parameter Set from EEPROM */ |
480 | /* Read Parameter Set from EEPROM */ |
481 | /***************************************************/ |
481 | /***************************************************/ |
482 | // number [1..5] |
482 | // number [1..5] |
483 | uint8_t ParamSet_ReadFromEEProm(uint8_t setnumber) |
483 | uint8_t ParamSet_ReadFromEEProm(uint8_t setnumber) |
484 | { |
484 | { |
485 | uint8_t crc; |
485 | uint8_t crc; |
486 | uint16_t eeaddr; |
486 | uint16_t eeaddr; |
487 | 487 | ||
488 | // range the setnumber |
488 | // range the setnumber |
489 | if((1 > setnumber) || (setnumber > 5)) setnumber = 3; |
489 | if((1 > setnumber) || (setnumber > 5)) setnumber = 3; |
490 | 490 | ||
491 | // calculate eeprom addr |
491 | // calculate eeprom addr |
492 | eeaddr = EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1); |
492 | eeaddr = EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1); |
493 | 493 | ||
494 | // calculate checksum from eeprom |
494 | // calculate checksum from eeprom |
495 | crc = EEProm_Checksum(eeaddr, PARAMSET_STRUCT_LEN - 1); |
495 | crc = EEProm_Checksum(eeaddr, PARAMSET_STRUCT_LEN - 1); |
496 | 496 | ||
497 | // check crc |
497 | // check crc |
498 | if(crc != eeprom_read_byte((uint8_t*)(eeaddr + PARAMSET_STRUCT_LEN - 1))) return 0; |
498 | if(crc != eeprom_read_byte((uint8_t*)(eeaddr + PARAMSET_STRUCT_LEN - 1))) return 0; |
499 | 499 | ||
500 | // check revision |
500 | // check revision |
501 | if(eeprom_read_byte((uint8_t*)(eeaddr)) != EEPARAM_REVISION) return 0; |
501 | if(eeprom_read_byte((uint8_t*)(eeaddr)) != EEPARAM_REVISION) return 0; |
502 | 502 | ||
503 | // read paramset from eeprom |
503 | // read paramset from eeprom |
504 | eeprom_read_block((void *) &EE_Parameter, (void*)(EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1)), PARAMSET_STRUCT_LEN); |
504 | eeprom_read_block((void *) &EE_Parameter, (void*)(EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1)), PARAMSET_STRUCT_LEN); |
505 | LED_Init(); |
505 | LED_Init(); |
506 | return 1; |
506 | return 1; |
507 | } |
507 | } |
508 | 508 | ||
509 | /***************************************************/ |
509 | /***************************************************/ |
510 | /* Write Parameter Set to EEPROM */ |
510 | /* Write Parameter Set to EEPROM */ |
511 | /***************************************************/ |
511 | /***************************************************/ |
512 | // number [1..5] |
512 | // number [1..5] |
513 | uint8_t ParamSet_WriteToEEProm(uint8_t setnumber) |
513 | uint8_t ParamSet_WriteToEEProm(uint8_t setnumber) |
514 | { |
514 | { |
515 | uint8_t crc; |
515 | uint8_t crc; |
516 | 516 | ||
517 | if(EE_Parameter.Revision == EEPARAM_REVISION) // write only the right revision to eeprom |
517 | if(EE_Parameter.Revision == EEPARAM_REVISION) // write only the right revision to eeprom |
518 | { |
518 | { |
519 | if(setnumber > 5) setnumber = 5; |
519 | if(setnumber > 5) setnumber = 5; |
520 | if(setnumber < 1) return 0; |
520 | if(setnumber < 1) return 0; |
521 | 521 | ||
522 | // update checksum |
522 | // update checksum |
523 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
523 | EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1); |
524 | 524 | ||
525 | // write paramset to eeprom |
525 | // write paramset to eeprom |
526 | eeprom_write_block((void *) &EE_Parameter, (void*)(EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1)), PARAMSET_STRUCT_LEN); |
526 | eeprom_write_block((void *) &EE_Parameter, (void*)(EEPROM_ADR_PARAMSET + PARAMSET_STRUCT_LEN * (setnumber - 1)), PARAMSET_STRUCT_LEN); |
527 | 527 | ||
528 | // backup channel settings to separate block in eeprom |
528 | // backup channel settings to separate block in eeprom |
529 | eeprom_write_block( (void*)(EE_Parameter.Kanalbelegung), (void*)(EEPROM_ADR_CHANNELS), sizeof(EE_Parameter.Kanalbelegung)); |
529 | eeprom_write_block( (void*)(EE_Parameter.Kanalbelegung), (void*)(EEPROM_ADR_CHANNELS), sizeof(EE_Parameter.Kanalbelegung)); |
530 | 530 | ||
531 | // write crc of channel block to eeprom |
531 | // write crc of channel block to eeprom |
532 | crc = RAM_Checksum((uint8_t*)(EE_Parameter.Kanalbelegung), sizeof(EE_Parameter.Kanalbelegung)); |
532 | crc = RAM_Checksum((uint8_t*)(EE_Parameter.Kanalbelegung), sizeof(EE_Parameter.Kanalbelegung)); |
533 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_CHANNELS + sizeof(EE_Parameter.Kanalbelegung)), crc); |
533 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_CHANNELS + sizeof(EE_Parameter.Kanalbelegung)), crc); |
534 | 534 | ||
535 | // update active settings number |
535 | // update active settings number |
536 | SetActiveParamSet(setnumber); |
536 | SetActiveParamSet(setnumber); |
537 | LED_Init(); |
537 | LED_Init(); |
538 | return 1; |
538 | return 1; |
539 | } |
539 | } |
540 | // wrong revision |
540 | // wrong revision |
541 | return 0; |
541 | return 0; |
542 | } |
542 | } |
543 | 543 | ||
544 | /***************************************************/ |
544 | /***************************************************/ |
545 | /* Read MixerTable from EEPROM */ |
545 | /* Read MixerTable from EEPROM */ |
546 | /***************************************************/ |
546 | /***************************************************/ |
547 | uint8_t MixerTable_ReadFromEEProm(void) |
547 | uint8_t MixerTable_ReadFromEEProm(void) |
548 | { |
548 | { |
549 | uint8_t crc; |
549 | uint8_t crc; |
550 | 550 | ||
551 | // calculate checksum in eeprom |
551 | // calculate checksum in eeprom |
552 | crc = EEProm_Checksum(EEPROM_ADR_MIXERTABLE, sizeof(Mixer) - 1); |
552 | crc = EEProm_Checksum(EEPROM_ADR_MIXERTABLE, sizeof(Mixer) - 1); |
553 | 553 | ||
554 | // check crc |
554 | // check crc |
555 | if( crc != eeprom_read_byte((uint8_t*)(EEPROM_ADR_MIXERTABLE + sizeof(Mixer) - 1)) ) return 0; |
555 | if( crc != eeprom_read_byte((uint8_t*)(EEPROM_ADR_MIXERTABLE + sizeof(Mixer) - 1)) ) return 0; |
556 | 556 | ||
557 | // check revision |
557 | // check revision |
558 | if(eeprom_read_byte((uint8_t*)(EEPROM_ADR_MIXERTABLE)) != EEMIXER_REVISION) return 0; |
558 | if(eeprom_read_byte((uint8_t*)(EEPROM_ADR_MIXERTABLE)) != EEMIXER_REVISION) return 0; |
559 | 559 | ||
560 | // read mixer table |
560 | // read mixer table |
561 | eeprom_read_block((void *) &Mixer, (void*)(EEPROM_ADR_MIXERTABLE), sizeof(Mixer)); |
561 | eeprom_read_block((void *) &Mixer, (void*)(EEPROM_ADR_MIXERTABLE), sizeof(Mixer)); |
562 | return 1; |
562 | return 1; |
563 | } |
563 | } |
564 | 564 | ||
565 | /***************************************************/ |
565 | /***************************************************/ |
566 | /* Write Mixer Table to EEPROM */ |
566 | /* Write Mixer Table to EEPROM */ |
567 | /***************************************************/ |
567 | /***************************************************/ |
568 | uint8_t MixerTable_WriteToEEProm(void) |
568 | uint8_t MixerTable_WriteToEEProm(void) |
569 | { |
569 | { |
570 | if(Mixer.Revision == EEMIXER_REVISION) |
570 | if(Mixer.Revision == EEMIXER_REVISION) |
571 | { |
571 | { |
572 | // update crc |
572 | // update crc |
573 | Mixer.crc = RAM_Checksum((uint8_t*)(&Mixer), sizeof(Mixer) - 1); |
573 | Mixer.crc = RAM_Checksum((uint8_t*)(&Mixer), sizeof(Mixer) - 1); |
574 | 574 | ||
575 | // write to eeprom |
575 | // write to eeprom |
576 | eeprom_write_block((void *) &Mixer, (void*)(EEPROM_ADR_MIXERTABLE), sizeof(Mixer)); |
576 | eeprom_write_block((void *) &Mixer, (void*)(EEPROM_ADR_MIXERTABLE), sizeof(Mixer)); |
577 | return 1; |
577 | return 1; |
578 | } |
578 | } |
579 | else return 0; |
579 | else return 0; |
580 | } |
580 | } |
581 | 581 | ||
582 | /***************************************************/ |
582 | /***************************************************/ |
583 | /* Default Values for Mixer Table */ |
583 | /* Default Values for Mixer Table */ |
584 | /***************************************************/ |
584 | /***************************************************/ |
585 | void MixerTable_Default(void) // Quadro |
585 | void MixerTable_Default(void) // Quadro |
586 | { |
586 | { |
587 | uint8_t i; |
587 | uint8_t i; |
588 | 588 | ||
589 | Mixer.Revision = EEMIXER_REVISION; |
589 | Mixer.Revision = EEMIXER_REVISION; |
590 | // clear mixer table |
590 | // clear mixer table |
591 | for(i = 0; i < 16; i++) |
591 | for(i = 0; i < 16; i++) |
592 | { |
592 | { |
593 | Mixer.Motor[i][MIX_GAS] = 0; |
593 | Mixer.Motor[i][MIX_GAS] = 0; |
594 | Mixer.Motor[i][MIX_NICK] = 0; |
594 | Mixer.Motor[i][MIX_NICK] = 0; |
595 | Mixer.Motor[i][MIX_ROLL] = 0; |
595 | Mixer.Motor[i][MIX_ROLL] = 0; |
596 | Mixer.Motor[i][MIX_YAW] = 0; |
596 | Mixer.Motor[i][MIX_YAW] = 0; |
597 | } |
597 | } |
598 | // default = Quadro |
598 | // default = Quadro |
599 | Mixer.Motor[0][MIX_GAS] = 64; Mixer.Motor[0][MIX_NICK] = +64; Mixer.Motor[0][MIX_ROLL] = 0; Mixer.Motor[0][MIX_YAW] = +64; |
599 | Mixer.Motor[0][MIX_GAS] = 64; Mixer.Motor[0][MIX_NICK] = +64; Mixer.Motor[0][MIX_ROLL] = 0; Mixer.Motor[0][MIX_YAW] = +64; |
600 | Mixer.Motor[1][MIX_GAS] = 64; Mixer.Motor[1][MIX_NICK] = -64; Mixer.Motor[1][MIX_ROLL] = 0; Mixer.Motor[1][MIX_YAW] = +64; |
600 | Mixer.Motor[1][MIX_GAS] = 64; Mixer.Motor[1][MIX_NICK] = -64; Mixer.Motor[1][MIX_ROLL] = 0; Mixer.Motor[1][MIX_YAW] = +64; |
601 | Mixer.Motor[2][MIX_GAS] = 64; Mixer.Motor[2][MIX_NICK] = 0; Mixer.Motor[2][MIX_ROLL] = -64; Mixer.Motor[2][MIX_YAW] = -64; |
601 | Mixer.Motor[2][MIX_GAS] = 64; Mixer.Motor[2][MIX_NICK] = 0; Mixer.Motor[2][MIX_ROLL] = -64; Mixer.Motor[2][MIX_YAW] = -64; |
602 | Mixer.Motor[3][MIX_GAS] = 64; Mixer.Motor[3][MIX_NICK] = 0; Mixer.Motor[3][MIX_ROLL] = +64; Mixer.Motor[3][MIX_YAW] = -64; |
602 | Mixer.Motor[3][MIX_GAS] = 64; Mixer.Motor[3][MIX_NICK] = 0; Mixer.Motor[3][MIX_ROLL] = +64; Mixer.Motor[3][MIX_YAW] = -64; |
603 | memcpy(Mixer.Name, "Quadro\0", 7); |
603 | memcpy(Mixer.Name, "Quadro\0", 7); |
604 | Mixer.crc = Mixer.crc = RAM_Checksum((uint8_t*)(&Mixer), sizeof(Mixer) - 1); |
604 | Mixer.crc = Mixer.crc = RAM_Checksum((uint8_t*)(&Mixer), sizeof(Mixer) - 1); |
605 | } |
605 | } |
606 | 606 | ||
607 | /***************************************************/ |
607 | /***************************************************/ |
608 | /* Get active parameter set */ |
608 | /* Get active parameter set */ |
609 | /***************************************************/ |
609 | /***************************************************/ |
610 | uint8_t GetActiveParamSet(void) |
610 | uint8_t GetActiveParamSet(void) |
611 | { |
611 | { |
612 | uint8_t setnumber; |
612 | uint8_t setnumber; |
613 | setnumber = eeprom_read_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + PID_ACTIVE_SET)); |
613 | setnumber = eeprom_read_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + PID_ACTIVE_SET)); |
614 | if(setnumber > 5) |
614 | if(setnumber > 5) |
615 | { |
615 | { |
616 | setnumber = 3; |
616 | setnumber = 3; |
617 | eeprom_write_byte((void*)(EEPROM_ADR_PARAM_BEGIN+PID_ACTIVE_SET), setnumber); |
617 | eeprom_write_byte((void*)(EEPROM_ADR_PARAM_BEGIN+PID_ACTIVE_SET), setnumber); |
618 | } |
618 | } |
619 | return(setnumber); |
619 | return(setnumber); |
620 | } |
620 | } |
621 | 621 | ||
622 | /***************************************************/ |
622 | /***************************************************/ |
623 | /* Set active parameter set */ |
623 | /* Set active parameter set */ |
624 | /***************************************************/ |
624 | /***************************************************/ |
625 | void SetActiveParamSet(uint8_t setnumber) |
625 | void SetActiveParamSet(uint8_t setnumber) |
626 | { |
626 | { |
627 | if(setnumber > 5) setnumber = 5; |
627 | if(setnumber > 5) setnumber = 5; |
628 | if(setnumber < 1) setnumber = 1; |
628 | if(setnumber < 1) setnumber = 1; |
629 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + PID_ACTIVE_SET), setnumber); |
629 | eeprom_write_byte((uint8_t*)(EEPROM_ADR_PARAM_BEGIN + PID_ACTIVE_SET), setnumber); |
630 | } |
630 | } |
631 | 631 | ||
632 | /***************************************************/ |
632 | /***************************************************/ |
633 | /* Initialize EEPROM Parameter Sets */ |
633 | /* Initialize EEPROM Parameter Sets */ |
634 | /***************************************************/ |
634 | /***************************************************/ |
635 | void ParamSet_Init(void) |
635 | void ParamSet_Init(void) |
636 | { |
636 | { |
637 | uint8_t channel_backup = 0, bad_params = 0, ee_default = 0,i; |
637 | uint8_t channel_backup = 0, bad_params = 0, ee_default = 0,i; |
638 | 638 | ||
639 | 639 | ||
640 | if(EEPARAM_REVISION != GetParamByte(PID_EE_REVISION) ) |
640 | if(EEPARAM_REVISION != GetParamByte(PID_EE_REVISION) ) |
641 | { |
641 | { |
642 | ee_default = 1; // software update or forced by mktool |
642 | ee_default = 1; // software update or forced by mktool |
643 | SetParamByte(PID_EE_REVISION, EEPARAM_REVISION); |
643 | SetParamByte(PID_EE_REVISION, EEPARAM_REVISION); |
644 | } |
644 | } |
645 | 645 | ||
646 | 646 | ||
647 | // 1st check for a valid channel backup in eeprom |
647 | // 1st check for a valid channel backup in eeprom |
648 | i = EEProm_Checksum(EEPROM_ADR_CHANNELS, sizeof(EE_Parameter.Kanalbelegung)); |
648 | i = EEProm_Checksum(EEPROM_ADR_CHANNELS, sizeof(EE_Parameter.Kanalbelegung)); |
649 | if(i == eeprom_read_byte((uint8_t*)(EEPROM_ADR_CHANNELS + sizeof(EE_Parameter.Kanalbelegung))) ) channel_backup = 1; |
649 | if(i == eeprom_read_byte((uint8_t*)(EEPROM_ADR_CHANNELS + sizeof(EE_Parameter.Kanalbelegung))) ) channel_backup = 1; |
650 | 650 | ||
651 | 651 | ||
652 | // parameter check |
652 | // parameter check |
653 | 653 | ||
654 | // check all 5 parameter settings |
654 | // check all 5 parameter settings |
655 | for (i = 1;i < 6; i++) |
655 | for (i = 1;i < 6; i++) |
656 | { |
656 | { |
657 | if(ee_default || !ParamSet_ReadFromEEProm(i)) // could not read paramset from eeprom |
657 | if(ee_default || !ParamSet_ReadFromEEProm(i)) // could not read paramset from eeprom |
658 | { |
658 | { |
659 | bad_params = 1; |
659 | bad_params = 1; |
660 | printf("\n\rGenerating default Parameter Set %d",i); |
660 | printf("\n\rGenerating default Parameter Set %d",i); |
661 | switch(i) |
661 | switch(i) |
662 | { |
662 | { |
663 | case 1: |
663 | case 1: |
664 | ParamSet_DefaultSet1(); // Fill ParamSet Structure to default parameter set 1 (Sport) |
664 | ParamSet_DefaultSet1(); // Fill ParamSet Structure to default parameter set 1 (Sport) |
665 | break; |
665 | break; |
666 | case 2: |
666 | case 2: |
667 | ParamSet_DefaultSet2(); // Kamera |
667 | ParamSet_DefaultSet2(); // Kamera |
668 | break; |
668 | break; |
669 | case 3: |
669 | case 3: |
670 | ParamSet_DefaultSet3(); // Beginner |
670 | ParamSet_DefaultSet3(); // Beginner |
671 | break; |
671 | break; |
672 | default: |
672 | default: |
673 | ParamSet_DefaultSet3(); // Kamera |
673 | ParamSet_DefaultSet3(); // Kamera |
674 | break; |
674 | break; |
675 | } |
675 | } |
676 | if(channel_backup) // if we have an channel mapping backup in eeprom |
676 | if(channel_backup) // if we have an channel mapping backup in eeprom |
677 | { // restore it from eeprom |
677 | { // restore it from eeprom |
678 | eeprom_read_block((void *)EE_Parameter.Kanalbelegung, (void*)(EEPROM_ADR_CHANNELS), sizeof(EE_Parameter.Kanalbelegung)); |
678 | eeprom_read_block((void *)EE_Parameter.Kanalbelegung, (void*)(EEPROM_ADR_CHANNELS), sizeof(EE_Parameter.Kanalbelegung)); |
679 | } |
679 | } |
680 | else |
680 | else |
681 | { // use default mapping |
681 | { // use default mapping |
682 | ParamSet_DefaultStickMapping(); |
682 | ParamSet_DefaultStickMapping(); |
683 | } |
683 | } |
684 | ParamSet_WriteToEEProm(i); |
684 | ParamSet_WriteToEEProm(i); |
685 | } |
685 | } |
686 | } |
686 | } |
687 | if(bad_params) // at least one of the parameter settings were invalid |
687 | if(bad_params) // at least one of the parameter settings were invalid |
688 | { |
688 | { |
689 | // default-Setting is parameter set 3 |
689 | // default-Setting is parameter set 3 |
690 | SetActiveParamSet(3); |
690 | SetActiveParamSet(3); |
691 | } |
691 | } |
692 | 692 | ||
693 | 693 | ||
694 | // read active parameter set to ParamSet stucture |
694 | // read active parameter set to ParamSet stucture |
695 | i = GetActiveParamSet(); |
695 | i = GetActiveParamSet(); |
696 | ParamSet_ReadFromEEProm(i); |
696 | ParamSet_ReadFromEEProm(i); |
697 | printf("\n\rUsing Parameter Set %d", i); |
697 | printf("\n\rUsing Parameter Set %d", i); |
698 | 698 | ||
699 | // load mixer table |
699 | // load mixer table |
700 | if(ee_default || !MixerTable_ReadFromEEProm() ) |
700 | if(ee_default || !MixerTable_ReadFromEEProm() ) |
701 | { |
701 | { |
702 | printf("\n\rGenerating default Mixer Table"); |
702 | printf("\n\rGenerating default Mixer Table"); |
703 | MixerTable_Default(); // Quadro |
703 | MixerTable_Default(); // Quadro |
704 | MixerTable_WriteToEEProm(); |
704 | MixerTable_WriteToEEProm(); |
705 | } |
705 | } |
706 | // determine motornumber |
706 | // determine motornumber |
707 | RequiredMotors = 0; |
707 | RequiredMotors = 0; |
708 | for(i = 0; i < 16; i++) |
708 | for(i = 0; i < 16; i++) |
709 | { |
709 | { |
710 | if(Mixer.Motor[i][MIX_GAS] > 0) RequiredMotors++; |
710 | if(Mixer.Motor[i][MIX_GAS] > 0) RequiredMotors++; |
711 | } |
711 | } |
712 | 712 | ||
713 | printf("\n\rMixer-Config: '%s' (%u Motors)",Mixer.Name, RequiredMotors); |
713 | printf("\n\rMixer-Config: '%s' (%u Motors)",Mixer.Name, RequiredMotors); |
714 | printf("\n\r=============================="); |
714 | printf("\n\r=============================="); |
715 | } |
715 | } |
716 | 716 |