Skip to content

Commit

Permalink
JogVelocityHandler: added support for proportional values
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Roessler authored and machinekoder committed Nov 29, 2015
1 parent d17fd62 commit b0f4d55
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/applicationcontrols/JogVelocityHandler.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ import Machinekit.Application 1.0

ApplicationObject {
property int axis: 0
readonly property string units: distanceUnits + "/" + timeUnits
readonly property string units: proportional ? "%" : distanceUnits + "/" + timeUnits
readonly property string distanceUnits: getDistanceUnits()
readonly property string timeUnits: getTimeUnits()
readonly property double displayValue: value * _timeFactor
property double value: 0
property double minimumValue: 0
property double maximumValue: 100
property bool proportional: false
property double minimumProportion: 0.0
property bool enabled: _ready
property bool synced: false

Expand All @@ -41,7 +43,12 @@ ApplicationObject {

onValueChanged: {
if (_ready && !_remoteUpdate) {
settings.setValue("axis" + axis + ".jogVelocity", value)
var velocity = value
if (proportional) {
velocity /= 100.0
velocity *= maximumValue
}
settings.setValue("axis" + axis + ".jogVelocity", velocity)
synced = false
}
}
Expand Down Expand Up @@ -85,8 +92,15 @@ ApplicationObject {
} else {
maximumValue = axisMaxVel
}
minimumProportion = (minimumValue / maximumValue) * 100.0

var tmpValue = settings.value("axis" + axis + ".jogVelocity")
tmpValue = Math.max(Math.min(tmpValue, maximumValue), minimumValue) // clamp value
if (proportional) {
tmpValue /= maximumValue
tmpValue *= 100.0
}

if (value !== tmpValue) {
value = tmpValue
}
Expand Down

0 comments on commit b0f4d55

Please sign in to comment.