diff --git a/src/main/cli/settings.c b/src/main/cli/settings.c index 957e5638d4..72efab8ba4 100644 --- a/src/main/cli/settings.c +++ b/src/main/cli/settings.c @@ -501,6 +501,10 @@ const char * const lookupTableEdgeMode[] = { "FALLING", "RISING" }; +const char * const lookupTableParamType[] = { + "NONE", "TIMER1", "TIMER2", "TIMER3", "GV1", "GV2", "GV3", "GV4", "GV5", "GV6", "GV7", "GV8", "GV9" +}; + #define LOOKUP_TABLE_ENTRY(name) { name, ARRAYLEN(name) } const lookupTableEntry_t lookupTables[] = { @@ -614,6 +618,7 @@ const lookupTableEntry_t lookupTables[] = { LOOKUP_TABLE_ENTRY(lookupTableTelemMode), LOOKUP_TABLE_ENTRY(lookupTablePullMode), LOOKUP_TABLE_ENTRY(lookupTableEdgeMode), + LOOKUP_TABLE_ENTRY(lookupTableParamType), }; #undef LOOKUP_TABLE_ENTRY @@ -1701,6 +1706,12 @@ const clivalue_t valueTable[] = { { "display_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, displayName) }, #endif { "model_id", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 99 }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, modelId) }, + { "model_param1_type", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_PARAM_TYPE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, modelParam1Type) }, + { "model_param1_value", VAR_INT16 | MASTER_VALUE, .config.minmax = { INT16_MIN, INT16_MAX }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, modelParam1Value) }, + { "model_param2_type", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_PARAM_TYPE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, modelParam2Type) }, + { "model_param2_value", VAR_INT16 | MASTER_VALUE, .config.minmax = { INT16_MIN, INT16_MAX }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, modelParam2Value) }, + { "model_param3_type", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_PARAM_TYPE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, modelParam3Type) }, + { "model_param3_value", VAR_INT16 | MASTER_VALUE, .config.minmax = { INT16_MIN, INT16_MAX }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, modelParam3Value) }, // PG_POSITION { "position_alt_source", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_POSITION_ALT_SOURCE }, PG_POSITION, offsetof(positionConfig_t, alt_source) }, diff --git a/src/main/cli/settings.h b/src/main/cli/settings.h index 8daeb75c2e..43da0bb477 100644 --- a/src/main/cli/settings.h +++ b/src/main/cli/settings.h @@ -129,9 +129,9 @@ typedef enum { TABLE_SWASH_TYPE, TABLE_DTERM_MODE, TABLE_TELEM_MODE, - TABLE_INPUT_PULL_MODE, TABLE_INPUT_EDGE_MODE, + TABLE_PARAM_TYPE, LOOKUP_TABLE_COUNT } lookupTableIndex_e; diff --git a/src/main/msp/msp.c b/src/main/msp/msp.c index 37e46d45f7..f0596b8c1b 100644 --- a/src/main/msp/msp.c +++ b/src/main/msp/msp.c @@ -1103,10 +1103,20 @@ static bool mspProcessOutCommand(int16_t cmdMSP, sbuf_t *dst) for (int i = 0; i < nameLen; i++) { sbufWriteU8(dst, pilotConfig()->name[i]); } - sbufWriteU8(dst, pilotConfig()->modelId); } break; + case MSP_PILOT_CONFIG: + // Introduced in MSP API 12.7 + sbufWriteU8(dst, pilotConfig()->modelId); + sbufWriteU8(dst, pilotConfig()->modelParam1Type); + sbufWriteU16(dst, pilotConfig()->modelParam1Value); + sbufWriteU8(dst, pilotConfig()->modelParam2Type); + sbufWriteU16(dst, pilotConfig()->modelParam2Value); + sbufWriteU8(dst, pilotConfig()->modelParam3Type); + sbufWriteU16(dst, pilotConfig()->modelParam3Value); + break; + #ifdef USE_SERVOS case MSP_SERVO: for (int i = 0; i < MAX_SUPPORTED_SERVOS; i++) { @@ -3202,14 +3212,22 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP, for (unsigned int i = 0; i < MIN(MAX_NAME_LENGTH, dataSize); i++) { pilotConfigMutable()->name[i] = sbufReadU8(src); } - if (sbufBytesRemaining(src) >= 1) { - pilotConfigMutable()->modelId = sbufReadU8(src); - } #ifdef USE_OSD osdAnalyzeActiveElements(); #endif break; + case MSP_SET_PILOT_CONFIG: + // Introduced in MSP API 12.7 + pilotConfigMutable()->modelId = sbufReadU8(src); + pilotConfigMutable()->modelParam1Type = sbufReadU8(src); + pilotConfigMutable()->modelParam1Value = sbufReadU16(src); + pilotConfigMutable()->modelParam2Type = sbufReadU8(src); + pilotConfigMutable()->modelParam2Value = sbufReadU16(src); + pilotConfigMutable()->modelParam3Type = sbufReadU8(src); + pilotConfigMutable()->modelParam3Value = sbufReadU16(src); + break; + #ifdef USE_RTC_TIME case MSP_SET_RTC: { diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index d75d184dea..32dd32204f 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -74,6 +74,8 @@ #define MSP_NAME 10 #define MSP_SET_NAME 11 +#define MSP_PILOT_CONFIG 12 +#define MSP_SET_PILOT_CONFIG 13 #define MSP_BATTERY_CONFIG 32 #define MSP_SET_BATTERY_CONFIG 33 diff --git a/src/main/pg/pilot.h b/src/main/pg/pilot.h index 5db1066b18..db96e9d12f 100644 --- a/src/main/pg/pilot.h +++ b/src/main/pg/pilot.h @@ -29,6 +29,12 @@ typedef struct { char name[MAX_NAME_LENGTH + 1]; char displayName[MAX_NAME_LENGTH + 1]; uint8_t modelId; + uint8_t modelParam1Type; + int16_t modelParam1Value; + uint8_t modelParam2Type; + int16_t modelParam2Value; + uint8_t modelParam3Type; + int16_t modelParam3Value; } pilotConfig_t; PG_DECLARE(pilotConfig_t, pilotConfig);