From 68f0af0cb4738271f76535cb65f137de3c512f1c Mon Sep 17 00:00:00 2001 From: Tao Gong Date: Tue, 15 Oct 2024 01:20:08 -0700 Subject: [PATCH] Add MSP_EXPERIMENTAL and MSP_SET_EXPERIMENTAL (#183) Add a placeholder for adjusting experimental parameters from LUA. This allows devs to quickly expose parameters to LUA for field tuning, without create their own LUA. --- src/main/msp/msp.c | 20 ++++++++++++++++++++ src/main/msp/msp_protocol.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/src/main/msp/msp.c b/src/main/msp/msp.c index f0596b8c1b..dd7af4cb45 100644 --- a/src/main/msp/msp.c +++ b/src/main/msp/msp.c @@ -1005,6 +1005,15 @@ static bool mspCommonProcessOutCommand(int16_t cmdMSP, sbuf_t *dst, mspPostProce break; } + case MSP_EXPERIMENTAL: + /* + * Send your experimental parameters to LUA. Like: + * + * sbufWriteU8(dst, currentPidProfile->yourFancyParameterA); + * sbufWriteU8(dst, currentPidProfile->yourFancyParameterB); + */ + break; + default: return false; } @@ -3523,6 +3532,17 @@ static mspResult_e mspCommonProcessInCommand(mspDescriptor_t srcDesc, int16_t cm break; #endif // OSD + case MSP_SET_EXPERIMENTAL: + /* + * Receive your experimental parameters from LUA. Like: + * + * if (sbufBytesRemaining(src) >= 2) { + * currentPidProfile->yourFancyParameterA = sbufReadU8(src); + * currentPidProfile->yourFancyParameterB = sbufReadU8(src); + * } + */ + break; + default: return mspProcessInCommand(srcDesc, cmdMSP, src); } diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 32dd32204f..6545eea8c0 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -194,6 +194,9 @@ #define MSP_LED_STRIP_SETTINGS 150 #define MSP_SET_LED_STRIP_SETTINGS 151 +#define MSP_EXPERIMENTAL 158 +#define MSP_SET_EXPERIMENTAL 159 + #define MSP_UID 160 #define MSP_GPSSVINFO 164