diff --git a/src/components/widgets/toolhead/ExtruderMoves.vue b/src/components/widgets/toolhead/ExtruderMoves.vue index a45f52d388..5298432ec4 100644 --- a/src/components/widgets/toolhead/ExtruderMoves.vue +++ b/src/components/widgets/toolhead/ExtruderMoves.vue @@ -31,7 +31,7 @@ {{ $t('app.general.btn.retract') }} $chevronUp @@ -68,7 +68,7 @@ {{ $t('app.general.btn.extrude') }} $chevronDown @@ -136,19 +136,15 @@ export default class ExtruderMoves extends Mixins(StateMixin, ToolheadMixin) { return this.$rules.numberLessThanOrEqual(this.maxExtrudeSpeed)(value) } - sendRetractGcode (amount: number, rate: number, wait?: string) { + retract () { if (this.valid) { - const gcode = `M83 -G1 E-${amount} F${rate * 60}` - this.sendGcode(gcode, wait) + this.sendExtrudeGcode(-this.extrudeLength, this.extrudeSpeed, this.$waits.onExtrude) } } - sendExtrudeGcode (amount: number, rate: number, wait?: string) { + extrude () { if (this.valid) { - const gcode = `M83 -G1 E${amount} F${rate * 60}` - this.sendGcode(gcode, wait) + this.sendExtrudeGcode(this.extrudeLength, this.extrudeSpeed, this.$waits.onExtrude) } } diff --git a/src/components/widgets/toolhead/ToolheadControlBarsAxis.vue b/src/components/widgets/toolhead/ToolheadControlBarsAxis.vue index 5075c242f3..c6e83ab71e 100644 --- a/src/components/widgets/toolhead/ToolheadControlBarsAxis.vue +++ b/src/components/widgets/toolhead/ToolheadControlBarsAxis.vue @@ -9,14 +9,14 @@ color="primary" :disabled="!klippyReady || printerPrinting || !homed" class="d-flex" - @click="sendMoveGcode($event)" + @click="moveBy($event)" > diff --git a/src/components/widgets/toolhead/ToolheadControlCross.vue b/src/components/widgets/toolhead/ToolheadControlCross.vue index 4f4e6e159e..bc6411f8cb 100644 --- a/src/components/widgets/toolhead/ToolheadControlCross.vue +++ b/src/components/widgets/toolhead/ToolheadControlCross.vue @@ -13,7 +13,7 @@ :color="axisButtonColor(yHomed)" :disabled="axisButtonDisabled(yHomed, yHasMultipleSteppers)" icon="$up" - @click="sendMoveGcode('Y', toolheadMoveLength)" + @click="moveAxisBy('Y', toolheadMoveLength)" /> @@ -39,7 +39,7 @@ :disabled="!klippyReady || (!yHomed && !yForceMove)" :readonly="printerBusy" :value="(useGcodeCoords) ? gcodePosition[1].toFixed(2) : toolheadPosition[1].toFixed(2)" - @change="moveTo('Y', $event)" + @change="moveAxisTo('Y', $event)" @focus="$event.target.select()" /> @@ -58,7 +58,7 @@ :disabled="!klippyReady || (!zHomed && !zForceMove)" :readonly="printerBusy" :value="(useGcodeCoords) ? gcodePosition[2].toFixed(2) : toolheadPosition[2].toFixed(2)" - @change="moveTo('Z', $event)" + @change="moveAxisTo('Z', $event)" @focus="$event.target.select()" /> @@ -159,7 +159,7 @@ export default class ToolheadPosition extends Mixins(StateMixin, ToolheadMixin) this.sendGcode(`G9${value}`) } - moveTo (axis: string, pos: string) { + moveAxisTo (axis: string, pos: string) { const axisIndexMap: any = { X: 0, Y: 1, Z: 2 } const currentPos = (this.useGcodeCoords) ? this.gcodePosition[axisIndexMap[axis]] @@ -174,8 +174,7 @@ export default class ToolheadPosition extends Mixins(StateMixin, ToolheadMixin) : this.$store.state.printer.printer.toolhead.max_accel this.sendGcode(`FORCE_MOVE STEPPER=stepper_${axis.toLowerCase()} DISTANCE=${pos} VELOCITY=${rate} ACCEL=${accel}`) } else { - this.sendGcode(`G90 -G1 ${axis}${pos} F${rate * 60}`) + this.sendMoveGcode(`${axis}${pos}`, rate, true) } } } diff --git a/src/mixins/state.ts b/src/mixins/state.ts index 0e5d23a9d2..49cbebc7d5 100644 --- a/src/mixins/state.ts +++ b/src/mixins/state.ts @@ -99,6 +99,24 @@ export default class StateMixin extends Vue { this.addConsoleEntry(gcode) } + sendMoveGcode (movementGcode: string, rate: number, absolute = false, wait?: string) { + const gcode = `SAVE_GCODE_STATE NAME=_ui_movement +G9${absolute ? 0 : 1} +G1 ${movementGcode} F${rate * 60} +RESTORE_GCODE_STATE NAME=_ui_movement` + + this.sendGcode(gcode, wait) + } + + sendExtrudeGcode (amount: number, rate: number, wait?: string) { + const gcode = `SAVE_GCODE_STATE NAME=_ui_retract +M83 +G1 E${amount} F${rate * 60} +RESTORE_GCODE_STATE NAME=_ui_retract` + + this.sendGcode(gcode, wait) + } + addConsoleEntry (message: string) { this.$store.dispatch('console/onAddConsoleEntry', { message, type: 'command' }) }