From a204d730bbd8c7d900b30bddd225dcb988d9f7ec Mon Sep 17 00:00:00 2001 From: Bas Delfos Date: Wed, 31 Jan 2018 23:06:04 +0100 Subject: [PATCH] Added DSHOT beacon configuration --- locales/en/messages.json | 9 +++++++ src/js/fc.js | 1 + src/js/msp/MSPHelper.js | 6 +++++ src/js/tabs/configuration.js | 33 +++++++++++++++++++++++- src/tabs/configuration.html | 49 +++++++++++++++++++++++++++++++++++- 5 files changed, 96 insertions(+), 2 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index b08d66f5..961269ac 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -919,6 +919,15 @@ "configurationThrottleMinimumCommandHelp": { "message": "This is the value that is sent to the ESCs when the craft is disarmed. Set this to a value that has the motors stopped (1000 for most ESCs)." }, + "configurationDshotBeeper": { + "message": "DSHOT Beacon Configuration" + }, + "configurationUseDshotBeeper": { + "message": "Use DSHOT beacon (use motors to sound beeps when disarmed)" + }, + "configurationDshotBeaconTone": { + "message": "Beacon Tone" + }, "configurationBeeper": { "message": "Beeper Configuration" }, diff --git a/src/js/fc.js b/src/js/fc.js index d87ca9bd..a8f8a5de 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -104,6 +104,7 @@ var FC = { BEEPER_CONFIG = { beepers: 0, + dshotBeaconTone: 0, }; MIXER_CONFIG = { diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index eaa4dd51..3ef82f0c 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -602,6 +602,9 @@ MspHelper.prototype.process_data = function(dataHandler) { case MSPCodes.MSP_BEEPER_CONFIG: BEEPER_CONFIG.beepers.setMask(data.readU32()); + if (semver.gte(CONFIG.apiVersion, "1.37.0")) { + BEEPER_CONFIG.dshotBeaconTone = data.readU8(); + } break; case MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG: @@ -1201,6 +1204,9 @@ MspHelper.prototype.crunch = function(code) { case MSPCodes.MSP_SET_BEEPER_CONFIG: var beeperMask = BEEPER_CONFIG.beepers.getMask(); buffer.push32(beeperMask); + if (semver.gte(CONFIG.apiVersion, "1.37.0")) { + buffer.push8(BEEPER_CONFIG.dshotBeaconTone ); + } break; case MSPCodes.MSP_SET_MIXER_CONFIG: buffer.push8(MIXER_CONFIG.mixer) diff --git a/src/js/tabs/configuration.js b/src/js/tabs/configuration.js index 5968b49a..032cb01e 100644 --- a/src/js/tabs/configuration.js +++ b/src/js/tabs/configuration.js @@ -235,7 +235,38 @@ TABS.configuration.initialize = function (callback, scrollPosition) { FEATURE_CONFIG.features.generateElements(features_e); - // Beeper + // Dshot Beeper + var dshotBeeper_e = $('.tab-configuration .dshotbeeper'); + var dshotBeacon_e = $('.tab-configuration .dshotbeacon'); + var dshotBeeperSwitch = $('#dshotBeeperSwitch'); + var dshotBeeperBeaconTone = $('#dshotBeeperBeaconTone'); + + dshotBeeperSwitch.change(function() { + if ($(this).is(':checked')) { + dshotBeacon_e.show(); + if (dshotBeeperBeaconTone.val() == 0) { + dshotBeeperBeaconTone.val(1).change(); + } + } else { + dshotBeeperBeaconTone.val(0).change(); + dshotBeacon_e.hide(); + } + }); + + dshotBeeperBeaconTone.change(function() { + BEEPER_CONFIG.dshotBeaconTone = dshotBeeperBeaconTone.val(); + }); + + dshotBeeperBeaconTone.val(BEEPER_CONFIG.dshotBeaconTone); + dshotBeeperSwitch.prop('checked', BEEPER_CONFIG.dshotBeaconTone !== 0).change(); + + if (semver.gte(CONFIG.apiVersion, "1.37.0")) { + dshotBeeper_e.show(); + } else { + dshotBeeper_e.hide(); + } + + // Analog Beeper var template = $('.beepers .beeper-template'); var destination = $('.beepers .beeper-configuration'); var beeper_e = $('.tab-configuration .beepers'); diff --git a/src/tabs/configuration.html b/src/tabs/configuration.html index f87c1c55..287b3e25 100644 --- a/src/tabs/configuration.html +++ b/src/tabs/configuration.html @@ -674,9 +674,56 @@ + + + + + + + +
+
+
+
+
+
+ + + + + + + + + +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+
+ + + - +