Merge pull request #2818 from mikeller/use_permanent_mode_ids_in_cli
Changed CLI to use permanent mode ids.
This commit is contained in:
commit
e84cbe5fb5
|
@ -81,6 +81,7 @@ extern uint8_t __config_end;
|
|||
#include "fc/rc_adjustments.h"
|
||||
#include "fc/rc_controls.h"
|
||||
#include "fc/runtime_config.h"
|
||||
#include "fc/fc_msp.h"
|
||||
|
||||
#include "flight/altitudehold.h"
|
||||
#include "flight/failsafe.h"
|
||||
|
@ -1693,21 +1694,27 @@ static void printAux(uint8_t dumpMask, const modeActivationCondition_t *modeActi
|
|||
&& mac->auxChannelIndex == macDefault->auxChannelIndex
|
||||
&& mac->range.startStep == macDefault->range.startStep
|
||||
&& mac->range.endStep == macDefault->range.endStep;
|
||||
cliDefaultPrintf(dumpMask, equalsDefault, format,
|
||||
const box_t *box = findBoxByBoxId(macDefault->modeId);
|
||||
if (box) {
|
||||
cliDefaultPrintf(dumpMask, equalsDefault, format,
|
||||
i,
|
||||
box->permanentId,
|
||||
macDefault->auxChannelIndex,
|
||||
MODE_STEP_TO_CHANNEL_VALUE(macDefault->range.startStep),
|
||||
MODE_STEP_TO_CHANNEL_VALUE(macDefault->range.endStep)
|
||||
);
|
||||
}
|
||||
}
|
||||
const box_t *box = findBoxByBoxId(mac->modeId);
|
||||
if (box) {
|
||||
cliDumpPrintf(dumpMask, equalsDefault, format,
|
||||
i,
|
||||
macDefault->modeId,
|
||||
macDefault->auxChannelIndex,
|
||||
MODE_STEP_TO_CHANNEL_VALUE(macDefault->range.startStep),
|
||||
MODE_STEP_TO_CHANNEL_VALUE(macDefault->range.endStep)
|
||||
box->permanentId,
|
||||
mac->auxChannelIndex,
|
||||
MODE_STEP_TO_CHANNEL_VALUE(mac->range.startStep),
|
||||
MODE_STEP_TO_CHANNEL_VALUE(mac->range.endStep)
|
||||
);
|
||||
}
|
||||
cliDumpPrintf(dumpMask, equalsDefault, format,
|
||||
i,
|
||||
mac->modeId,
|
||||
mac->auxChannelIndex,
|
||||
MODE_STEP_TO_CHANNEL_VALUE(mac->range.startStep),
|
||||
MODE_STEP_TO_CHANNEL_VALUE(mac->range.endStep)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1727,8 +1734,9 @@ static void cliAux(char *cmdline)
|
|||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
val = atoi(ptr);
|
||||
if (val >= 0 && val < CHECKBOX_ITEM_COUNT) {
|
||||
mac->modeId = val;
|
||||
const box_t *box = findBoxByPermanentId(val);
|
||||
if (box) {
|
||||
mac->modeId = box->boxId;
|
||||
validArgumentCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
#include "fc/fc_msp.h"
|
||||
#include "fc/fc_rc.h"
|
||||
#include "fc/rc_adjustments.h"
|
||||
#include "fc/rc_controls.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "flight/altitudehold.h"
|
||||
|
@ -114,12 +113,6 @@ extern uint16_t cycleTime; // FIXME dependency on mw.c
|
|||
static const char * const flightControllerIdentifier = BETAFLIGHT_IDENTIFIER; // 4 UPPER CASE alpha numeric characters that identify the flight controller.
|
||||
static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER;
|
||||
|
||||
typedef struct box_e {
|
||||
const uint8_t boxId; // see boxId_e
|
||||
const char *boxName; // GUI-readable box name
|
||||
const uint8_t permanentId; //
|
||||
} box_t;
|
||||
|
||||
// FIXME remove ;'s
|
||||
static const box_t boxes[CHECKBOX_ITEM_COUNT + 1] = {
|
||||
{ BOXARM, "ARM;", 0 },
|
||||
|
@ -258,18 +251,18 @@ static void mspRebootFn(serialPort_t *serialPort)
|
|||
while (true) ;
|
||||
}
|
||||
|
||||
static const box_t *findBoxByActiveBoxId(uint8_t activeBoxId)
|
||||
const box_t *findBoxByBoxId(uint8_t boxId)
|
||||
{
|
||||
for (uint8_t boxIndex = 0; boxIndex < sizeof(boxes) / sizeof(box_t); boxIndex++) {
|
||||
const box_t *candidate = &boxes[boxIndex];
|
||||
if (candidate->boxId == activeBoxId) {
|
||||
if (candidate->boxId == boxId) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const box_t *findBoxByPermenantId(uint8_t permenantId)
|
||||
const box_t *findBoxByPermanentId(uint8_t permenantId)
|
||||
{
|
||||
for (uint8_t boxIndex = 0; boxIndex < sizeof(boxes) / sizeof(box_t); boxIndex++) {
|
||||
const box_t *candidate = &boxes[boxIndex];
|
||||
|
@ -289,7 +282,7 @@ reset:
|
|||
// then come back and actually send it
|
||||
for (int i = 0; i < activeBoxIdCount; i++) {
|
||||
const int activeBoxId = activeBoxIds[i];
|
||||
const box_t *box = findBoxByActiveBoxId(activeBoxId);
|
||||
const box_t *box = findBoxByBoxId(activeBoxId);
|
||||
if (!box) {
|
||||
continue;
|
||||
}
|
||||
|
@ -769,7 +762,7 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
|||
case MSP_MODE_RANGES:
|
||||
for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||
const modeActivationCondition_t *mac = modeActivationConditions(i);
|
||||
const box_t *box = &boxes[mac->modeId];
|
||||
const box_t *box = findBoxByBoxId(mac->modeId);
|
||||
sbufWriteU8(dst, box->permanentId);
|
||||
sbufWriteU8(dst, mac->auxChannelIndex);
|
||||
sbufWriteU8(dst, mac->range.startStep);
|
||||
|
@ -795,7 +788,7 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
|||
|
||||
case MSP_BOXIDS:
|
||||
for (int i = 0; i < activeBoxIdCount; i++) {
|
||||
const box_t *box = findBoxByActiveBoxId(activeBoxIds[i]);
|
||||
const box_t *box = findBoxByBoxId(activeBoxIds[i]);
|
||||
if (!box) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1373,7 +1366,7 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
||||
modeActivationCondition_t *mac = modeActivationConditionsMutable(i);
|
||||
i = sbufReadU8(src);
|
||||
const box_t *box = findBoxByPermenantId(i);
|
||||
const box_t *box = findBoxByPermanentId(i);
|
||||
if (box) {
|
||||
mac->modeId = box->boxId;
|
||||
mac->auxChannelIndex = sbufReadU8(src);
|
||||
|
|
|
@ -18,6 +18,16 @@
|
|||
#pragma once
|
||||
|
||||
#include "msp/msp.h"
|
||||
#include "rc_controls.h"
|
||||
|
||||
typedef struct box_e {
|
||||
const uint8_t boxId; // see boxId_e
|
||||
const char *boxName; // GUI-readable box name
|
||||
const uint8_t permanentId; //
|
||||
} box_t;
|
||||
|
||||
const box_t *findBoxByBoxId(uint8_t boxId);
|
||||
const box_t *findBoxByPermanentId(uint8_t permenantId);
|
||||
|
||||
void mspFcInit(void);
|
||||
mspResult_e mspFcProcessCommand(mspPacket_t *cmd, mspPacket_t *reply, mspPostProcessFnPtr *mspPostProcessFn);
|
||||
|
|
Loading…
Reference in New Issue