Skip to content

Commit

Permalink
refactor: change from 2 macros to 1 macro (_CLIENT_LINEAR_MOVE)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Dej <[email protected]>
  • Loading branch information
meteyou committed Nov 15, 2024
1 parent e43d727 commit 34ac485
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/components/mixins/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ export default class ControlMixin extends Vue {
})
}

get existsClientAxisMoveMacro() {
get existsClientLinearMoveMacro() {
const macros = this.$store.state.printer?.gcode?.commands ?? {}

return '_CLIENT_AXIS_MOVE' in macros
return '_CLIENT_LINEAR_MOVE' in macros
}

doHome() {
Expand Down Expand Up @@ -160,7 +160,7 @@ export default class ControlMixin extends Vue {
`G1 ${gcode} F${feedrate * 60}\n` +
`RESTORE_GCODE_STATE NAME=_ui_movement`

if (this.existsClientAxisMoveMacro) {
if (this.existsClientLinearMoveMacro) {
gcode = gcode
.split(' ')
.map((part) => {
Expand All @@ -171,7 +171,7 @@ export default class ControlMixin extends Vue {
})
.join(' ')

command = `_CLIENT_AXIS_MOVE ${gcode} F=${feedrate * 60}`
command = `_CLIENT_LINEAR_MOVE ${gcode} F=${feedrate * 60}`
}

this.doSend(command)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ export default class ExtruderControlPanel extends Mixins(BaseMixin, ExtruderMixi
return this.feedamount * this.extrudeFactor > this.maxExtrudeOnlyDistance
}
get existsHelperMacro(): boolean {
get existsClientLinearMoveMacro() {
const macros = this.$store.state.printer?.gcode?.commands ?? {}
return '_CLIENT_EXTRUDER_MOVE' in macros
return '_CLIENT_LINEAR_MOVE' in macros
}
@Watch('maxExtrudeOnlyDistance', { immediate: true })
Expand Down Expand Up @@ -283,8 +283,8 @@ export default class ExtruderControlPanel extends Mixins(BaseMixin, ExtruderMixi
`G1 E${length} F${this.feedrate * 60}\n` +
`RESTORE_GCODE_STATE NAME=_ui_extrude`
if (this.existsHelperMacro) {
gcode = `_CLIENT_EXTRUDER_MOVE E=${length} F=${this.feedrate * 60}`
if (this.existsClientLinearMoveMacro) {
gcode = `_CLIENT_LINEAR_MOVE E=${length} F=${this.feedrate * 60}`
}
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
Expand Down
12 changes: 6 additions & 6 deletions src/components/panels/ToolheadControls/MoveToControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,26 +165,26 @@ export default class MoveToControl extends Mixins(BaseMixin, ControlMixin) {
sendCmd(): void {
let gcode: string[] = []
if (!this.existsClientAxisMoveMacro) {
if (!this.existsClientLinearMoveMacro) {
gcode.push('SAVE_GCODE_STATE NAME=_ui_movement')
gcode.push('G90')
}
if (this.input.z.pos !== this.gcodePositions.z) {
if (this.existsClientAxisMoveMacro)
gcode.push(`_CLIENT_AXIS_MOVE Z=${this.input.z.pos} F=${this.feedrateZ * 60} ABSOLUTE=1`)
if (this.existsClientLinearMoveMacro)
gcode.push(`_CLIENT_LINEAR_MOVE Z=${this.input.z.pos} F=${this.feedrateZ * 60} ABSOLUTE=1`)
else gcode.push(`G1 Z${this.input.z.pos} F${this.feedrateZ * 60}`)
}
if (this.input.x.pos !== this.gcodePositions.x || this.input.y.pos !== this.gcodePositions.y) {
let xPos = ''
let yPos = ''
if (this.existsClientAxisMoveMacro) {
if (this.existsClientLinearMoveMacro) {
if (this.input.x.pos !== this.gcodePositions.x) xPos = ` X=${this.input.x.pos}`
if (this.input.y.pos !== this.gcodePositions.y) yPos = ` Y=${this.input.y.pos}`
gcode.push(`_CLIENT_AXIS_MOVE${xPos}${yPos} F=${this.feedrateXY * 60} ABSOLUTE=1`)
gcode.push(`_CLIENT_LINEAR_MOVE${xPos}${yPos} F=${this.feedrateXY * 60} ABSOLUTE=1`)
} else {
if (this.input.x.pos !== this.gcodePositions.x) xPos = ` X${this.input.x.pos}`
if (this.input.y.pos !== this.gcodePositions.y) yPos = ` Y${this.input.y.pos}`
Expand All @@ -193,7 +193,7 @@ export default class MoveToControl extends Mixins(BaseMixin, ControlMixin) {
}
}
if (!this.existsClientAxisMoveMacro) {
if (!this.existsClientLinearMoveMacro) {
gcode.push('RESTORE_GCODE_STATE NAME=_ui_movement')
}
Expand Down

0 comments on commit 34ac485

Please sign in to comment.