mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 07:15:18 +03:00
Fixed rxfail and rxrange CLI commands
This commit is contained in:
parent
dcecf9dc67
commit
0b100bf167
7 changed files with 43 additions and 43 deletions
|
@ -2002,7 +2002,7 @@ static void cliRxFailsafe(char *cmdline)
|
||||||
channel = atoi(ptr++);
|
channel = atoi(ptr++);
|
||||||
if ((channel < MAX_SUPPORTED_RC_CHANNEL_COUNT)) {
|
if ((channel < MAX_SUPPORTED_RC_CHANNEL_COUNT)) {
|
||||||
|
|
||||||
rxFailsafeChannelConfig_t *channelFailsafeConfig = &rxConfigMutable()->failsafe_channel_configurations[channel];
|
rxFailsafeChannelConfig_t *channelFailsafeConfig = rxFailsafeChannelConfigsMutable(channel);
|
||||||
|
|
||||||
const rxFailsafeChannelType_e type = (channel < NON_AUX_CHANNEL_COUNT) ? RX_FAILSAFE_TYPE_FLIGHT : RX_FAILSAFE_TYPE_AUX;
|
const rxFailsafeChannelType_e type = (channel < NON_AUX_CHANNEL_COUNT) ? RX_FAILSAFE_TYPE_FLIGHT : RX_FAILSAFE_TYPE_AUX;
|
||||||
rxFailsafeChannelMode_e mode = channelFailsafeConfig->mode;
|
rxFailsafeChannelMode_e mode = channelFailsafeConfig->mode;
|
||||||
|
@ -2565,9 +2565,9 @@ static void cliRxRange(char *cmdline)
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
|
|
||||||
if (isEmpty(cmdline)) {
|
if (isEmpty(cmdline)) {
|
||||||
printRxRange(DUMP_MASTER, rxConfig()->channelRanges, NULL);
|
printRxRange(DUMP_MASTER, rxChannelRangeConfigs(0), NULL);
|
||||||
} else if (strcasecmp(cmdline, "reset") == 0) {
|
} else if (strcasecmp(cmdline, "reset") == 0) {
|
||||||
resetAllRxChannelRangeConfigurations(rxConfigMutable()->channelRanges);
|
resetAllRxChannelRangeConfigurations(rxChannelRangeConfigsMutable(0));
|
||||||
} else {
|
} else {
|
||||||
ptr = cmdline;
|
ptr = cmdline;
|
||||||
i = atoi(ptr);
|
i = atoi(ptr);
|
||||||
|
@ -2591,7 +2591,7 @@ static void cliRxRange(char *cmdline)
|
||||||
} else if (rangeMin < PWM_PULSE_MIN || rangeMin > PWM_PULSE_MAX || rangeMax < PWM_PULSE_MIN || rangeMax > PWM_PULSE_MAX) {
|
} else if (rangeMin < PWM_PULSE_MIN || rangeMin > PWM_PULSE_MAX || rangeMax < PWM_PULSE_MIN || rangeMax > PWM_PULSE_MAX) {
|
||||||
cliShowParseError();
|
cliShowParseError();
|
||||||
} else {
|
} else {
|
||||||
rxChannelRangeConfig_t *channelRangeConfig = &rxConfigMutable()->channelRanges[i];
|
rxChannelRangeConfig_t *channelRangeConfig = rxChannelRangeConfigsMutable(i);
|
||||||
channelRangeConfig->min = rangeMin;
|
channelRangeConfig->min = rangeMin;
|
||||||
channelRangeConfig->max = rangeMax;
|
channelRangeConfig->max = rangeMax;
|
||||||
}
|
}
|
||||||
|
@ -3858,8 +3858,6 @@ static void cliProfile(char *cmdline)
|
||||||
const int i = atoi(cmdline);
|
const int i = atoi(cmdline);
|
||||||
if (i >= 0 && i < MAX_PROFILE_COUNT) {
|
if (i >= 0 && i < MAX_PROFILE_COUNT) {
|
||||||
systemConfigMutable()->pidProfileIndex = i;
|
systemConfigMutable()->pidProfileIndex = i;
|
||||||
writeEEPROM();
|
|
||||||
readEEPROM();
|
|
||||||
cliProfile("");
|
cliProfile("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1057,8 +1057,6 @@ void changePidProfile(uint8_t pidProfileIndex)
|
||||||
}
|
}
|
||||||
systemConfigMutable()->pidProfileIndex = pidProfileIndex;
|
systemConfigMutable()->pidProfileIndex = pidProfileIndex;
|
||||||
currentPidProfile = pidProfilesMutable(pidProfileIndex);
|
currentPidProfile = pidProfilesMutable(pidProfileIndex);
|
||||||
writeEEPROM();
|
|
||||||
readEEPROM();
|
|
||||||
beeperConfirmationBeeps(pidProfileIndex + 1);
|
beeperConfirmationBeeps(pidProfileIndex + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1816,8 +1816,8 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
||||||
case MSP_SET_RXFAIL_CONFIG:
|
case MSP_SET_RXFAIL_CONFIG:
|
||||||
i = sbufReadU8(src);
|
i = sbufReadU8(src);
|
||||||
if (i < MAX_SUPPORTED_RC_CHANNEL_COUNT) {
|
if (i < MAX_SUPPORTED_RC_CHANNEL_COUNT) {
|
||||||
rxConfigMutable()->failsafe_channel_configurations[i].mode = sbufReadU8(src);
|
rxFailsafeChannelConfigsMutable(i)->mode = sbufReadU8(src);
|
||||||
rxConfigMutable()->failsafe_channel_configurations[i].step = CHANNEL_VALUE_TO_RXFAIL_STEP(sbufReadU16(src));
|
rxFailsafeChannelConfigsMutable(i)->step = CHANNEL_VALUE_TO_RXFAIL_STEP(sbufReadU16(src));
|
||||||
} else {
|
} else {
|
||||||
return MSP_RESULT_ERROR;
|
return MSP_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "common/maths.h"
|
#include "common/maths.h"
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
|
#include "config/config_reset.h"
|
||||||
#include "config/feature.h"
|
#include "config/feature.h"
|
||||||
#include "config/parameter_group.h"
|
#include "config/parameter_group.h"
|
||||||
#include "config/parameter_group_ids.h"
|
#include "config/parameter_group_ids.h"
|
||||||
|
@ -101,29 +102,35 @@ static uint8_t rcSampleIndex = 0;
|
||||||
#define SERIALRX_PROVIDER 0
|
#define SERIALRX_PROVIDER 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define RX_MIN_USEC 885
|
||||||
|
#define RX_MAX_USEC 2115
|
||||||
|
#define RX_MID_USEC 1500
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_FN(rxConfig_t, rxConfig, PG_RX_CONFIG, 0);
|
PG_REGISTER_WITH_RESET_FN(rxConfig_t, rxConfig, PG_RX_CONFIG, 0);
|
||||||
void pgResetFn_rxConfig(rxConfig_t *rxConfig)
|
void pgResetFn_rxConfig(rxConfig_t *rxConfig)
|
||||||
{
|
{
|
||||||
rxConfig->halfDuplex = 0;
|
RESET_CONFIG(const rxConfig_t, rxConfig,
|
||||||
rxConfig->serialrx_provider = SERIALRX_PROVIDER;
|
.halfDuplex = 0,
|
||||||
rxConfig->rx_spi_protocol = RX_SPI_DEFAULT_PROTOCOL;
|
.serialrx_provider = SERIALRX_PROVIDER,
|
||||||
rxConfig->sbus_inversion = 1;
|
.rx_spi_protocol = RX_SPI_DEFAULT_PROTOCOL,
|
||||||
rxConfig->spektrum_sat_bind = 0;
|
.sbus_inversion = 1,
|
||||||
rxConfig->spektrum_sat_bind_autoreset = 1;
|
.spektrum_sat_bind = 0,
|
||||||
rxConfig->midrc = 1500;
|
.spektrum_sat_bind_autoreset = 1,
|
||||||
rxConfig->mincheck = 1100;
|
.midrc = RX_MID_USEC,
|
||||||
rxConfig->maxcheck = 1900;
|
.mincheck = 1100,
|
||||||
rxConfig->rx_min_usec = 885; // any of first 4 channels below this value will trigger rx loss detection
|
.maxcheck = 1900,
|
||||||
rxConfig->rx_max_usec = 2115; // any of first 4 channels above this value will trigger rx loss detection
|
.rx_min_usec = RX_MIN_USEC, // any of first 4 channels below this value will trigger rx loss detection
|
||||||
rxConfig->rssi_channel = 0;
|
.rx_max_usec = RX_MAX_USEC, // any of first 4 channels above this value will trigger rx loss detection
|
||||||
rxConfig->rssi_scale = RSSI_SCALE_DEFAULT;
|
.rssi_channel = 0,
|
||||||
rxConfig->rssi_invert = 0;
|
.rssi_scale = RSSI_SCALE_DEFAULT,
|
||||||
rxConfig->rcInterpolation = RC_SMOOTHING_AUTO;
|
.rssi_invert = 0,
|
||||||
rxConfig->rcInterpolationChannels = 0;
|
.rcInterpolation = RC_SMOOTHING_AUTO,
|
||||||
rxConfig->rcInterpolationInterval = 19;
|
.rcInterpolationChannels = 0,
|
||||||
rxConfig->fpvCamAngleDegrees = 0;
|
.rcInterpolationInterval = 19,
|
||||||
rxConfig->max_aux_channel = DEFAULT_AUX_CHANNEL_COUNT;
|
.fpvCamAngleDegrees = 0,
|
||||||
rxConfig->airModeActivateThreshold = 1350;
|
.max_aux_channel = DEFAULT_AUX_CHANNEL_COUNT,
|
||||||
|
.airModeActivateThreshold = 1350
|
||||||
|
);
|
||||||
|
|
||||||
#ifdef RX_CHANNELS_TAER
|
#ifdef RX_CHANNELS_TAER
|
||||||
parseRcChannels("TAER1234", rxConfig);
|
parseRcChannels("TAER1234", rxConfig);
|
||||||
|
@ -148,8 +155,8 @@ void pgResetFn_rxFailsafeChannelConfigs(rxFailsafeChannelConfig_t *rxFailsafeCha
|
||||||
for (int i = 0; i < MAX_SUPPORTED_RC_CHANNEL_COUNT; i++) {
|
for (int i = 0; i < MAX_SUPPORTED_RC_CHANNEL_COUNT; i++) {
|
||||||
rxFailsafeChannelConfigs[i].mode = (i < NON_AUX_CHANNEL_COUNT) ? RX_FAILSAFE_MODE_AUTO : RX_FAILSAFE_MODE_HOLD;
|
rxFailsafeChannelConfigs[i].mode = (i < NON_AUX_CHANNEL_COUNT) ? RX_FAILSAFE_MODE_AUTO : RX_FAILSAFE_MODE_HOLD;
|
||||||
rxFailsafeChannelConfigs[i].step = (i == THROTTLE)
|
rxFailsafeChannelConfigs[i].step = (i == THROTTLE)
|
||||||
? CHANNEL_VALUE_TO_RXFAIL_STEP(rxConfig()->rx_min_usec)
|
? CHANNEL_VALUE_TO_RXFAIL_STEP(RX_MIN_USEC)
|
||||||
: CHANNEL_VALUE_TO_RXFAIL_STEP(rxConfig()->midrc);
|
: CHANNEL_VALUE_TO_RXFAIL_STEP(RX_MID_USEC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,7 +437,7 @@ static uint16_t calculateNonDataDrivenChannel(uint8_t chan, uint16_t sample)
|
||||||
|
|
||||||
static uint16_t getRxfailValue(uint8_t channel)
|
static uint16_t getRxfailValue(uint8_t channel)
|
||||||
{
|
{
|
||||||
const rxFailsafeChannelConfig_t *channelFailsafeConfig = &rxConfig()->failsafe_channel_configurations[channel];
|
const rxFailsafeChannelConfig_t *channelFailsafeConfig = rxFailsafeChannelConfigs(channel);
|
||||||
|
|
||||||
switch(channelFailsafeConfig->mode) {
|
switch(channelFailsafeConfig->mode) {
|
||||||
case RX_FAILSAFE_MODE_AUTO:
|
case RX_FAILSAFE_MODE_AUTO:
|
||||||
|
@ -498,7 +505,7 @@ static void readRxChannelsApplyRanges(void)
|
||||||
|
|
||||||
// apply the rx calibration
|
// apply the rx calibration
|
||||||
if (channel < NON_AUX_CHANNEL_COUNT) {
|
if (channel < NON_AUX_CHANNEL_COUNT) {
|
||||||
sample = applyRxChannelRangeConfiguraton(sample, &rxConfig()->channelRanges[channel]);
|
sample = applyRxChannelRangeConfiguraton(sample, rxChannelRangeConfigs(channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
rcRaw[channel] = sample;
|
rcRaw[channel] = sample;
|
||||||
|
|
|
@ -140,9 +140,6 @@ typedef struct rxConfig_s {
|
||||||
|
|
||||||
uint16_t rx_min_usec;
|
uint16_t rx_min_usec;
|
||||||
uint16_t rx_max_usec;
|
uint16_t rx_max_usec;
|
||||||
rxFailsafeChannelConfig_t failsafe_channel_configurations[MAX_SUPPORTED_RC_CHANNEL_COUNT];
|
|
||||||
|
|
||||||
rxChannelRangeConfig_t channelRanges[NON_AUX_CHANNEL_COUNT];
|
|
||||||
} rxConfig_t;
|
} rxConfig_t;
|
||||||
|
|
||||||
PG_DECLARE(rxConfig_t, rxConfig);
|
PG_DECLARE(rxConfig_t, rxConfig);
|
||||||
|
|
|
@ -891,8 +891,8 @@ static bool bstSlaveProcessFeedbackCommand(uint8_t bstRequest)
|
||||||
|
|
||||||
case BST_RXFAIL_CONFIG:
|
case BST_RXFAIL_CONFIG:
|
||||||
for (i = NON_AUX_CHANNEL_COUNT; i < rxRuntimeConfig.channelCount; i++) {
|
for (i = NON_AUX_CHANNEL_COUNT; i < rxRuntimeConfig.channelCount; i++) {
|
||||||
bstWrite8(rxConfig()->failsafe_channel_configurations[i].mode);
|
bstWrite8(rxFailsafeChannelConfigs(i)->mode);
|
||||||
bstWrite16(RXFAIL_STEP_TO_CHANNEL_VALUE(rxConfig()->failsafe_channel_configurations[i].step));
|
bstWrite16(RXFAIL_STEP_TO_CHANNEL_VALUE(rxFailsafeChannelConfigs(i)->step));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1307,8 +1307,8 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
||||||
ret = BST_FAILED;
|
ret = BST_FAILED;
|
||||||
} else {
|
} else {
|
||||||
for (i = NON_AUX_CHANNEL_COUNT; i < channelCount; i++) {
|
for (i = NON_AUX_CHANNEL_COUNT; i < channelCount; i++) {
|
||||||
rxConfigMutable()->failsafe_channel_configurations[i].mode = bstRead8();
|
rxFailsafeChannelConfigsMutable(i)->mode = bstRead8();
|
||||||
rxConfigMutable()->failsafe_channel_configurations[i].step = CHANNEL_VALUE_TO_RXFAIL_STEP(bstRead16());
|
rxFailsafeChannelConfigsMutable(i)->step = CHANNEL_VALUE_TO_RXFAIL_STEP(bstRead16());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,8 +57,8 @@ void targetConfiguration(void)
|
||||||
gyroConfigMutable()->gyro_soft_notch_hz_2 = 0;
|
gyroConfigMutable()->gyro_soft_notch_hz_2 = 0;
|
||||||
|
|
||||||
/*for (int channel = 0; channel < NON_AUX_CHANNEL_COUNT; channel++) {
|
/*for (int channel = 0; channel < NON_AUX_CHANNEL_COUNT; channel++) {
|
||||||
rxConfigMutable()->channelRanges[channel].min = 1180;
|
rxChannelRangeConfigsMutable(channel)->min = 1180;
|
||||||
rxConfigMutable()->channelRanges[channel].max = 1860;
|
rxChannelRangeConfigsMutable(channel)->max = 1860;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
for (int profileId = 0; profileId < 2; profileId++) {
|
for (int profileId = 0; profileId < 2; profileId++) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue