mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 22:05:17 +03:00
Failsafe - Remove magic number usage. Cleanup whitespace
This commit is contained in:
parent
8e79a117d1
commit
3436b08575
4 changed files with 20 additions and 17 deletions
|
@ -403,7 +403,7 @@ static void resetConf(void)
|
||||||
masterConfig.rxConfig.rx_min_usec = 885; // any of first 4 channels below this value will trigger rx loss detection
|
masterConfig.rxConfig.rx_min_usec = 885; // any of first 4 channels below this value will trigger rx loss detection
|
||||||
masterConfig.rxConfig.rx_max_usec = 2115; // any of first 4 channels above this value will trigger rx loss detection
|
masterConfig.rxConfig.rx_max_usec = 2115; // any of first 4 channels above this value will trigger rx loss detection
|
||||||
|
|
||||||
for (i = 0; i < MAX_SUPPORTED_RC_CHANNEL_COUNT-4; i++) {
|
for (i = 0; i < MAX_AUX_CHANNEL_COUNT; i++) {
|
||||||
masterConfig.rxConfig.rx_fail_usec_steps[i] = CHANNEL_VALUE_TO_RXFAIL_STEP(masterConfig.rxConfig.midrc);
|
masterConfig.rxConfig.rx_fail_usec_steps[i] = CHANNEL_VALUE_TO_RXFAIL_STEP(masterConfig.rxConfig.midrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -567,7 +567,7 @@ static void cliRxFail(char *cmdline)
|
||||||
|
|
||||||
if (isEmpty(cmdline)) {
|
if (isEmpty(cmdline)) {
|
||||||
// print out rxConfig failsafe settings
|
// print out rxConfig failsafe settings
|
||||||
for (channel = 0; channel < MAX_SUPPORTED_RC_CHANNEL_COUNT-4; channel++) {
|
for (channel = 0; channel < MAX_AUX_CHANNEL_COUNT; channel++) {
|
||||||
cliRxFail(itoa(channel, buf, 10));
|
cliRxFail(itoa(channel, buf, 10));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -575,7 +575,7 @@ static void cliRxFail(char *cmdline)
|
||||||
char *ptr = cmdline;
|
char *ptr = cmdline;
|
||||||
|
|
||||||
channel = atoi(ptr++);
|
channel = atoi(ptr++);
|
||||||
if ((channel < MAX_SUPPORTED_RC_CHANNEL_COUNT-4)) {
|
if ((channel < MAX_AUX_CHANNEL_COUNT)) {
|
||||||
ptr = strchr(ptr, ' ');
|
ptr = strchr(ptr, ' ');
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
value = atoi(++ptr);
|
value = atoi(++ptr);
|
||||||
|
@ -590,9 +590,12 @@ static void cliRxFail(char *cmdline)
|
||||||
// 1. acknowledge interpretation on command,
|
// 1. acknowledge interpretation on command,
|
||||||
// 2. query current setting on single item,
|
// 2. query current setting on single item,
|
||||||
// 3. recursive use for full list.
|
// 3. recursive use for full list.
|
||||||
printf("rxfail %u %d\r\n", channel, RXFAIL_STEP_TO_CHANNEL_VALUE(masterConfig.rxConfig.rx_fail_usec_steps[channel]));
|
printf("rxfail %u %d\r\n",
|
||||||
|
channel,
|
||||||
|
RXFAIL_STEP_TO_CHANNEL_VALUE(masterConfig.rxConfig.rx_fail_usec_steps[channel])
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
printf("channel must be < %u\r\n", MAX_SUPPORTED_RC_CHANNEL_COUNT-4);
|
printf("channel must be < %u\r\n", MAX_AUX_CHANNEL_COUNT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,18 +311,18 @@ static uint16_t calculateNonDataDrivenChannel(uint8_t chan, uint16_t sample)
|
||||||
return rcDataMean[chan] / PPM_AND_PWM_SAMPLE_COUNT;
|
return rcDataMean[chan] / PPM_AND_PWM_SAMPLE_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t getRxfailValue(uint8_t chan)
|
static uint16_t getRxfailValue(uint8_t channel)
|
||||||
{
|
{
|
||||||
switch (chan) {
|
switch (channel) {
|
||||||
case ROLL:
|
case ROLL:
|
||||||
case PITCH:
|
case PITCH:
|
||||||
case YAW:
|
case YAW:
|
||||||
return rxConfig->midrc;
|
return rxConfig->midrc;
|
||||||
case THROTTLE:
|
case THROTTLE:
|
||||||
if (feature(FEATURE_3D)) return rxConfig->midrc;
|
if (feature(FEATURE_3D)) return rxConfig->midrc;
|
||||||
else return rxConfig->rx_min_usec;
|
else return rxConfig->rx_min_usec;
|
||||||
default:
|
default:
|
||||||
return RXFAIL_STEP_TO_CHANNEL_VALUE(rxConfig->rx_fail_usec_steps[chan-4]);
|
return RXFAIL_STEP_TO_CHANNEL_VALUE(rxConfig->rx_fail_usec_steps[channel - NON_AUX_CHANNEL_COUNT]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ typedef struct rxConfig_s {
|
||||||
|
|
||||||
uint16_t rx_min_usec;
|
uint16_t rx_min_usec;
|
||||||
uint16_t rx_max_usec;
|
uint16_t rx_max_usec;
|
||||||
uint8_t rx_fail_usec_steps[MAX_SUPPORTED_RC_CHANNEL_COUNT-4];
|
uint8_t rx_fail_usec_steps[MAX_AUX_CHANNEL_COUNT];
|
||||||
|
|
||||||
} rxConfig_t;
|
} rxConfig_t;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue