From 892640e35f712dc53f227b8438eb4c0943756b33 Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Sat, 24 Nov 2018 20:07:25 -0500 Subject: [PATCH] Add throttle limit to PID Tuning tab --- locales/en/messages.json | 21 +++++++++++++++++++++ src/css/tabs/pid_tuning.css | 27 +++++++++++++++++++++++++++ src/js/msp/MSPHelper.js | 8 ++++++++ src/js/tabs/pid_tuning.js | 13 +++++++++++++ src/tabs/pid_tuning.html | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+) diff --git a/locales/en/messages.json b/locales/en/messages.json index d3e55eb9..da485e5d 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1440,6 +1440,27 @@ "pidTuningTPABreakPoint": { "message": "TPA Breakpoint" }, + "pidTuningThrottleLimitType": { + "message": "Throttle Limit" + }, + "pidTuningThrottleLimitPercent": { + "message": "Throttle Limit %" + }, + "pidTuningThrottleLimitTypeOff": { + "message": "OFF" + }, + "pidTuningThrottleLimitTypeScale": { + "message": "SCALE" + }, + "pidTuningThrottleLimitTypeClip": { + "message": "CLIP" + }, + "pidTuningThrottleLimitTypeTip": { + "message": "Select the type of throttle limiting. OFF disables the feature, SCALE will transform the throttle range from 0 to the selected percentage using the full stick travel, CLIP will set a max throttle percentage and stick travel above that will have no additional effect" + }, + "pidTuningThrottleLimitPercentTip": { + "message": "Set the desired throttle limit percentage. Setting to 100% disables the feature." + }, "pidTuningFilter": { "message": "Filter" }, diff --git a/src/css/tabs/pid_tuning.css b/src/css/tabs/pid_tuning.css index e6352152..90d3b106 100644 --- a/src/css/tabs/pid_tuning.css +++ b/src/css/tabs/pid_tuning.css @@ -8,6 +8,16 @@ text-align: left; } +.tab-pid_tuning .throttle_limit th { + background-color: #828885; + padding: 4px; + border-left: 0px solid #ccc; + border-bottom: 1px solid #ccc; + font-weight: bold; + color: white; + text-align: left; +} + .tab-pid_tuning .cf tr { background-color: #DEDEDE; } @@ -178,6 +188,18 @@ border-top-right-radius: 3px; } +.tab-pid_tuning .throttle_limit th:nth-child(2) { + border-top-left-radius: 3px; +} + +.tab-pid_tuning .throttle_limit th:first-child { + border-top-left-radius: 3px; +} + +.tab-pid_tuning .throttle_limit th:last-child { + border-top-right-radius: 3px; +} + .tab-pid_tuning .rc_curve { float: right; width: calc(100% - 2px); /* - ( "virtual" margin) */ @@ -437,6 +459,11 @@ width: calc(100% - 2px); /* - ( "virtual" margin) */ } +.tab-pid_tuning .throttle_limit { + float: right; + width: calc(100% - 2px); /* - ( "virtual" margin) */ +} + .tab-pid_tuning .top-buttons { float: right; } diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 8efeeb5e..42793544 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -320,6 +320,10 @@ MspHelper.prototype.process_data = function(dataHandler) { RC_tuning.rcPitchRate = 0; RC_tuning.RC_PITCH_EXPO = 0; } + if (semver.gte(CONFIG.apiVersion, "1.41.0")) { + RC_tuning.throttleLimitType = data.readU8(); + RC_tuning.throttleLimitPercent = data.readU8(); + } break; case MSPCodes.MSP_PID: // PID data arrived, we need to scale it and save to appropriate bank / array @@ -1347,6 +1351,10 @@ MspHelper.prototype.crunch = function(code) { buffer.push8(Math.round(RC_tuning.rcPitchRate * 100)); buffer.push8(Math.round(RC_tuning.RC_PITCH_EXPO * 100)); } + if (semver.gte(CONFIG.apiVersion, "1.41.0")) { + buffer.push8(RC_tuning.throttleLimitType); + buffer.push8(RC_tuning.throttleLimitPercent); + } break; case MSPCodes.MSP_SET_RX_MAP: for (var i = 0; i < RC_MAP.length; i++) { diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index bd734399..5633ff24 100644 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -308,6 +308,13 @@ TABS.pid_tuning.initialize = function (callback) { $('.antigravity table td:first-child').hide(); } + if (semver.gte(CONFIG.apiVersion, "1.41.0")) { + $('select[id="throttleLimitType"]').val(RC_tuning.throttleLimitType); + $('.throttle_limit input[name="throttleLimitPercent"]').val(RC_tuning.throttleLimitPercent); + } else { + $('.throttle_limit').hide(); + } + $('input[id="gyroNotch1Enabled"]').change(function() { var checked = $(this).is(':checked'); var hz = FILTER_CONFIG.gyro_notch_hz > 0 ? FILTER_CONFIG.gyro_notch_hz : DEFAULT.gyro_notch_hz; @@ -520,6 +527,12 @@ TABS.pid_tuning.initialize = function (callback) { ADVANCED_TUNING.antiGravityMode = $('select[id="antiGravityMode"]').val(); } + + if (semver.gte(CONFIG.apiVersion, "1.41.0")) { + RC_tuning.throttleLimitType = $('select[id="throttleLimitType"]').val(); + RC_tuning.throttleLimitPercent = parseInt($('.throttle_limit input[name="throttleLimitPercent"]').val()); + } + } function showAllPids() { diff --git a/src/tabs/pid_tuning.html b/src/tabs/pid_tuning.html index 8a809646..151e1ef1 100644 --- a/src/tabs/pid_tuning.html +++ b/src/tabs/pid_tuning.html @@ -582,6 +582,39 @@ +
+ + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+ + +
+