-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.