diff --git a/Makefile b/Makefile
index 0801b7e22..266889dad 100644
--- a/Makefile
+++ b/Makefile
@@ -596,6 +596,7 @@ COMMON_SRC = \
drivers/system.c \
drivers/timer.c \
fc/config.c \
+ fc/controlrate_profile.c \
fc/fc_init.c \
fc/fc_dispatch.c \
fc/fc_hardfaults.c \
diff --git a/src/main/config/config_master.h b/src/main/config/config_master.h
index 77ce577c6..655839a7f 100644
--- a/src/main/config/config_master.h
+++ b/src/main/config/config_master.h
@@ -38,6 +38,7 @@
#include "drivers/serial.h"
#include "fc/config.h"
+#include "fc/controlrate_profile.h"
#include "fc/rc_adjustments.h"
#include "fc/rc_controls.h"
#include "fc/fc_core.h"
diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c
index b7a78c991..71b79f3ff 100755
--- a/src/main/fc/cli.c
+++ b/src/main/fc/cli.c
@@ -944,7 +944,7 @@ static systemConfig_t systemConfigCopy;
#ifdef BEEPER
static beeperDevConfig_t beeperDevConfigCopy;
#endif
-static controlRateConfig_t controlRateProfilesCopy[MAX_CONTROL_RATE_PROFILE_COUNT];
+static controlRateConfig_t controlRateProfilesCopy[CONTROL_RATE_PROFILE_COUNT];
static pidProfile_t pidProfileCopy[MAX_PROFILE_COUNT];
#endif // USE_PARAMETER_GROUPS
diff --git a/src/main/fc/config.c b/src/main/fc/config.c
index 2884b5c3e..8f194d1f4 100755
--- a/src/main/fc/config.c
+++ b/src/main/fc/config.c
@@ -127,8 +127,6 @@ PG_REGISTER_WITH_RESET_FN(statusLedConfig_t, statusLedConfig, PG_STATUS_LED_CONF
master_t masterConfig; // master config struct with data independent from profiles
profile_t *currentProfile;
-controlRateConfig_t *currentControlRateProfile;
-
#ifndef USE_PARAMETER_GROUPS
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
{
@@ -148,7 +146,6 @@ static void resetCompassConfig(compassConfig_t* compassConfig)
compassConfig->interruptTag = IO_TAG_NONE;
#endif
}
-#endif
static void resetControlRateProfile(controlRateConfig_t *controlRateConfig)
{
@@ -165,6 +162,7 @@ static void resetControlRateProfile(controlRateConfig_t *controlRateConfig)
controlRateConfig->rates[axis] = 70;
}
}
+#endif
static void resetPidProfile(pidProfile_t *pidProfile)
{
@@ -768,14 +766,6 @@ uint8_t getCurrentControlRateProfileIndex(void)
return systemConfigMutable()->activeRateProfile;
}
-static void setControlRateProfile(uint8_t controlRateProfileIndex)
-{
- if (controlRateProfileIndex < MAX_CONTROL_RATE_PROFILE_COUNT) {
- systemConfigMutable()->activeRateProfile = controlRateProfileIndex;
- currentControlRateProfile = controlRateProfilesMutable(controlRateProfileIndex);
- }
-}
-
uint16_t getCurrentMinthrottle(void)
{
return motorConfig()->minthrottle;
@@ -993,9 +983,11 @@ void createDefaultConfig(master_t *config)
for (int ii = 0; ii < MAX_PROFILE_COUNT; ++ii) {
resetProfile(&config->profile[ii]);
}
- for (int ii = 0; ii < MAX_CONTROL_RATE_PROFILE_COUNT; ++ii) {
+#ifndef USE_PARAMETER_GROUPS
+ for (int ii = 0; ii < CONTROL_RATE_PROFILE_COUNT; ++ii) {
resetControlRateProfile(&config->controlRateProfile[ii]);
}
+#endif
config->compassConfig.mag_declination = 0;
@@ -1363,15 +1355,6 @@ void changeProfile(uint8_t profileIndex)
beeperConfirmationBeeps(profileIndex + 1);
}
-void changeControlRateProfile(uint8_t profileIndex)
-{
- if (profileIndex >= MAX_RATEPROFILES) {
- profileIndex = MAX_RATEPROFILES - 1;
- }
- setControlRateProfile(profileIndex);
- generateThrottleCurve();
-}
-
void beeperOffSet(uint32_t mask)
{
beeperConfigMutable()->beeper_off_flags |= mask;
diff --git a/src/main/fc/config.h b/src/main/fc/config.h
index 2921d9500..164d06b4b 100644
--- a/src/main/fc/config.h
+++ b/src/main/fc/config.h
@@ -89,8 +89,6 @@ PG_DECLARE(serialPinConfig_t, serialPinConfig);
struct profile_s;
extern struct profile_s *currentProfile;
-struct controlRateConfig_s;
-extern struct controlRateConfig_s *currentControlRateProfile;
void beeperOffSet(uint32_t mask);
void beeperOffSetAll(uint8_t beeperCount);
diff --git a/src/main/fc/controlrate_profile.c b/src/main/fc/controlrate_profile.c
new file mode 100644
index 000000000..c89c9ea8e
--- /dev/null
+++ b/src/main/fc/controlrate_profile.c
@@ -0,0 +1,73 @@
+/*
+ * This file is part of Cleanflight.
+ *
+ * Cleanflight is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Cleanflight is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cleanflight. If not, see .
+ */
+
+#include
+#include
+#include
+
+#include "platform.h"
+
+#include "common/axis.h"
+
+#include "config/config_reset.h"
+#include "config/parameter_group.h"
+#include "config/parameter_group_ids.h"
+
+#include "fc/config.h"
+#include "fc/controlrate_profile.h"
+#include "fc/fc_rc.h"
+
+controlRateConfig_t *currentControlRateProfile;
+
+
+PG_REGISTER_ARRAY_WITH_RESET_FN(controlRateConfig_t, CONTROL_RATE_PROFILE_COUNT, controlRateProfiles, PG_CONTROL_RATE_PROFILES, 0);
+
+void pgResetFn_controlRateProfiles(controlRateConfig_t *controlRateConfig)
+{
+ for (int i = 0; i < CONTROL_RATE_PROFILE_COUNT; i++) {
+ RESET_CONFIG(const controlRateConfig_t, &controlRateConfig[i],
+ .rcRate8 = 100,
+ .rcYawRate8 = 100,
+ .rcExpo8 = 0,
+ .thrMid8 = 50,
+ .thrExpo8 = 0,
+ .dynThrPID = 10,
+ .rcYawExpo8 = 0,
+ .tpa_breakpoint = 1650,
+ .rates[FD_ROLL] = 70,
+ .rates[FD_PITCH] = 70,
+ .rates[FD_YAW] = 70
+ );
+ }
+}
+
+void setControlRateProfile(uint8_t controlRateProfileIndex)
+{
+ if (controlRateProfileIndex < CONTROL_RATE_PROFILE_COUNT) {
+ systemConfigMutable()->activeRateProfile = controlRateProfileIndex;
+ currentControlRateProfile = controlRateProfilesMutable(controlRateProfileIndex);
+ }
+}
+
+void changeControlRateProfile(uint8_t controlRateProfileIndex)
+{
+ if (controlRateProfileIndex >= CONTROL_RATE_PROFILE_COUNT) {
+ controlRateProfileIndex = CONTROL_RATE_PROFILE_COUNT - 1;
+ }
+ setControlRateProfile(controlRateProfileIndex);
+ generateThrottleCurve();
+}
diff --git a/src/main/fc/controlrate_profile.h b/src/main/fc/controlrate_profile.h
new file mode 100644
index 000000000..291190707
--- /dev/null
+++ b/src/main/fc/controlrate_profile.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of Cleanflight.
+ *
+ * Cleanflight is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Cleanflight is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cleanflight. If not, see .
+ */
+
+#pragma once
+
+#include
+
+#include "config/parameter_group.h"
+
+
+typedef struct controlRateConfig_s {
+ uint8_t rcRate8;
+ uint8_t rcYawRate8;
+ uint8_t rcExpo8;
+ uint8_t thrMid8;
+ uint8_t thrExpo8;
+ uint8_t rates[3];
+ uint8_t dynThrPID;
+ uint8_t rcYawExpo8;
+ uint16_t tpa_breakpoint; // Breakpoint where TPA is activated
+} controlRateConfig_t;
+
+#define CONTROL_RATE_PROFILE_COUNT 3
+PG_DECLARE_ARRAY(controlRateConfig_t, CONTROL_RATE_PROFILE_COUNT, controlRateProfiles);
+
+extern controlRateConfig_t *currentControlRateProfile;
+
+void setControlRateProfile(uint8_t controlRateProfileIndex);
+void changeControlRateProfile(uint8_t controlRateProfileIndex);
diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c
index e4ce797d7..70f80353a 100644
--- a/src/main/fc/fc_core.c
+++ b/src/main/fc/fc_core.c
@@ -47,6 +47,7 @@
#include "fc/cli.h"
#include "fc/config.h"
+#include "fc/controlrate_profile.h"
#include "fc/fc_core.h"
#include "fc/fc_rc.h"
#include "fc/rc_adjustments.h"
diff --git a/src/main/fc/rc_controls.h b/src/main/fc/rc_controls.h
index 19d649588..45713ed1b 100644
--- a/src/main/fc/rc_controls.h
+++ b/src/main/fc/rc_controls.h
@@ -151,21 +151,6 @@ typedef struct modeActivationProfile_s {
#define IS_RANGE_USABLE(range) ((range)->startStep < (range)->endStep)
-typedef struct controlRateConfig_s {
- uint8_t rcRate8;
- uint8_t rcYawRate8;
- uint8_t rcExpo8;
- uint8_t thrMid8;
- uint8_t thrExpo8;
- uint8_t rates[3];
- uint8_t dynThrPID;
- uint8_t rcYawExpo8;
- uint16_t tpa_breakpoint; // Breakpoint where TPA is activated
-} controlRateConfig_t;
-
-#define MAX_CONTROL_RATE_PROFILE_COUNT 3
-PG_DECLARE_ARRAY(controlRateConfig_t, MAX_CONTROL_RATE_PROFILE_COUNT, controlRateProfiles);
-
extern int16_t rcCommand[4];
typedef struct rcControlsConfig_s {
diff --git a/src/main/telemetry/smartport.c b/src/main/telemetry/smartport.c
index 7698b4e38..ac7cc70a3 100644
--- a/src/main/telemetry/smartport.c
+++ b/src/main/telemetry/smartport.c
@@ -21,21 +21,31 @@
#include "config/parameter_group.h"
#include "config/parameter_group_ids.h"
-#include "drivers/system.h"
-#include "drivers/sensor.h"
#include "drivers/accgyro.h"
#include "drivers/compass.h"
+#include "drivers/sensor.h"
+#include "drivers/system.h"
#include "fc/config.h"
+#include "fc/controlrate_profile.h"
+#include "fc/fc_msp.h"
#include "fc/rc_controls.h"
#include "fc/runtime_config.h"
-#include "fc/fc_msp.h"
+
+#include "flight/altitudehold.h"
+#include "flight/failsafe.h"
+#include "flight/imu.h"
+#include "flight/mixer.h"
+#include "flight/pid.h"
+#include "flight/navigation.h"
#include "io/beeper.h"
#include "io/motors.h"
#include "io/gps.h"
#include "io/serial.h"
+#include "msp/msp.h"
+
#include "sensors/boardalignment.h"
#include "sensors/sensors.h"
#include "sensors/battery.h"
@@ -44,23 +54,13 @@
#include "sensors/compass.h"
#include "sensors/gyro.h"
-#include "flight/pid.h"
-#include "flight/imu.h"
-#include "flight/mixer.h"
-#include "flight/failsafe.h"
-#include "flight/navigation.h"
-#include "flight/altitudehold.h"
-
#include "rx/rx.h"
#include "rx/msp.h"
#include "telemetry/telemetry.h"
#include "telemetry/smartport.h"
-#include "msp/msp.h"
-
extern profile_t *currentProfile;
-extern controlRateConfig_t *currentControlRateProfile;
enum
{