diff --git a/src/css/tabs/pid_tuning.less b/src/css/tabs/pid_tuning.less index a4764cfa6ab..c10cf8c6faa 100644 --- a/src/css/tabs/pid_tuning.less +++ b/src/css/tabs/pid_tuning.less @@ -732,6 +732,7 @@ } } .slidersWarning { + text-align: center; background: #ffa3a3; border: 1px solid red; font-weight: 600; diff --git a/src/js/tabs/motors.js b/src/js/tabs/motors.js index 4987f52f9d0..8915bbbcf69 100644 --- a/src/js/tabs/motors.js +++ b/src/js/tabs/motors.js @@ -898,12 +898,13 @@ motors.initialize = async function (callback) { setSlidersDefault(); const ignoreKeys = [ - 'PageUp', - 'PageDown', - 'End', - 'Home', - 'ArrowUp', - 'ArrowDown', + 33, // Page Up + 34, // Page Down + 35, // End + 36, // Home + 38, // Arrow Up + 40, // Arrow Down + 18, // Alt / Opt ]; motorsEnableTestModeElement.on('change', function () { @@ -921,7 +922,7 @@ motors.initialize = async function (callback) { function disableMotorTest(e) { if (motorsEnableTestModeElement.is(':checked')) { - if (!ignoreKeys.includes(e.code)) { + if (!ignoreKeys.includes(e.which)) { motorsEnableTestModeElement.prop('checked', false).trigger('change'); document.removeEventListener('keydown', evt => disableMotorTest(evt)); } @@ -978,6 +979,10 @@ motors.initialize = async function (callback) { } }); + $('div.sliders input:not(.master)').on('input wheel', function (e) { + self.scrollSlider($(this), e); + }); + $('div.sliders input.master').on('input', function () { const val = $(this).val(); @@ -986,6 +991,10 @@ motors.initialize = async function (callback) { $('div.sliders input:not(:last):first').trigger('input'); }); + $('div.sliders input.master').on('input wheel', function (e) { + self.scrollSlider($(this), e); + }); + // check if motors are already spinning let motorsRunning = false; @@ -1316,6 +1325,25 @@ motors.cleanup = function (callback) { if (callback) callback(); }; +motors.scrollSlider = function(slider, e) { + if (slider.prop('disabled')) { + return; + } + + if (!(e.originalEvent?.deltaY && e.originalEvent?.altKey)) { + return; + } + + e.preventDefault(); + + const step = 25; + const delta = e.originalEvent.deltaY > 0 ? -step : step; + const val = parseInt(slider.val()) + delta; + const roundedVal = Math.round(val / step) * step; + slider.val(roundedVal); + slider.trigger('input'); +}; + TABS.motors = motors; export { motors, diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index d974d61746f..b12ae1a7820 100644 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -2021,6 +2021,10 @@ pid_tuning.initialize = function (callback) { self.analyticsChanges['PidTuningSliders'] = "On"; }); + allPidTuningSliders.each(function (i) { + self.sliderOnScroll($(this)); + }); + // reset to middle with double click allPidTuningSliders.dblclick(function() { const slider = $(this); @@ -2118,6 +2122,10 @@ pid_tuning.initialize = function (callback) { } }); + allFilterTuningSliders.each(function() { + self.sliderOnScroll($(this)); + }); + // reset to middle with double click allFilterTuningSliders.dblclick(function() { const slider = $(this); @@ -2970,6 +2978,29 @@ pid_tuning.expertModeChanged = function(expertModeEnabled) { TuningSliders.setExpertMode(expertModeEnabled); }; +pid_tuning.sliderOnScroll = function(slider, e) { + slider.parent().on('input wheel', function(e) { + if (slider.prop('disabled')) { + return; + } + + if (!(e.originalEvent?.deltaY && e.originalEvent?.altKey)) { + return; + } + + e.preventDefault(); + + const step = parseFloat(slider.attr('step')); + const delta = e.originalEvent.deltaY > 0 ? -step : step; + const preScrollSliderValue = isInt(slider.val()) ? parseInt(slider.val()) : parseFloat(slider.val()); + const sliderValue = (Math.floor(preScrollSliderValue * 100) + Math.floor(delta * 100)) / 100; + + slider.val(sliderValue); + slider.trigger('input'); + slider.trigger('change'); + }); +}; + TABS.pid_tuning = pid_tuning; export { pid_tuning, diff --git a/src/tabs/pid_tuning.html b/src/tabs/pid_tuning.html index a17d22a4c8a..dba638d04db 100644 --- a/src/tabs/pid_tuning.html +++ b/src/tabs/pid_tuning.html @@ -66,9 +66,6 @@

-
-

-
+ +
+

+

@@ -1183,9 +1184,6 @@

-
-

-
@@ -1255,6 +1253,10 @@
+
+

+
+