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

Merge pull request #8816 from mikeller/add_scheduler_optimize_rate_auto

Added 'auto' setting for 'scheduler_optimize_rate'.
This commit is contained in:
Michael Keller 2019-09-06 01:11:42 +12:00 committed by GitHub
commit 44f0fb577c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 8 deletions

View file

@ -469,7 +469,7 @@ static const char * const lookupTablePositionAltSource[] = {
"DEFAULT", "BARO_ONLY", "GPS_ONLY" "DEFAULT", "BARO_ONLY", "GPS_ONLY"
}; };
static const char * const lookupTableDshotBitbang[] = { static const char * const lookupTableOffOnAuto[] = {
"OFF", "ON", "AUTO" "OFF", "ON", "AUTO"
}; };
@ -592,7 +592,7 @@ const lookupTableEntry_t lookupTables[] = {
LOOKUP_TABLE_ENTRY(lookupTableGyroFilterDebug), LOOKUP_TABLE_ENTRY(lookupTableGyroFilterDebug),
LOOKUP_TABLE_ENTRY(lookupTablePositionAltSource), LOOKUP_TABLE_ENTRY(lookupTablePositionAltSource),
LOOKUP_TABLE_ENTRY(lookupTableDshotBitbang), LOOKUP_TABLE_ENTRY(lookupTableOffOnAuto),
LOOKUP_TABLE_ENTRY(lookupTableInterpolatedSetpoint), LOOKUP_TABLE_ENTRY(lookupTableInterpolatedSetpoint),
}; };
@ -767,7 +767,7 @@ const clivalue_t valueTable[] = {
{ "dshot_bidir", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotTelemetry) }, { "dshot_bidir", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotTelemetry) },
#endif #endif
#ifdef USE_DSHOT_BITBANG #ifdef USE_DSHOT_BITBANG
{ "dshot_bitbang", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_DSHOT_BITBANG }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotBitbang) }, { "dshot_bitbang", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON_AUTO }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useDshotBitbang) },
#endif #endif
#endif #endif
{ "use_unsynced_pwm", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useUnsyncedPwm) }, { "use_unsynced_pwm", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.useUnsyncedPwm) },
@ -1362,7 +1362,7 @@ const clivalue_t valueTable[] = {
{ "cpu_overclock", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OVERCLOCK }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, cpu_overclock) }, { "cpu_overclock", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OVERCLOCK }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, cpu_overclock) },
#endif #endif
{ "pwr_on_arm_grace", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 30 }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, powerOnArmingGraceTime) }, { "pwr_on_arm_grace", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 30 }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, powerOnArmingGraceTime) },
{ "scheduler_optimize_rate", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, schedulerOptimizeRate) }, { "scheduler_optimize_rate", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON_AUTO }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, schedulerOptimizeRate) },
// PG_VTX_CONFIG // PG_VTX_CONFIG
#ifdef USE_VTX_COMMON #ifdef USE_VTX_COMMON

View file

@ -135,7 +135,7 @@ typedef enum {
#endif #endif
TABLE_GYRO_FILTER_DEBUG, TABLE_GYRO_FILTER_DEBUG,
TABLE_POSITION_ALT_SOURCE, TABLE_POSITION_ALT_SOURCE,
TABLE_DSHOT_BITBANG, TABLE_OFF_ON_AUTO,
TABLE_INTERPOLATED_SP, TABLE_INTERPOLATED_SP,
LOOKUP_TABLE_COUNT LOOKUP_TABLE_COUNT

View file

@ -113,7 +113,7 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
.boardIdentifier = TARGET_BOARD_IDENTIFIER, .boardIdentifier = TARGET_BOARD_IDENTIFIER,
.hseMhz = SYSTEM_HSE_VALUE, // Not used for non-F4 targets .hseMhz = SYSTEM_HSE_VALUE, // Not used for non-F4 targets
.configurationState = CONFIGURATION_STATE_DEFAULTS_BARE, .configurationState = CONFIGURATION_STATE_DEFAULTS_BARE,
.schedulerOptimizeRate = true, .schedulerOptimizeRate = SCHEDULER_OPTIMIZE_RATE_AUTO,
); );
uint8_t getCurrentPidProfileIndex(void) uint8_t getCurrentPidProfileIndex(void)
@ -147,7 +147,7 @@ void resetConfig(void)
static void activateConfig(void) static void activateConfig(void)
{ {
schedulerOptimizeRate(systemConfig()->schedulerOptimizeRate); schedulerOptimizeRate(systemConfig()->schedulerOptimizeRate == SCHEDULER_OPTIMIZE_RATE_ON || (systemConfig()->schedulerOptimizeRate == SCHEDULER_OPTIMIZE_RATE_AUTO && motorConfig()->dev.useDshotTelemetry));
loadPidProfile(); loadPidProfile();
loadControlRateProfile(); loadControlRateProfile();
@ -510,7 +510,7 @@ static void validateAndFixConfig(void)
} }
#if defined(USE_DSHOT_TELEMETRY) #if defined(USE_DSHOT_TELEMETRY)
if ((!usingDshotProtocol || (motorConfig()->dev.useDshotBitbang == DSHOT_BITBANG_OFF && motorConfig()->dev.useBurstDshot) || !systemConfig()->schedulerOptimizeRate) if ((!usingDshotProtocol || (motorConfig()->dev.useDshotBitbang == DSHOT_BITBANG_OFF && motorConfig()->dev.useBurstDshot) || systemConfig()->schedulerOptimizeRate == SCHEDULER_OPTIMIZE_RATE_OFF)
&& motorConfig()->dev.useDshotTelemetry) { && motorConfig()->dev.useDshotTelemetry) {
motorConfigMutable()->dev.useDshotTelemetry = false; motorConfigMutable()->dev.useDshotTelemetry = false;
} }

View file

@ -35,6 +35,12 @@ typedef enum {
CONFIGURATION_STATE_CONFIGURED, CONFIGURATION_STATE_CONFIGURED,
} configurationState_e; } configurationState_e;
typedef enum {
SCHEDULER_OPTIMIZE_RATE_OFF = 0,
SCHEDULER_OPTIMIZE_RATE_ON,
SCHEDULER_OPTIMIZE_RATE_AUTO,
} schedulerOptimizeRate_e;
typedef struct pilotConfig_s { typedef struct pilotConfig_s {
char name[MAX_NAME_LENGTH + 1]; char name[MAX_NAME_LENGTH + 1];
char displayName[MAX_NAME_LENGTH + 1]; char displayName[MAX_NAME_LENGTH + 1];