Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make scrolling wheel on actuator test not be a significant increment #12130

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this piece of code since it assumes there is at least 1 actuator, and that all actuators have the same minimum and maximum. I am open to suggestions on how this could be improved

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that all having the same minimum and maximum is always the same now that I think about it since the Mavlink message sent to do the actuator test only allows a value from 0 to 1.

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) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you scroll down to the point of deactivating the actuator test, the value becomes a NAN (as suggested by onActuatorValueChanged above these changes). Whenever I scrolled back up, instead of having NAN it would be a negative value of -0.16. Since the minimum I have seen has always been 0.0 I interpreted that as NAN, but would be open to suggestions on how to do this better.

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);
}
}
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are the same to those above, just on different actuator sliders.

}
} // Repeater
} // Row
Expand Down
Loading