From c2575935fcb8156c837df0d4666de1a6c73505fb Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Thu, 6 Feb 2020 15:12:13 +1300 Subject: [PATCH] Added bind button for receivers that support it. --- locales/en/messages.json | 3 +++ src/js/fc.js | 1 + src/js/msp/MSPCodes.js | 5 ++++- src/js/tabs/receiver.js | 10 ++++++++++ src/tabs/receiver.html | 3 +++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 6885bc36..f981158a 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1952,6 +1952,9 @@ "receiverButtonRefresh": { "message": "Refresh" }, + "receiverButtonBind": { + "message": "Bind Receiver" + }, "receiverButtonSticks": { "message": "Control sticks" }, diff --git a/src/js/fc.js b/src/js/fc.js index 2544ad8c..a51548e2 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -633,6 +633,7 @@ var FC = { HAS_FLASH_BOOTLOADER: 3, SUPPORTS_CUSTOM_DEFAULTS: 4, HAS_CUSTOM_DEFAULTS: 5, + SUPPORTS_RX_BIND: 6, }, boardHasVcp: function () { diff --git a/src/js/msp/MSPCodes.js b/src/js/msp/MSPCodes.js index e8c50e8e..7c04137f 100644 --- a/src/js/msp/MSPCodes.js +++ b/src/js/msp/MSPCodes.js @@ -173,7 +173,10 @@ var MSPCodes = { MSP_DEBUGMSG: 253, // Not used MSP_DEBUG: 254, - // MSPv2 + // MSPv2 Common MSP2_COMMON_SERIAL_CONFIG: 0x1009, MSP2_COMMON_SET_SERIAL_CONFIG: 0x100A, + + // MSPv2 Betaflight specific + MSP2_BETAFLIGHT_BIND: 0x3000, }; diff --git a/src/js/tabs/receiver.js b/src/js/tabs/receiver.js index e1e3788b..d7d2ea2a 100644 --- a/src/js/tabs/receiver.js +++ b/src/js/tabs/receiver.js @@ -325,6 +325,16 @@ TABS.receiver.initialize = function (callback) { }); }); + let showBindButton = false; + if (semver.gte(CONFIG.apiVersion, "1.43.0")) { + showBindButton = bit_check(CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.SUPPORTS_RX_BIND); + + $("a.bind").click(function() { + MSP.send_message(MSPCodes.MSP2_BETAFLIGHT_BIND); + }); + } + $(".bind_btn").toggle(showBindButton); + // RC Smoothing if (semver.gte(CONFIG.apiVersion, "1.40.0")) { $('.tab-receiver .rcSmoothing').show(); diff --git a/src/tabs/receiver.html b/src/tabs/receiver.html index fc66e29a..e364d789 100644 --- a/src/tabs/receiver.html +++ b/src/tabs/receiver.html @@ -315,6 +315,9 @@
+
+ +