mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-14 20:10:18 +03:00
changes to vtx cli command:
- add option for power - set band, channel or power to 0 to leave it unchanged - added short help text to cli
This commit is contained in:
parent
72d0117278
commit
056535e498
3 changed files with 29 additions and 22 deletions
|
@ -2274,7 +2274,7 @@ static void cliFlashRead(char *cmdline)
|
||||||
static void printVtx(dumpFlags_t dumpMask, const vtxConfig_t *vtxConfig, const vtxConfig_t *vtxConfigDefault)
|
static void printVtx(dumpFlags_t dumpMask, const vtxConfig_t *vtxConfig, const vtxConfig_t *vtxConfigDefault)
|
||||||
{
|
{
|
||||||
// print out vtx channel settings
|
// print out vtx channel settings
|
||||||
const char *format = "vtx %u %u %u %u %u %u";
|
const char *format = "vtx %u %u %u %u %u %u %u";
|
||||||
bool equalsDefault = false;
|
bool equalsDefault = false;
|
||||||
for (uint32_t i = 0; i < MAX_CHANNEL_ACTIVATION_CONDITION_COUNT; i++) {
|
for (uint32_t i = 0; i < MAX_CHANNEL_ACTIVATION_CONDITION_COUNT; i++) {
|
||||||
const vtxChannelActivationCondition_t *cac = &vtxConfig->vtxChannelActivationConditions[i];
|
const vtxChannelActivationCondition_t *cac = &vtxConfig->vtxChannelActivationConditions[i];
|
||||||
|
@ -2286,6 +2286,7 @@ static void printVtx(dumpFlags_t dumpMask, const vtxConfig_t *vtxConfig, const v
|
||||||
cacDefault->auxChannelIndex,
|
cacDefault->auxChannelIndex,
|
||||||
cacDefault->band,
|
cacDefault->band,
|
||||||
cacDefault->channel,
|
cacDefault->channel,
|
||||||
|
cacDefault->power,
|
||||||
MODE_STEP_TO_CHANNEL_VALUE(cacDefault->range.startStep),
|
MODE_STEP_TO_CHANNEL_VALUE(cacDefault->range.startStep),
|
||||||
MODE_STEP_TO_CHANNEL_VALUE(cacDefault->range.endStep)
|
MODE_STEP_TO_CHANNEL_VALUE(cacDefault->range.endStep)
|
||||||
);
|
);
|
||||||
|
@ -2295,6 +2296,7 @@ static void printVtx(dumpFlags_t dumpMask, const vtxConfig_t *vtxConfig, const v
|
||||||
cac->auxChannelIndex,
|
cac->auxChannelIndex,
|
||||||
cac->band,
|
cac->band,
|
||||||
cac->channel,
|
cac->channel,
|
||||||
|
cac->power,
|
||||||
MODE_STEP_TO_CHANNEL_VALUE(cac->range.startStep),
|
MODE_STEP_TO_CHANNEL_VALUE(cac->range.startStep),
|
||||||
MODE_STEP_TO_CHANNEL_VALUE(cac->range.endStep)
|
MODE_STEP_TO_CHANNEL_VALUE(cac->range.endStep)
|
||||||
);
|
);
|
||||||
|
@ -2303,7 +2305,7 @@ static void printVtx(dumpFlags_t dumpMask, const vtxConfig_t *vtxConfig, const v
|
||||||
|
|
||||||
static void cliVtx(char *cmdline)
|
static void cliVtx(char *cmdline)
|
||||||
{
|
{
|
||||||
const char *format = "vtx %u %u %u %u %u %u";
|
const char *format = "vtx %u %u %u %u %u %u %u";
|
||||||
int i, val = 0;
|
int i, val = 0;
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
|
|
||||||
|
@ -2327,7 +2329,6 @@ static void cliVtx(char *cmdline)
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
val = atoi(ptr);
|
val = atoi(ptr);
|
||||||
// FIXME Use VTX API to get max
|
// FIXME Use VTX API to get max
|
||||||
// We check for the min value in final validation below
|
|
||||||
if (val >= 0 && val <= VTX_SETTINGS_MAX_BAND) {
|
if (val >= 0 && val <= VTX_SETTINGS_MAX_BAND) {
|
||||||
cac->band = val;
|
cac->band = val;
|
||||||
validArgumentCount++;
|
validArgumentCount++;
|
||||||
|
@ -2337,29 +2338,23 @@ static void cliVtx(char *cmdline)
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
val = atoi(ptr);
|
val = atoi(ptr);
|
||||||
// FIXME Use VTX API to get max
|
// FIXME Use VTX API to get max
|
||||||
// We check for the min value in final validation below
|
|
||||||
if (val >= 0 && val <= VTX_SETTINGS_MAX_CHANNEL) {
|
if (val >= 0 && val <= VTX_SETTINGS_MAX_CHANNEL) {
|
||||||
cac->channel = val;
|
cac->channel = val;
|
||||||
validArgumentCount++;
|
validArgumentCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptr = processChannelRangeArgs(ptr, &cac->range, &validArgumentCount);
|
ptr = nextArg(ptr);
|
||||||
|
if (ptr) {
|
||||||
bool parseError = false;
|
val = atoi(ptr);
|
||||||
if (validArgumentCount != 5) {
|
// FIXME Use VTX API to get max
|
||||||
parseError = true;
|
if (val >= 0 && val < VTX_SETTINGS_POWER_COUNT) {
|
||||||
} else {
|
cac->power= val;
|
||||||
// check for an empty activation condition for reset
|
validArgumentCount++;
|
||||||
vtxChannelActivationCondition_t emptyCac;
|
|
||||||
memset(&emptyCac, 0, sizeof(emptyCac));
|
|
||||||
if (memcmp(cac, &emptyCac, sizeof(emptyCac)) != 0
|
|
||||||
// FIXME Use VTX API to get min
|
|
||||||
&& ((cac->band < VTX_SETTINGS_MIN_BAND) || (cac->channel < VTX_SETTINGS_MIN_CHANNEL))) {
|
|
||||||
parseError = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ptr = processChannelRangeArgs(ptr, &cac->range, &validArgumentCount);
|
||||||
|
|
||||||
if (parseError) {
|
if (validArgumentCount != 6) {
|
||||||
memset(cac, 0, sizeof(vtxChannelActivationCondition_t));
|
memset(cac, 0, sizeof(vtxChannelActivationCondition_t));
|
||||||
cliShowParseError();
|
cliShowParseError();
|
||||||
} else {
|
} else {
|
||||||
|
@ -2368,6 +2363,7 @@ static void cliVtx(char *cmdline)
|
||||||
cac->auxChannelIndex,
|
cac->auxChannelIndex,
|
||||||
cac->band,
|
cac->band,
|
||||||
cac->channel,
|
cac->channel,
|
||||||
|
cac->power,
|
||||||
MODE_STEP_TO_CHANNEL_VALUE(cac->range.startStep),
|
MODE_STEP_TO_CHANNEL_VALUE(cac->range.startStep),
|
||||||
MODE_STEP_TO_CHANNEL_VALUE(cac->range.endStep)
|
MODE_STEP_TO_CHANNEL_VALUE(cac->range.endStep)
|
||||||
);
|
);
|
||||||
|
@ -5738,7 +5734,7 @@ const clicmd_t cmdTable[] = {
|
||||||
#endif
|
#endif
|
||||||
CLI_COMMAND_DEF("version", "show version", NULL, cliVersion),
|
CLI_COMMAND_DEF("version", "show version", NULL, cliVersion),
|
||||||
#ifdef USE_VTX_CONTROL
|
#ifdef USE_VTX_CONTROL
|
||||||
CLI_COMMAND_DEF("vtx", "vtx channels on switch", NULL, cliVtx),
|
CLI_COMMAND_DEF("vtx", "vtx channels on switch", "<index> <aux> <band> <channel> <power> <start> <end>", cliVtx),
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_VTX_TABLE
|
#ifdef USE_VTX_TABLE
|
||||||
CLI_COMMAND_DEF("vtxtable", "vtx frequency able", "<band> <bandname> <bandletter> <freq> ... <freq>\r\n", cliVtxTable),
|
CLI_COMMAND_DEF("vtxtable", "vtx frequency able", "<band> <bandname> <bandletter> <freq> ... <freq>\r\n", cliVtxTable),
|
||||||
|
|
|
@ -109,7 +109,7 @@ void vtxUpdateActivatedChannel(void)
|
||||||
locked = 1;
|
locked = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!locked && vtxCommonDevice()) {
|
if (vtxCommonDevice()) {
|
||||||
static uint8_t lastIndex = -1;
|
static uint8_t lastIndex = -1;
|
||||||
|
|
||||||
for (uint8_t index = 0; index < MAX_CHANNEL_ACTIVATION_CONDITION_COUNT; index++) {
|
for (uint8_t index = 0; index < MAX_CHANNEL_ACTIVATION_CONDITION_COUNT; index++) {
|
||||||
|
@ -119,8 +119,18 @@ void vtxUpdateActivatedChannel(void)
|
||||||
&& index != lastIndex) {
|
&& index != lastIndex) {
|
||||||
lastIndex = index;
|
lastIndex = index;
|
||||||
|
|
||||||
vtxSettingsConfigMutable()->band = vtxChannelActivationCondition->band;
|
if (!locked) {
|
||||||
vtxSettingsConfigMutable()->channel = vtxChannelActivationCondition->channel;
|
if (vtxChannelActivationCondition->band > 0) {
|
||||||
|
vtxSettingsConfigMutable()->band = vtxChannelActivationCondition->band;
|
||||||
|
}
|
||||||
|
if (vtxChannelActivationCondition->channel > 0) {
|
||||||
|
vtxSettingsConfigMutable()->channel = vtxChannelActivationCondition->channel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtxChannelActivationCondition->power > 0) {
|
||||||
|
vtxSettingsConfigMutable()->power = vtxChannelActivationCondition->power;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ typedef struct vtxChannelActivationCondition_s {
|
||||||
uint8_t auxChannelIndex;
|
uint8_t auxChannelIndex;
|
||||||
uint8_t band;
|
uint8_t band;
|
||||||
uint8_t channel;
|
uint8_t channel;
|
||||||
|
uint8_t power;
|
||||||
channelRange_t range;
|
channelRange_t range;
|
||||||
} vtxChannelActivationCondition_t;
|
} vtxChannelActivationCondition_t;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue