From d2ecaedc4bf7e9f666e3884a92a73c36e84893d4 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 28 Mar 2018 15:44:34 +0200 Subject: [PATCH] MSP2 frame for getting and setting new mixer properties --- src/main/fc/fc_msp.c | 17 +++++++++++++++++ src/main/flight/mixer.c | 3 ++- src/main/flight/mixer.h | 1 + src/main/msp/msp_protocol.h | 2 +- src/main/msp/msp_protocol_v2_inav.h | 3 +++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index a65c6f06fe..a45472bf7b 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1295,6 +1295,14 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF #endif break; + case MSP2_INAV_MIXER: + sbufWriteU8(dst, mixerConfig()->yaw_motor_direction); + sbufWriteU16(dst, mixerConfig()->yaw_jump_prevention_limit); + sbufWriteU8(dst, mixerConfig()->platformType); + sbufWriteU8(dst, mixerConfig()->hasFlaps); + sbufWriteU16(dst, mixerConfig()->appliedMixerPreset); + break; + default: return false; } @@ -2368,6 +2376,15 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; + case MSP2_INAV_SET_MIXER: + mixerConfigMutable()->yaw_motor_direction = sbufReadU8(src); + mixerConfigMutable()->yaw_jump_prevention_limit = sbufReadU16(src); + mixerConfigMutable()->platformType = sbufReadU8(src); + mixerConfigMutable()->hasFlaps = sbufReadU8(src); + mixerConfigMutable()->appliedMixerPreset = sbufReadU16(src); + mixerUpdateStateFlags(); + break; + default: return MSP_RESULT_ERROR; } diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 80d4c11f1a..eb80c907c6 100755 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -74,7 +74,8 @@ PG_RESET_TEMPLATE(mixerConfig_t, mixerConfig, .yaw_motor_direction = 1, .yaw_jump_prevention_limit = 200, .platformType = PLATFORM_MULTIROTOR, - .hasFlaps = false + .hasFlaps = false, + appliedMixerPreset = -1 //This flag is not available in CLI and used by Configurator only ); #ifdef BRUSHED_MOTORS diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index 0ee1b289c0..88cf8b06a1 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -59,6 +59,7 @@ typedef struct mixerConfig_s { uint16_t yaw_jump_prevention_limit; // make limit configurable (original fixed value was 100) uint8_t platformType; bool hasFlaps; + int appliedMixerPreset; } mixerConfig_t; PG_DECLARE(mixerConfig_t, mixerConfig); diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index d299f036c1..712f0387f3 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -60,7 +60,7 @@ #define MSP_PROTOCOL_VERSION 0 // Same version over MSPv1 & MSPv2 - message format didn't change and it backward compatible #define API_VERSION_MAJOR 2 // increment when major changes are made -#define API_VERSION_MINOR 1 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR +#define API_VERSION_MINOR 2 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR #define API_VERSION_LENGTH 2 diff --git a/src/main/msp/msp_protocol_v2_inav.h b/src/main/msp/msp_protocol_v2_inav.h index 5f799e3542..be7086d13f 100755 --- a/src/main/msp/msp_protocol_v2_inav.h +++ b/src/main/msp/msp_protocol_v2_inav.h @@ -28,3 +28,6 @@ #define MSP2_INAV_RATE_PROFILE 0x2007 #define MSP2_INAV_SET_RATE_PROFILE 0x2008 #define MSP2_INAV_AIR_SPEED 0x2009 + +#define MSP2_INAV_MIXER 0x2010 +#define MSP2_INAV_SET_MIXER 0x2011