diff --git a/jni/osd_dji_overlay_udp.c b/jni/osd_dji_overlay_udp.c index 93b9e74..7367e67 100644 --- a/jni/osd_dji_overlay_udp.c +++ b/jni/osd_dji_overlay_udp.c @@ -79,6 +79,9 @@ typedef enum #define BACK_BUTTON_DELAY 4 +#define VTX_MPS_CONFIG_KEY "vtx_msp" +static u_int8_t vtx_manager_enabled; + #define SWAP32(data) \ ( (((data) >> 24) & 0x000000FF) | (((data) >> 8) & 0x0000FF00) | \ (((data) << 8) & 0x00FF0000) | (((data) << 24) & 0xFF000000) ) @@ -496,7 +499,9 @@ static void process_data_packet(uint8_t *buf, int len, dji_shm_state_t *radio_sh snprintf(str, 8, "A %2.1fV", packet->tx_voltage / 64.0f); display_print_string(overlay_display_info.char_width - 7, overlay_display_info.char_height - 7, str, 7); } - changeChannel(packet->fc_vtx_channel); + if(vtx_manager_enabled == 1) { + changeChannel(packet->fc_vtx_channel); + } if(len > 6) { DEBUG_PRINT("Got new packet with variant %.4s\n", packet->fc_variant); // should have FC type @@ -755,6 +760,9 @@ void osd_directfb(duss_disp_instance_handle_t *disp, duss_hal_obj_handle_t ion_h int compression_dict_size = 0; void *compression_dict = open_dict(DICTIONARY_VERSION, &compression_dict_size); + vtx_manager_enabled = get_boolean_config_value(VTX_MPS_CONFIG_KEY); + setupVTXManager(); + uint64_t event_number; while (!quit) { diff --git a/jni/util/vtx_manager.c b/jni/util/vtx_manager.c index b5f2237..35a61b3 100644 --- a/jni/util/vtx_manager.c +++ b/jni/util/vtx_manager.c @@ -1,10 +1,8 @@ #include #include -#include "json/osd_config.h" #include "util/debug.h" #include "vtx_manager.h" -#define VTX_MPS_CONFIG_KEY "vtx_msp" #define CHANNEL_PUBLIC 8 static void *tp1801_gui_lib = NULL; @@ -14,7 +12,11 @@ static uint32_t userSettingsInstance = 0; static __gs_gui_config *gs_gui_config = 0; static int8_t currentChannel = -1; -void setupManager() { +void setupVTXManager() { + if(setChannelPilotOriginal != NULL) { + return; + } + //Load SetPilotChannel original setChannelPilotOriginal = dlsym (RTLD_NEXT, "_ZN17GlassUserSettings15setPilotChannelEtb"); if (setChannelPilotOriginal == NULL) { @@ -46,12 +48,6 @@ void setupManager() { } void changeChannel(int8_t channel) { - if(!get_boolean_config_value(VTX_MPS_CONFIG_KEY)) { - return; - } - - setupManager(); - if (channel <= 0 || channel > 8) { printf("VTX_MANAGER Error:, invalid channel index: %d\n", channel); return; @@ -70,4 +66,4 @@ void changeChannel(int8_t channel) { int8_t channelIdx = channel - 1; setChannelPilotOriginal(userSettingsGetInstanceOriginal(), channelIdx, true); } -} \ No newline at end of file +}