Skip to content

Commit

Permalink
Make scrolling wheel on actuator test not be a significant increment
Browse files Browse the repository at this point in the history
  • Loading branch information
av-stefan committed Nov 23, 2024
1 parent fb11f31 commit a3bcebf
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions src/AutoPilotPlugins/PX4/ActuatorComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -257,24 +257,61 @@ SetupPage {
}
}
}
WheelHandler {
onWheel: (event) => { // Capture the event object
let minimum = sliderRepeater.itemAt(0).channel.min;
let maximum = sliderRepeater.itemAt(0).channel.max;
let stepSize = (maximum - minimum) * 0.01;

const NAN_THRESHOLD = -0.1;
if (value < NAN_THRESHOLD && event.angleDelta.y > 0) {
value = stepSize;
} else {
let newValue = value + event.angleDelta.y / 120 * stepSize;
if (newValue < 0) {
value = NaN;
} else {
value = Math.min(maximum, newValue);
}
}
}
}
}
}

// all channels
Repeater {
id: sliderRepeater
model: actuators.actuatorTest.actuators

ActuatorSlider {
channel: object
onActuatorValueChanged: (value) =>{
onActuatorValueChanged: (value) => {
if (isNaN(value)) {
actuators.actuatorTest.stopControl(index);
stop();
} else {
actuators.actuatorTest.setChannelTo(index, value);
}
}
WheelHandler {
onWheel: (event) => {
let minimum = channel.min;
let maximum = channel.max;
let stepSize = (maximum - minimum) * 0.01;

const NAN_THRESHOLD = -0.1;
if (value < NAN_THRESHOLD && event.angleDelta.y > 0) {
value = stepSize;
} else {
let newValue = value + event.angleDelta.y / 120 * stepSize;
if (newValue < 0) {
value = NaN;
} else {
value = Math.min(maximum, newValue);
}
}
}
}
}
} // Repeater
} // Row
Expand Down

0 comments on commit a3bcebf

Please sign in to comment.