1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 17:25:20 +03:00

Merge pull request #202 from KiteAnton/rateprofile

Rateprofiles to profiles
This commit is contained in:
borisbstyle 2016-02-20 20:46:17 +01:00
commit 6df1b3ead3
6 changed files with 85 additions and 26 deletions

View file

@ -339,7 +339,8 @@ uint8_t getCurrentProfile(void)
static void setProfile(uint8_t profileIndex)
{
currentProfile = &masterConfig.profile[profileIndex];
currentControlRateProfile = &currentProfile->controlRateProfile;
currentControlRateProfileIndex = currentProfile->activeRateProfile;
currentControlRateProfile = &currentProfile->controlRateProfile[currentControlRateProfileIndex];
}
uint8_t getCurrentControlRateProfile(void)
@ -347,8 +348,15 @@ uint8_t getCurrentControlRateProfile(void)
return currentControlRateProfileIndex;
}
static void setControlRateProfile(uint8_t profileIndex) {
currentControlRateProfileIndex = profileIndex;
masterConfig.profile[getCurrentProfile()].activeRateProfile = profileIndex;
currentControlRateProfile = &masterConfig.profile[getCurrentProfile()].controlRateProfile[profileIndex];
}
controlRateConfig_t *getControlRateConfig(uint8_t profileIndex) {
return &masterConfig.profile[profileIndex].controlRateProfile;
return &masterConfig.profile[profileIndex].controlRateProfile[masterConfig.profile[profileIndex].activeRateProfile];
}
uint16_t getCurrentMinthrottle(void)
@ -479,9 +487,11 @@ static void resetConf(void)
masterConfig.emf_avoidance = 0;
resetPidProfile(&currentProfile->pidProfile);
resetControlRateConfig(&masterConfig.profile[0].controlRateProfile);
uint8_t rI;
for (rI = 0; rI<MAX_RATEPROFILES; rI++) {
resetControlRateConfig(&masterConfig.profile[0].controlRateProfile[rI]);
}
resetRollAndPitchTrims(&masterConfig.accelerometerTrims);
masterConfig.mag_declination = 0;
@ -995,6 +1005,14 @@ void changeProfile(uint8_t profileIndex)
beeperConfirmationBeeps(profileIndex + 1);
}
void changeControlRateProfile(uint8_t profileIndex) {
if (profileIndex > MAX_RATEPROFILES) {
profileIndex = MAX_RATEPROFILES - 1;
}
setControlRateProfile(profileIndex);
activateControlRateConfig();
}
void handleOneshotFeatureChangeOnRestart(void)
{
// Shutdown PWM on all motors prior to soft restart