Rev 885 | Rev 911 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 885 | Rev 886 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | // + 0-250 -> normale Werte |
3 | // + 0-250 -> normale Werte |
4 | // + 251 -> Poti1 |
4 | // + 251 -> Poti1 |
5 | // + 252 -> Poti2 |
5 | // + 252 -> Poti2 |
6 | // + 253 -> Poti3 |
6 | // + 253 -> Poti3 |
7 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
7 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | 8 | ||
- | 9 | #ifndef EEMEM |
|
- | 10 | #define EEMEM __attribute__ ((section (".eeprom"))) |
|
- | 11 | #endif |
|
- | 12 | ||
- | 13 | ||
- | 14 | #include <avr/eeprom.h> |
|
- | 15 | #include <string.h> |
|
- | 16 | #include "eeprom.h" |
|
- | 17 | #include "printf_P.h" |
|
- | 18 | ||
- | 19 | ||
- | 20 | // byte array in eeprom |
|
- | 21 | uint8_t EEPromArray[E2END+1] EEMEM; |
|
- | 22 | ||
- | 23 | paramset_t ParamSet; |
|
- | 24 | ||
- | 25 | ||
- | 26 | ||
- | 27 | /***************************************************/ |
|
- | 28 | /* Default Values for parameter set 1 */ |
|
- | 29 | /***************************************************/ |
|
8 | void DefaultKonstanten1(void) |
30 | void ParamSet_DefaultSet1(void) // sport |
- | 31 | { |
|
- | 32 | ParamSet.ChannelAssignment[CH_PITCH] = 1; |
|
- | 33 | ParamSet.ChannelAssignment[CH_ROLL] = 2; |
|
- | 34 | ParamSet.ChannelAssignment[CH_THRUST] = 3; |
|
- | 35 | ParamSet.ChannelAssignment[CH_YAW] = 4; |
|
- | 36 | ParamSet.ChannelAssignment[CH_POTI1] = 5; |
|
- | 37 | ParamSet.ChannelAssignment[CH_POTI2] = 6; |
|
- | 38 | ParamSet.ChannelAssignment[CH_POTI3] = 7; |
|
- | 39 | ParamSet.ChannelAssignment[CH_POTI4] = 8; |
|
- | 40 | ParamSet.GlobalConfig = CFG_AXIS_COUPLING_ACTIVE | CFG_COMPASS_ACTIVE | CFG_GPS_ACTIVE;//CFG_HEIGHT_CONTROL | CFG_HEIGHT_SWITCH | CFG_COMPASS_FIX;//0x01; |
|
- | 41 | ParamSet.Height_MinThrust = 30; |
|
- | 42 | ParamSet.MaxHeight = 251; // Wert : 0-250 251 -> Poti1 |
|
- | 43 | ParamSet.Height_P = 10; // Wert : 0-32 |
|
- | 44 | ParamSet.Height_D = 30; // Wert : 0-250 |
|
- | 45 | ParamSet.Height_ACC_Effect = 30; // Wert : 0-250 |
|
- | 46 | ParamSet.Height_Gain = 4; // Wert : 0-50 |
|
- | 47 | ParamSet.Stick_P = 15; // Wert : 1-24 |
|
- | 48 | ParamSet.Stick_D = 30; // Wert : 0-250 |
|
- | 49 | ParamSet.Yaw_P = 12; // Wert : 1-20 |
|
- | 50 | ParamSet.Trust_Min = 8; // Wert : 0-32 |
|
- | 51 | ParamSet.Trust_Max = 230; // Wert : 33-250 |
|
- | 52 | ParamSet.GyroAccFactor = 30; // Wert : 1-64 |
|
- | 53 | ParamSet.CompassYawEffect = 128; // Wert : 0-250 |
|
- | 54 | ParamSet.Gyro_P = 80; // Wert : 0-250 |
|
- | 55 | ParamSet.Gyro_I = 150; // Wert : 0-250 |
|
- | 56 | ParamSet.LowVoltageWarning = 94; // Wert : 0-250 |
|
- | 57 | ParamSet.EmergencyThrust = 35; // Wert : 0-250 // Gaswert bei Empangsverlust |
|
- | 58 | ParamSet.EmergencyThrustDuration = 30; // Wert : 0-250 // Zeit bis auf EmergencyThrust geschaltet wird, wg. Rx-Problemen |
|
- | 59 | ParamSet.UfoArrangement = 0; // X oder + Formation |
|
- | 60 | ParamSet.I_Factor = 32; |
|
- | 61 | ParamSet.UserParam1 = 253; //zur freien Verwendung |
|
- | 62 | ParamSet.UserParam2 = 100; //zur freien Verwendung |
|
- | 63 | ParamSet.UserParam3 = 90; //zur freien Verwendung |
|
- | 64 | ParamSet.UserParam4 = 90; //zur freien Verwendung |
|
- | 65 | ParamSet.UserParam5 = 90; // zur freien Verwendung |
|
- | 66 | ParamSet.UserParam6 = 90; // zur freien Verwendung |
|
- | 67 | ParamSet.UserParam7 = 0; // zur freien Verwendung |
|
- | 68 | ParamSet.UserParam8 = 0; // zur freien Verwendung |
|
- | 69 | ParamSet.ServoPitchControl = 100; // Wert : 0-250 // Stellung des Servos |
|
- | 70 | ParamSet.ServoPitchComp = 40; // Wert : 0-250 // Einfluss Gyro/Servo |
|
- | 71 | ParamSet.ServoPitchCompInvert = 0; // Wert : 0-250 // Richtung Einfluss Gyro/Servo |
|
- | 72 | ParamSet.ServoPitchMin = 50; // Wert : 0-250 // Anschlag |
|
- | 73 | ParamSet.ServoPitchMax = 150; // Wert : 0-250 // Anschlag |
|
- | 74 | ParamSet.ServoPitchRefresh = 5; |
|
- | 75 | ParamSet.LoopThrustLimit = 50; |
|
- | 76 | ParamSet.LoopThreshold = 90; // Wert: 0-250 Schwelle für Stickausschlag |
|
- | 77 | ParamSet.LoopHysteresis = 50; |
|
- | 78 | ParamSet.LoopConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
|
- | 79 | ParamSet.Yaw_PosFeedback = 90; |
|
- | 80 | ParamSet.Yaw_NegFeedback = 5; |
|
- | 81 | ParamSet.AngleTurnOverPitch = 100; |
|
- | 82 | ParamSet.AngleTurnOverRoll = 100; |
|
- | 83 | ParamSet.GyroAccTrim = 16; // 1/k |
|
- | 84 | ParamSet.DriftComp = 4; |
|
- | 85 | ParamSet.DynamicStability = 100; |
|
- | 86 | memcpy(ParamSet.Name, "Sport\0",6); |
|
- | 87 | } |
|
- | 88 | ||
- | 89 | ||
- | 90 | /***************************************************/ |
|
- | 91 | /* Default Values for parameter set 2 */ |
|
- | 92 | /***************************************************/ |
|
- | 93 | void ParamSet_DefaultSet2(void) // normal |
|
- | 94 | { |
|
- | 95 | ParamSet.ChannelAssignment[CH_PITCH] = 1; |
|
- | 96 | ParamSet.ChannelAssignment[CH_ROLL] = 2; |
|
- | 97 | ParamSet.ChannelAssignment[CH_THRUST] = 3; |
|
- | 98 | ParamSet.ChannelAssignment[CH_YAW] = 4; |
|
- | 99 | ParamSet.ChannelAssignment[CH_POTI1] = 5; |
|
- | 100 | ParamSet.ChannelAssignment[CH_POTI2] = 6; |
|
- | 101 | ParamSet.ChannelAssignment[CH_POTI3] = 7; |
|
- | 102 | ParamSet.ChannelAssignment[CH_POTI4] = 8; |
|
- | 103 | ParamSet.GlobalConfig = CFG_AXIS_COUPLING_ACTIVE | CFG_COMPASS_ACTIVE | CFG_GPS_ACTIVE;//CFG_HEIGHT_CONTROL | CFG_HEIGHT_SWITCH | CFG_COMPASS_FIX;//0x01; |
|
- | 104 | ParamSet.Height_MinThrust = 30; |
|
- | 105 | ParamSet.MaxHeight = 251; // Wert : 0-250 251 -> Poti1 |
|
- | 106 | ParamSet.Height_P = 10; // Wert : 0-32 |
|
- | 107 | ParamSet.Height_D = 30; // Wert : 0-250 |
|
- | 108 | ParamSet.Height_ACC_Effect = 30; // Wert : 0-250 |
|
- | 109 | ParamSet.Height_Gain = 3; // Wert : 0-50 |
|
- | 110 | ParamSet.Stick_P = 12; // Wert : 1-24 |
|
- | 111 | ParamSet.Stick_D = 16; // Wert : 0-250 |
|
- | 112 | ParamSet.Yaw_P = 6; // Wert : 1-20 |
|
- | 113 | ParamSet.Trust_Min = 8; // Wert : 0-32 |
|
- | 114 | ParamSet.Trust_Max = 230; // Wert : 33-250 |
|
- | 115 | ParamSet.GyroAccFactor = 30; // Wert : 1-64 |
|
- | 116 | ParamSet.CompassYawEffect = 128; // Wert : 0-250 |
|
- | 117 | ParamSet.Gyro_P = 80; // Wert : 0-250 |
|
- | 118 | ParamSet.Gyro_I = 120; // Wert : 0-250 |
|
- | 119 | ParamSet.LowVoltageWarning = 94; // Wert : 0-250 |
|
- | 120 | ParamSet.EmergencyThrust = 35; // Wert : 0-250 // Gaswert bei Empangsverlust |
|
- | 121 | ParamSet.EmergencyThrustDuration = 30; // Wert : 0-250 // Zeit bis auf EmergencyThrust geschaltet wird, wg. Rx-Problemen |
|
- | 122 | ParamSet.UfoArrangement = 0; // X oder + Formation |
|
- | 123 | ParamSet.I_Factor = 32; |
|
- | 124 | ParamSet.UserParam1 = 253; // zur freien Verwendung |
|
- | 125 | ParamSet.UserParam2 = 100; // zur freien Verwendung |
|
- | 126 | ParamSet.UserParam3 = 90; // zur freien Verwendung |
|
- | 127 | ParamSet.UserParam4 = 90; // zur freien Verwendung |
|
- | 128 | ParamSet.UserParam5 = 90; // zur freien Verwendung |
|
- | 129 | ParamSet.UserParam6 = 90; // zur freien Verwendung |
|
- | 130 | ParamSet.UserParam7 = 0; // zur freien Verwendung |
|
- | 131 | ParamSet.UserParam8 = 0; // zur freien Verwendung |
|
- | 132 | ParamSet.ServoPitchControl = 100; // Wert : 0-250 // Stellung des Servos |
|
- | 133 | ParamSet.ServoPitchComp = 40; // Wert : 0-250 // Einfluss Gyro/Servo |
|
- | 134 | ParamSet.ServoPitchCompInvert = 0; // Wert : 0-250 // Richtung Einfluss Gyro/Servo |
|
- | 135 | ParamSet.ServoPitchMin = 50; // Wert : 0-250 // Anschlag |
|
- | 136 | ParamSet.ServoPitchMax = 150; // Wert : 0-250 // Anschlag |
|
- | 137 | ParamSet.ServoPitchRefresh = 5; |
|
- | 138 | ParamSet.LoopThrustLimit = 50; |
|
- | 139 | ParamSet.LoopThreshold = 90; // Wert: 0-250 Schwelle für Stickausschlag |
|
- | 140 | ParamSet.LoopHysteresis = 50; |
|
- | 141 | ParamSet.LoopConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
|
- | 142 | ParamSet.Yaw_PosFeedback = 90; // Faktor, mit dem Yaw die Achsen Roll und Pitch verkoppelt |
|
- | 143 | ParamSet.Yaw_NegFeedback = 5; |
|
- | 144 | ParamSet.AngleTurnOverPitch = 100; |
|
- | 145 | ParamSet.AngleTurnOverRoll = 100; |
|
- | 146 | ParamSet.GyroAccTrim = 32; // 1/k |
|
- | 147 | ParamSet.DriftComp = 4; |
|
- | 148 | ParamSet.DynamicStability = 75; |
|
- | 149 | memcpy(ParamSet.Name, "Normal\0", 7); |
|
- | 150 | } |
|
- | 151 | ||
- | 152 | ||
- | 153 | /***************************************************/ |
|
- | 154 | /* Default Values for parameter set 3 */ |
|
- | 155 | /***************************************************/ |
|
- | 156 | void ParamSet_DefaultSet3(void) // beginner |
|
- | 157 | { |
|
- | 158 | ParamSet.ChannelAssignment[CH_PITCH] = 1; |
|
- | 159 | ParamSet.ChannelAssignment[CH_ROLL] = 2; |
|
- | 160 | ParamSet.ChannelAssignment[CH_THRUST] = 3; |
|
- | 161 | ParamSet.ChannelAssignment[CH_YAW] = 4; |
|
- | 162 | ParamSet.ChannelAssignment[CH_POTI1] = 5; |
|
- | 163 | ParamSet.ChannelAssignment[CH_POTI2] = 6; |
|
- | 164 | ParamSet.ChannelAssignment[CH_POTI3] = 7; |
|
- | 165 | ParamSet.ChannelAssignment[CH_POTI4] = 8; |
|
- | 166 | ParamSet.GlobalConfig = CFG_ROTARY_RATE_LIMITER | CFG_AXIS_COUPLING_ACTIVE | CFG_COMPASS_ACTIVE | CFG_GPS_ACTIVE;//CFG_HEIGHT_CONTROL | CFG_HEIGHT_SWITCH | CFG_COMPASS_FIX;//0x01; |
|
- | 167 | ParamSet.Height_MinThrust = 30; |
|
- | 168 | ParamSet.MaxHeight = 251; // Wert : 0-250 251 -> Poti1 |
|
- | 169 | ParamSet.Height_P = 10; // Wert : 0-32 |
|
- | 170 | ParamSet.Height_D = 30; // Wert : 0-250 |
|
- | 171 | ParamSet.Height_ACC_Effect = 30; // Wert : 0-250 |
|
- | 172 | ParamSet.Height_Gain = 3; // Wert : 0-50 |
|
- | 173 | ParamSet.Stick_P = 8; // Wert : 1-24 |
|
- | 174 | ParamSet.Stick_D = 16; // Wert : 0-250 |
|
- | 175 | ParamSet.Yaw_P = 6; // Wert : 1-20 |
|
- | 176 | ParamSet.Trust_Min = 8; // Wert : 0-32 |
|
- | 177 | ParamSet.Trust_Max = 230; // Wert : 33-250 |
|
- | 178 | ParamSet.GyroAccFactor = 30; // Wert : 1-64 |
|
- | 179 | ParamSet.CompassYawEffect = 128; // Wert : 0-250 |
|
- | 180 | ParamSet.Gyro_P = 100; // Wert : 0-250 |
|
- | 181 | ParamSet.Gyro_I = 120; // Wert : 0-250 |
|
- | 182 | ParamSet.LowVoltageWarning = 94; // Wert : 0-250 |
|
- | 183 | ParamSet.EmergencyThrust = 35; // Wert : 0-250 // Gaswert bei Empangsverlust |
|
- | 184 | ParamSet.EmergencyThrustDuration = 20; // Wert : 0-250 // Zeit bis auf EmergencyThrust geschaltet wird, wg. Rx-Problemen |
|
- | 185 | ParamSet.UfoArrangement = 0; // X oder + Formation |
|
- | 186 | ParamSet.I_Factor = 16; |
|
- | 187 | ParamSet.UserParam1 = 253; // zur freien Verwendung |
|
- | 188 | ParamSet.UserParam2 = 100; // zur freien Verwendung |
|
- | 189 | ParamSet.UserParam3 = 90; // zur freien Verwendung |
|
- | 190 | ParamSet.UserParam4 = 90; // zur freien Verwendung |
|
- | 191 | ParamSet.UserParam5 = 90; // zur freien Verwendung |
|
- | 192 | ParamSet.UserParam6 = 90; // zur freien Verwendung |
|
- | 193 | ParamSet.UserParam7 = 0; // zur freien Verwendung |
|
- | 194 | ParamSet.UserParam8 = 0; // zur freien Verwendung |
|
- | 195 | ParamSet.ServoPitchControl = 100; // Wert : 0-250 // Stellung des Servos |
|
- | 196 | ParamSet.ServoPitchComp = 40; // Wert : 0-250 // Einfluss Gyro/Servo |
|
- | 197 | ParamSet.ServoPitchCompInvert = 0; // Wert : 0-250 // Richtung Einfluss Gyro/Servo |
|
- | 198 | ParamSet.ServoPitchMin = 50; // Wert : 0-250 // Anschlag |
|
- | 199 | ParamSet.ServoPitchMax = 150; // Wert : 0-250 // Anschlag |
|
- | 200 | ParamSet.ServoPitchRefresh = 5; |
|
- | 201 | ParamSet.LoopThrustLimit = 50; |
|
- | 202 | ParamSet.LoopThreshold = 90; // Wert: 0-250 Schwelle für Stickausschlag |
|
- | 203 | ParamSet.LoopHysteresis = 50; |
|
- | 204 | ParamSet.LoopConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
|
- | 205 | ParamSet.Yaw_PosFeedback = 90; // Faktor, mit dem Yaw die Achsen Roll und Pitch verkoppelt |
|
- | 206 | ParamSet.Yaw_NegFeedback = 5; |
|
- | 207 | ParamSet.AngleTurnOverPitch = 100; |
|
- | 208 | ParamSet.AngleTurnOverRoll = 100; |
|
- | 209 | ParamSet.GyroAccTrim = 32; // 1/k |
|
- | 210 | ParamSet.DriftComp = 4; |
|
- | 211 | ParamSet.DynamicStability = 50; |
|
- | 212 | memcpy(ParamSet.Name, "Beginner\0", 9); |
|
- | 213 | } |
|
- | 214 | ||
- | 215 | /***************************************************/ |
|
- | 216 | /* Read Parameter from EEPROM as byte */ |
|
- | 217 | /***************************************************/ |
|
- | 218 | uint8_t GetParamByte(uint8_t param_id) |
|
- | 219 | { |
|
- | 220 | return eeprom_read_byte(&EEPromArray[EEPROM_ADR_PARAM_BEGIN + param_id]); |
|
- | 221 | } |
|
- | 222 | ||
- | 223 | /***************************************************/ |
|
- | 224 | /* Write Parameter to EEPROM as byte */ |
|
- | 225 | /***************************************************/ |
|
- | 226 | void SetParamByte(uint8_t param_id, uint8_t value) |
|
- | 227 | { |
|
- | 228 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_PARAM_BEGIN + param_id], value); |
|
- | 229 | } |
|
- | 230 | ||
- | 231 | /***************************************************/ |
|
- | 232 | /* Read Parameter from EEPROM as word */ |
|
- | 233 | /***************************************************/ |
|
- | 234 | uint16_t GetParamWord(uint8_t param_id) |
|
9 | { |
235 | { |
182 | } |
321 | } |