Merge pull request #827 from mikeller/fix_msp_reset_profile

Moved resetting rateprofile values into 'resetPidProfile' to make them get reset on 'Reset PID' in GUI.
This commit is contained in:
Anton 2016-07-27 00:30:56 +02:00 committed by GitHub
commit 5305b86bec
2 changed files with 29 additions and 24 deletions

View File

@ -180,7 +180,23 @@ static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
accelerometerTrims->values.yaw = 0;
}
void resetPidProfile(pidProfile_t *pidProfile)
static void resetControlRateConfig(controlRateConfig_t *controlRateConfig)
{
controlRateConfig->rcRate8 = 100;
controlRateConfig->rcYawRate8 = 100;
controlRateConfig->rcExpo8 = 10;
controlRateConfig->thrMid8 = 50;
controlRateConfig->thrExpo8 = 0;
controlRateConfig->dynThrPID = 20;
controlRateConfig->rcYawExpo8 = 10;
controlRateConfig->tpa_breakpoint = 1650;
for (uint8_t axis = 0; axis < FLIGHT_DYNAMICS_INDEX_COUNT; axis++) {
controlRateConfig->rates[axis] = 70;
}
}
static void resetPidProfile(pidProfile_t *pidProfile)
{
pidProfile->pidController = PID_CONTROLLER_BETAFLIGHT;
@ -242,6 +258,15 @@ void resetPidProfile(pidProfile_t *pidProfile)
#endif
}
void resetProfile(profile_t *profile)
{
resetPidProfile(&profile->pidProfile);
for (int rI = 0; rI<MAX_RATEPROFILES; rI++) {
resetControlRateConfig(&profile->controlRateProfile[rI]);
}
}
#ifdef GPS
void resetGpsProfile(gpsProfile_t *gpsProfile)
{
@ -350,23 +375,6 @@ void resetSerialConfig(serialConfig_t *serialConfig)
serialConfig->reboot_character = 'R';
}
static void resetControlRateConfig(controlRateConfig_t *controlRateConfig)
{
controlRateConfig->rcRate8 = 100;
controlRateConfig->rcYawRate8 = 100;
controlRateConfig->rcExpo8 = 10;
controlRateConfig->thrMid8 = 50;
controlRateConfig->thrExpo8 = 0;
controlRateConfig->dynThrPID = 20;
controlRateConfig->rcYawExpo8 = 10;
controlRateConfig->tpa_breakpoint = 1650;
for (uint8_t axis = 0; axis < FLIGHT_DYNAMICS_INDEX_COUNT; axis++) {
controlRateConfig->rates[axis] = 70;
}
}
void resetRcControlsConfig(rcControlsConfig_t *rcControlsConfig)
{
rcControlsConfig->deadband = 0;
@ -560,11 +568,8 @@ static void resetConf(void)
masterConfig.emf_avoidance = 0; // TODO - needs removal
resetPidProfile(&currentProfile->pidProfile);
resetProfile(currentProfile);
for (int rI = 0; rI<MAX_RATEPROFILES; rI++) {
resetControlRateConfig(&masterConfig.profile[0].controlRateProfile[rI]);
}
resetRollAndPitchTrims(&masterConfig.accelerometerTrims);
masterConfig.mag_declination = 0;

View File

@ -103,7 +103,7 @@ static serialPort_t *mspSerialPort;
extern uint16_t cycleTime; // FIXME dependency on mw.c
extern uint16_t rssi; // FIXME dependency on mw.c
extern void resetPidProfile(pidProfile_t *pidProfile);
extern void resetProfile(profile_t *profile);
void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, escAndServoConfig_t *escAndServoConfigToUse, pidProfile_t *pidProfileToUse);
@ -1482,7 +1482,7 @@ static bool processInCommand(void)
break;
case MSP_SET_RESET_CURR_PID:
resetPidProfile(&currentProfile->pidProfile);
resetProfile(currentProfile);
break;
case MSP_SET_SENSOR_ALIGNMENT: