mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Changed CLI to use permanent mode ids.
This commit is contained in:
parent
c2307a4bea
commit
8a7241f6cb
3 changed files with 39 additions and 28 deletions
|
@ -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;
|
||||
}
|
||||
|
@ -764,7 +757,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);
|
||||
|
@ -790,7 +783,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;
|
||||
}
|
||||
|
@ -1368,7 +1361,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue