From f3a8bc46bc91e14e5a7c8a74980990f194111c6b Mon Sep 17 00:00:00 2001 From: Jesus Lopez Garcia Date: Sat, 23 Sep 2023 16:25:06 +0200 Subject: [PATCH] Add configuration to enable/disable VTX MSP. Default: disabled --- config/goggles/config.json | 3 ++- config/goggles/schema.json | 4 ++++ config/goggles/schemaV2.json | 11 ++++++++++- config/goggles/uiSchemaV2.json | 5 ++++- jni/util/vtx_manager.c | 7 ++++++- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/config/goggles/config.json b/config/goggles/config.json index 5529de8..34ba612 100644 --- a/config/goggles/config.json +++ b/config/goggles/config.json @@ -10,5 +10,6 @@ "fakehd_columns": "S", "fakehd_rows": "WWWWWWCCWWWWWWWD", "rec_enabled": true, - "rec_pb_enabled": true + "rec_pb_enabled": true, + "vtx_msp": false } diff --git a/config/goggles/schema.json b/config/goggles/schema.json index 4127e4e..4477c81 100644 --- a/config/goggles/schema.json +++ b/config/goggles/schema.json @@ -60,6 +60,10 @@ "hide_diagnostics": { "name": "Hide diagnostic information", "widget": "checkbox" + }, + "vtx_msp": { + "name": "Enable VTX MSP", + "widget": "checkbox" } }, "units": [ diff --git a/config/goggles/schemaV2.json b/config/goggles/schemaV2.json index 8c6f246..a25c206 100644 --- a/config/goggles/schemaV2.json +++ b/config/goggles/schemaV2.json @@ -58,7 +58,16 @@ true, false ] - } + }, + "vtx_msp": { + "type": "boolean", + "title": "Enable VTX MSP", + "description": "Control video channel from Betaflight or ELRS Lua script VTX admin", + "enum": [ + true, + false + ] + } }, "dependencies": { "fakehd_enable": { diff --git a/config/goggles/uiSchemaV2.json b/config/goggles/uiSchemaV2.json index 5184fb8..12735de 100644 --- a/config/goggles/uiSchemaV2.json +++ b/config/goggles/uiSchemaV2.json @@ -31,5 +31,8 @@ }, "fakehd_rows": { "ui:help": "FakeHD row alignment config, each character configures the alignment for one row. [Read more](https://github.com/fpv-wtf/msp-osd#customising-the-default-fakehd-grid)" - } + }, + "vtx_msp": { + "ui:help": "Enable VTX MSP protocol to control the video channel from Betaflight or ELRS Lua script VTX admin" + }, } \ No newline at end of file diff --git a/jni/util/vtx_manager.c b/jni/util/vtx_manager.c index 9d04c03..ed78c57 100644 --- a/jni/util/vtx_manager.c +++ b/jni/util/vtx_manager.c @@ -1,8 +1,9 @@ #include #include +#include "json/osd_config.h" #include "util/debug.h" - +#define VTX_MPS_CONFIG_KEY "vtx_msp" static void *tp1801_gui_lib = NULL; static uint32_t (* setChannelPilotOriginal)(void *this,unsigned short param_1, bool param_2) = 0; @@ -11,6 +12,10 @@ static uint32_t userSettingsInstance = 0; static int8_t currentChannel = -1; void changeChannel(int8_t channel) { + if(!get_boolean_config_value(VTX_MPS_CONFIG_KEY)) { + return; + } + //Load SetPilotChannel original setChannelPilotOriginal = dlsym (RTLD_NEXT, "_ZN17GlassUserSettings15setPilotChannelEtb"); if (setChannelPilotOriginal == NULL) {