Skip to content

Commit

Permalink
Added max_rx_channels configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
blckmn committed Jan 25, 2016
1 parent 196f05f commit 452e694
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
10 changes: 9 additions & 1 deletion src/main/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,15 @@ static void resetConf(void)
#if defined(CC3D)
masterConfig.acc_hardware = 1; // default/autodetect
#endif


#if defined(STM32F40_41xxx) || defined (STM32F411xE)
masterConfig.rxConfig.max_rx_channels = 16;
#elif defined(STM32F303xC)
masterConfig.rxConfig.max_rx_channels = 10;
#else
masterConfig.rxConfig.max_rx_channels = 8;
#endif

masterConfig.rxConfig.spektrum_sat_bind = 0;
masterConfig.rxConfig.midrc = 1500;
masterConfig.rxConfig.mincheck = 1100;
Expand Down
3 changes: 2 additions & 1 deletion src/main/flight/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ STATIC_UNIT_TESTED void servoMixer(void)
void mixTable(void)
{
uint32_t i;

bool isFailsafeActive = failsafeIsActive(); // TODO - Find out if failsafe checks are really needed here in mixer code

if (motorCount >= 4 && mixerConfig->yaw_jump_prevention_limit < YAW_JUMP_PREVENTION_LIMIT_HIGH) {
Expand Down Expand Up @@ -793,6 +793,7 @@ void mixTable(void)
int16_t throttleMin, throttleMax;
static bool flightDirection3dReversed;

throttleMin = 0;
throttle = rcData[THROTTLE];

// Find min and max throttle based on condition
Expand Down
1 change: 1 addition & 0 deletions src/main/io/serial_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ const clivalue_t valueTable[] = {

{ "rx_min_usec", VAR_UINT16 | MASTER_VALUE, &masterConfig.rxConfig.rx_min_usec, .config.minmax = { PWM_PULSE_MIN, PWM_PULSE_MAX } },
{ "rx_max_usec", VAR_UINT16 | MASTER_VALUE, &masterConfig.rxConfig.rx_max_usec, .config.minmax = { PWM_PULSE_MIN, PWM_PULSE_MAX } },
{ "max_rx_channels", VAR_UINT8 | MASTER_VALUE, &masterConfig.rxConfig.max_rx_channels, .config.minmax = { 4, 16 } },

#ifdef USE_SERVOS
{ "gimbal_mode", VAR_UINT8 | PROFILE_VALUE | MODE_LOOKUP, &masterConfig.profile[0].gimbalConfig.mode, .config.lookup = { TABLE_GIMBAL_MODE } },
Expand Down
15 changes: 3 additions & 12 deletions src/main/rx/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ uint32_t rcInvalidPulsPeriod[MAX_SUPPORTED_RC_CHANNEL_COUNT];
#define DELAY_5_HZ (1000000 / 5)
#define SKIP_RC_ON_SUSPEND_PERIOD 1500000 // 1.5 second period in usec (call frequency independent)
#define SKIP_RC_SAMPLES_ON_RESUME 2 // flush 2 samples to drop wrong measurements (timing independent)
#ifdef STM32F303xC
#define MAX_RC_CHANNELS_HIGH_PERFORMANCE 10 // Maximum channels allowed during fast refresh rates for more performance
#else
#define MAX_RC_CHANNELS_HIGH_PERFORMANCE 8 // Maximum channels allowed during fast refresh rates for more performance
#endif

rxRuntimeConfig_t rxRuntimeConfig;
static rxConfig_t *rxConfig;
Expand Down Expand Up @@ -457,14 +452,10 @@ static uint8_t getRxChannelCount(void) {
static uint8_t maxChannelsAllowed;

if (!maxChannelsAllowed) {
if (targetLooptime < 1000) {
if (MAX_RC_CHANNELS_HIGH_PERFORMANCE > rxRuntimeConfig.channelCount) {
maxChannelsAllowed = rxRuntimeConfig.channelCount;
} else {
maxChannelsAllowed = MAX_RC_CHANNELS_HIGH_PERFORMANCE;
}
} else {
if (rxConfig->max_rx_channels > rxRuntimeConfig.channelCount) {
maxChannelsAllowed = rxRuntimeConfig.channelCount;
} else {
maxChannelsAllowed = rxConfig->max_rx_channels;
}
}
return maxChannelsAllowed;
Expand Down
1 change: 1 addition & 0 deletions src/main/rx/rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ typedef struct rxConfig_s {

uint16_t rx_min_usec;
uint16_t rx_max_usec;
uint8_t max_rx_channels;
rxFailsafeChannelConfiguration_t failsafe_channel_configurations[MAX_SUPPORTED_RC_CHANNEL_COUNT];

rxChannelRangeConfiguration_t channelRanges[NON_AUX_CHANNEL_COUNT];
Expand Down

0 comments on commit 452e694

Please sign in to comment.