diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 42299e074..b0f092329 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -4262,5 +4262,17 @@ }, "BLACKBOX_FEATURE_MOTORS": { "message": "Motors output" + }, + "axisRoll": { + "message": "Roll" + }, + "axisPitch": { + "message": "Pitch" + }, + "axisYaw": { + "message": "Yaw" + }, + "showAdvancedPIDs": { + "message": "Show advanced PID controllers" } } diff --git a/gulpfile.js b/gulpfile.js index 661b95d6f..992ca9713 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -52,7 +52,7 @@ sources.css = [ './js/libraries/jbox/jBox.css', './node_modules/openlayers/dist/ol.css', './src/css/logic.css', - './src/css/defaults_dialog.css' + './src/css/defaults_dialog.css', ]; sources.js = [ @@ -133,7 +133,7 @@ sources.js = [ './js/waypointCollection.js', './js/waypoint.js', './node_modules/openlayers/dist/ol.js', - './js/libraries/plotly-latest.min.js' + './js/libraries/plotly-latest.min.js', ]; sources.receiverCss = [ diff --git a/js/helpers.js b/js/helpers.js index 25ff1baef..d45a22639 100644 --- a/js/helpers.js +++ b/js/helpers.js @@ -57,4 +57,10 @@ function generateFilename(prefix, suffix) { + zeroPad(date.getSeconds(), 2); return filename + '.' + suffix; +} + +function scaleRangeInt(x, srcMin, srcMax, destMin, destMax) { + let a = (destMax - destMin) * (x - srcMin); + let b = srcMax - srcMin; + return Math.round((a / b) + destMin); } \ No newline at end of file diff --git a/main.css b/main.css index 33f54e7de..1c13dbf81 100644 --- a/main.css +++ b/main.css @@ -2274,5 +2274,5 @@ ol li { } .controlProfileHighlightActive { - background-color: #d5ebfe; + background-color: #d5ebfe !important ; } diff --git a/package-lock.json b/package-lock.json index 898533667..935cc5ada 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4272,6 +4272,11 @@ "remove-trailing-separator": "^1.0.1" } }, + "nouislider": { + "version": "15.6.0", + "resolved": "https://registry.npmjs.org/nouislider/-/nouislider-15.6.0.tgz", + "integrity": "sha512-YJg+A6RQXTuFqhEwd42FeRaEGMGgDSSNnpIyVtT8XJrNl4VBEUkPI6Yj91bT3JjJIvNYi4VdppWeCV+z2gOnnw==" + }, "now-and-later": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.1.tgz", diff --git a/src/css/tabs/pid_tuning.css b/src/css/tabs/pid_tuning.css index 2b00ad870..fb744c920 100644 --- a/src/css/tabs/pid_tuning.css +++ b/src/css/tabs/pid_tuning.css @@ -395,3 +395,54 @@ .settings-table tbody { /* background: #D6D6D6 linear-gradient(-45deg, rgba(255, 255, 255, .2) 10%, transparent 10%, transparent 20%, rgba(255, 255, 255, .2) 20%, rgba(255, 255, 255, .2) 30%, transparent 30%, transparent 40%, rgba(255, 255, 255, .2) 40%, rgba(255, 255, 255, .2) 50%, transparent 50%, transparent 60%, rgba(255, 255, 255, .2) 60%, rgba(255, 255, 255, .2) 70%, transparent 70%, transparent 80%, rgba(255, 255, 255, .2) 80%, rgba(255, 255, 255, .2) 90%, transparent 90%, transparent 100%, rgba(255, 255, 255, .2) 100%, transparent); */ } + +.pid-slider-row { + display: flex; + padding: 4px; +} + +.pid-slider-row span { + margin-right: 2em; + width: 120px; + line-height: 22px;; +} + +.pid-slider-row input[type="number"] { + font-family: 'open_sansregular', 'Segoe UI', Tahoma, sans-serif; + background-color: #fff; + border: 1px solid #ccc; + font-size: 0.95em; + border-radius: 3px; + padding: 0.3em; + margin-right: 2em; +} + +.pid-slider-row input[type="range"] { + display: block; + flex-grow: 100; +} + +.pid-sliders-axis { + padding: 0.5em; + margin-bottom: 1em; +} + +.pid-sliders-axis h3 { + padding: 4px; +} + +.pid-sliders-axis[data-axis="roll"] { + background-color: #afe4fe; +} + +.pid-sliders-axis[data-axis="pitch"] { + background-color: #C4B5FF; +} + +.pid-sliders-axis[data-axis="yaw"] { + background-color: #E6B6F0; +} + +#pid-sliders { + margin-bottom: 1em; +} \ No newline at end of file diff --git a/tabs/pid_tuning.html b/tabs/pid_tuning.html index 352ea50a0..cedfe2e3b 100644 --- a/tabs/pid_tuning.html +++ b/tabs/pid_tuning.html @@ -22,7 +22,99 @@
-@@ -47,7 +139,7 @@ | ||||
@@ -55,7 +147,7 @@ | ||||
diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 0309cc6f2..486090eb3 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -66,9 +66,14 @@ TABS.pid_tuning.initialize = function (callback) { function form_to_pid_and_rc() { $('[data-pid-bank-position]').each(function () { + var $this = $(this), bankPosition = $this.data('pid-bank-position'); + if ($this.hasClass('is-hidden')) { + return; + } + if (PIDs[bankPosition]) { $this.find('input').each(function (index) { PIDs[bankPosition][index] = parseFloat($(this).val()); @@ -157,12 +162,74 @@ TABS.pid_tuning.initialize = function (callback) { pid_and_rc_to_form(); - let $magHoldYawRate = $("#magHoldYawRate"); + let $theOtherPids = $('#the-other-pids'); + let $showAdvancedPids = $('#show-advanced-pids'); + + chrome.storage.local.get('showOtherPids', function (result) { + if (result.showOtherPids) { + $theOtherPids.removeClass("is-hidden"); + $showAdvancedPids.prop('checked', true); + } else { + $theOtherPids.addClass("is-hidden"); + $showAdvancedPids.prop('checked', false); + } + $showAdvancedPids.change(); + }); + + $showAdvancedPids.on('change', function() { + if ($showAdvancedPids.is(':checked')) { + $theOtherPids.removeClass("is-hidden"); + chrome.storage.local.set({ showOtherPids: true }); + } else { + $theOtherPids.addClass("is-hidden"); + chrome.storage.local.set({ showOtherPids: false }); + } + }); + + $(".pid-slider-row [name='value-slider']").on('input', function () { + let val = $(this).val(); + let normalMax = parseInt($(this).data('normal-max')); - $magHoldYawRate.val(INAV_PID_CONFIG.magHoldRateLimit); + if (val <= 800) { + val = scaleRangeInt(val, 0, 800, 0, normalMax); + } else { + val = scaleRangeInt(val, 801, 1000, normalMax + 1, 255); + } + + $(this).parent().find('input[name="value-input"]').val(val); + PIDs[$(this).parent().data('axis')][$(this).parent().data('bank')] = val; + }); - $magHoldYawRate.change(function () { - INAV_PID_CONFIG.magHoldRateLimit = parseInt($magHoldYawRate.val(), 10); + $(".pid-slider-row [name='value-input']").on('change', function () { + let val = $(this).val(); + let newVal; + let normalMax = parseInt($(this).parent().find('input[name="value-slider"]').data('normal-max')); + + if (val <= 110) { + newVal = scaleRangeInt(val, 0, normalMax, 0, 800); + } else { + newVal = scaleRangeInt(val, normalMax + 1, 255, 801, 1000); + } + + $(this).parent().find('input[name="value-slider"]').val(newVal); + PIDs[$(this).parent().data('axis')][$(this).parent().data('bank')] = $(this).val(); + }); + + let axis = 0; + $('#pid-sliders').find('.pid-sliders-axis').each(function () { + + let $this = $(this); + let bank = 0; + + $this.find('.pid-slider-row').each(function () { + let $this = $(this); + $this.data('axis', axis); + $this.data('bank', bank); + $this.find('input[name="value-input"]').val(PIDs[axis][bank]).trigger('change'); + bank++; + }); + + axis++; }); if (!FC.isRpyFfComponentUsed()) { |