mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 01:35:41 +03:00
add validation based on rates type
This commit is contained in:
parent
4519935c92
commit
5adc8d5ce6
1 changed files with 38 additions and 0 deletions
|
@ -91,6 +91,7 @@ static bool configIsDirty; /* someone indicated that the config is modified and
|
||||||
static bool rebootRequired = false; // set if a config change requires a reboot to take effect
|
static bool rebootRequired = false; // set if a config change requires a reboot to take effect
|
||||||
|
|
||||||
pidProfile_t *currentPidProfile;
|
pidProfile_t *currentPidProfile;
|
||||||
|
controlRateConfig_t *currentRateProfile;
|
||||||
|
|
||||||
#ifndef RX_SPI_DEFAULT_PROTOCOL
|
#ifndef RX_SPI_DEFAULT_PROTOCOL
|
||||||
#define RX_SPI_DEFAULT_PROTOCOL 0
|
#define RX_SPI_DEFAULT_PROTOCOL 0
|
||||||
|
@ -98,6 +99,11 @@ pidProfile_t *currentPidProfile;
|
||||||
|
|
||||||
#define DYNAMIC_FILTER_MAX_SUPPORTED_LOOP_TIME HZ_TO_INTERVAL_US(2000)
|
#define DYNAMIC_FILTER_MAX_SUPPORTED_LOOP_TIME HZ_TO_INTERVAL_US(2000)
|
||||||
|
|
||||||
|
#define BETAFLIGHT_MAX_SRATE 100
|
||||||
|
#define KISS_MAX_SRATE 100
|
||||||
|
#define QUICK_MAX_RATE 200
|
||||||
|
#define ACTUAL_MAX_RATE 200
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_TEMPLATE(pilotConfig_t, pilotConfig, PG_PILOT_CONFIG, 1);
|
PG_REGISTER_WITH_RESET_TEMPLATE(pilotConfig_t, pilotConfig, PG_PILOT_CONFIG, 1);
|
||||||
|
|
||||||
PG_RESET_TEMPLATE(pilotConfig_t, pilotConfig,
|
PG_RESET_TEMPLATE(pilotConfig_t, pilotConfig,
|
||||||
|
@ -132,6 +138,11 @@ static void loadPidProfile(void)
|
||||||
currentPidProfile = pidProfilesMutable(systemConfig()->pidProfileIndex);
|
currentPidProfile = pidProfilesMutable(systemConfig()->pidProfileIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void loadCurrentControlRateProfile(void)
|
||||||
|
{
|
||||||
|
currentControlRateProfile = controlRateProfilesMutable(systemConfig()->activeRateProfile);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t getCurrentControlRateProfileIndex(void)
|
uint8_t getCurrentControlRateProfileIndex(void)
|
||||||
{
|
{
|
||||||
return systemConfig()->activeRateProfile;
|
return systemConfig()->activeRateProfile;
|
||||||
|
@ -156,6 +167,7 @@ static void activateConfig(void)
|
||||||
schedulerOptimizeRate(systemConfig()->schedulerOptimizeRate == SCHEDULER_OPTIMIZE_RATE_ON || (systemConfig()->schedulerOptimizeRate == SCHEDULER_OPTIMIZE_RATE_AUTO && motorConfig()->dev.useDshotTelemetry));
|
schedulerOptimizeRate(systemConfig()->schedulerOptimizeRate == SCHEDULER_OPTIMIZE_RATE_ON || (systemConfig()->schedulerOptimizeRate == SCHEDULER_OPTIMIZE_RATE_AUTO && motorConfig()->dev.useDshotTelemetry));
|
||||||
loadPidProfile();
|
loadPidProfile();
|
||||||
loadControlRateProfile();
|
loadControlRateProfile();
|
||||||
|
loadCurrentControlRateProfile();
|
||||||
|
|
||||||
initRcProcessing();
|
initRcProcessing();
|
||||||
|
|
||||||
|
@ -555,6 +567,32 @@ static void validateAndFixConfig(void)
|
||||||
#if defined(TARGET_VALIDATECONFIG)
|
#if defined(TARGET_VALIDATECONFIG)
|
||||||
targetValidateConfiguration();
|
targetValidateConfiguration();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
switch (currentControlRateProfile->rates_type) {
|
||||||
|
case RATES_TYPE_BETAFLIGHT:
|
||||||
|
default:
|
||||||
|
for (int axis = FD_ROLL; axis <= FD_YAW; axis++) {
|
||||||
|
currentControlRateProfile->rates[axis] = constrain(currentControlRateProfile->rates[axis], 0, BETAFLIGHT_MAX_SRATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case RATES_TYPE_KISS:
|
||||||
|
for (int axis = FD_ROLL; axis <= FD_YAW; axis++) {
|
||||||
|
currentControlRateProfile->rates[axis] = constrain(currentControlRateProfile->rates[axis], 0, KISS_MAX_SRATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case RATES_TYPE_ACTUAL:
|
||||||
|
for (int axis = FD_ROLL; axis <= FD_YAW; axis++) {
|
||||||
|
currentControlRateProfile->rates[axis] = constrain(currentControlRateProfile->rates[axis], 0, ACTUAL_MAX_RATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case RATES_TYPE_QUICK:
|
||||||
|
for (int axis = FD_ROLL; axis <= FD_YAW; axis++) {
|
||||||
|
currentControlRateProfile->rates[axis] = constrain(currentControlRateProfile->rates[axis], 0, QUICK_MAX_RATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void validateAndFixGyroConfig(void)
|
void validateAndFixGyroConfig(void)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue