mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
Optimize rc modes activation conditions processing
Analyze the rc modes activation conditions and only process configured entries. Previously the entire possible list was processed even though typically only a handful are configured. Reduces the RX task processing time by about 25% (~44us to ~33us) with an average setup of 3 modes configured (F405, SBUS). Processing time savings will diminish as the user configures more modes. But typically far fewer than the maximum of 20 will be configured.
This commit is contained in:
parent
8c78ac507b
commit
42af168854
11 changed files with 65 additions and 14 deletions
|
@ -285,4 +285,6 @@ bool setManufacturerId(char *newManufacturerId) { UNUSED(newManufacturerId); ret
|
|||
bool persistBoardInformation(void) { return true; };
|
||||
|
||||
void activeAdjustmentRangeReset(void) {}
|
||||
void analyzeModeActivationConditions(void) {}
|
||||
bool isModeActivationConditionConfigured(const modeActivationCondition_t *, const modeActivationCondition_t *) { return false; }
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ TEST_F(RcControlsModesTest, updateActivatedModesWithAllInputsAtMidde)
|
|||
}
|
||||
|
||||
// when
|
||||
analyzeModeActivationConditions();
|
||||
updateActivatedModes();
|
||||
|
||||
// then
|
||||
|
@ -178,6 +179,7 @@ TEST_F(RcControlsModesTest, updateActivatedModesUsingValidAuxConfigurationAndRXV
|
|||
bitArraySet(&activeBoxIds, 5);
|
||||
|
||||
// when
|
||||
analyzeModeActivationConditions();
|
||||
updateActivatedModes();
|
||||
|
||||
// then
|
||||
|
|
|
@ -301,6 +301,8 @@ TEST(RCDeviceTest, TestWifiModeChangeWithDeviceUnready)
|
|||
modeActivationConditionsMutable(2)->range.startStep = CHANNEL_VALUE_TO_STEP(1300);
|
||||
modeActivationConditionsMutable(2)->range.endStep = CHANNEL_VALUE_TO_STEP(1600);
|
||||
|
||||
analyzeModeActivationConditions();
|
||||
|
||||
// make the binded mode inactive
|
||||
rcData[modeActivationConditions(0)->auxChannelIndex + NON_AUX_CHANNEL_COUNT] = 1800;
|
||||
rcData[modeActivationConditions(1)->auxChannelIndex + NON_AUX_CHANNEL_COUNT] = 900;
|
||||
|
@ -362,6 +364,8 @@ TEST(RCDeviceTest, TestWifiModeChangeWithDeviceReady)
|
|||
modeActivationConditionsMutable(2)->range.startStep = CHANNEL_VALUE_TO_STEP(1900);
|
||||
modeActivationConditionsMutable(2)->range.endStep = CHANNEL_VALUE_TO_STEP(2100);
|
||||
|
||||
analyzeModeActivationConditions();
|
||||
|
||||
rcData[modeActivationConditions(0)->auxChannelIndex + NON_AUX_CHANNEL_COUNT] = 1700;
|
||||
rcData[modeActivationConditions(1)->auxChannelIndex + NON_AUX_CHANNEL_COUNT] = 2000;
|
||||
rcData[modeActivationConditions(2)->auxChannelIndex + NON_AUX_CHANNEL_COUNT] = 1700;
|
||||
|
@ -422,6 +426,8 @@ TEST(RCDeviceTest, TestWifiModeChangeCombine)
|
|||
modeActivationConditionsMutable(2)->range.startStep = CHANNEL_VALUE_TO_STEP(1900);
|
||||
modeActivationConditionsMutable(2)->range.endStep = CHANNEL_VALUE_TO_STEP(2100);
|
||||
|
||||
analyzeModeActivationConditions();
|
||||
|
||||
// // make the binded mode inactive
|
||||
rcData[modeActivationConditions(0)->auxChannelIndex + NON_AUX_CHANNEL_COUNT] = 1700;
|
||||
rcData[modeActivationConditions(1)->auxChannelIndex + NON_AUX_CHANNEL_COUNT] = 2000;
|
||||
|
|
|
@ -78,6 +78,8 @@ TEST(RxTest, TestValidFlightChannels)
|
|||
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MIN);
|
||||
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(1600);
|
||||
|
||||
analyzeModeActivationConditions();
|
||||
|
||||
// when
|
||||
rxInit();
|
||||
|
||||
|
@ -113,6 +115,8 @@ TEST(RxTest, TestValidFlightChannelsHighArm)
|
|||
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1400);
|
||||
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
|
||||
|
||||
analyzeModeActivationConditions();
|
||||
|
||||
// when
|
||||
rxInit();
|
||||
|
||||
|
@ -147,6 +151,8 @@ TEST(RxTest, TestInvalidFlightChannels)
|
|||
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1400);
|
||||
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
|
||||
|
||||
analyzeModeActivationConditions();
|
||||
|
||||
// and
|
||||
uint16_t channelPulses[MAX_SUPPORTED_RC_CHANNEL_COUNT];
|
||||
memset(&channelPulses, 1500, sizeof(channelPulses));
|
||||
|
|
|
@ -89,6 +89,8 @@ TEST(VtxTest, PitMode)
|
|||
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
|
||||
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
|
||||
|
||||
analyzeModeActivationConditions();
|
||||
|
||||
// and
|
||||
vtxSettingsConfigMutable()->band = 0;
|
||||
vtxSettingsConfigMutable()->freq = 5800;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue