feat: use _CLIENT_LINEAR_MOVE macros instead of multi-line gcodes (#2043)
* feat: use _CLIENT_MOVE macros instead of multi-line gcodes Signed-off-by: Stefan Dej <meteyou@gmail.com> * refactor: change from 2 macros to 1 macro (_CLIENT_LINEAR_MOVE) Signed-off-by: Stefan Dej <meteyou@gmail.com> --------- Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
parent
601188738f
commit
1c722c44e0
@ -112,6 +112,12 @@ export default class ControlMixin extends Vue {
|
||||
})
|
||||
}
|
||||
|
||||
get existsClientLinearMoveMacro() {
|
||||
const macros = this.$store.state.printer?.gcode?.commands ?? {}
|
||||
|
||||
return '_CLIENT_LINEAR_MOVE' in macros
|
||||
}
|
||||
|
||||
doHome() {
|
||||
this.$store.dispatch('server/addEvent', { message: 'G28', type: 'command' })
|
||||
this.$socket.emit('printer.gcode.script', { script: 'G28' }, { loading: 'homeAll' })
|
||||
@ -148,13 +154,27 @@ export default class ControlMixin extends Vue {
|
||||
}
|
||||
|
||||
doSendMove(gcode: string, feedrate: number) {
|
||||
gcode =
|
||||
let command =
|
||||
`SAVE_GCODE_STATE NAME=_ui_movement\n` +
|
||||
`G91\n` +
|
||||
`G1 ${gcode} F${feedrate * 60}\n` +
|
||||
`RESTORE_GCODE_STATE NAME=_ui_movement`
|
||||
|
||||
this.doSend(gcode)
|
||||
if (this.existsClientLinearMoveMacro) {
|
||||
gcode = gcode
|
||||
.split(' ')
|
||||
.map((part) => {
|
||||
const axis = part.slice(0, 1)
|
||||
const value = parseFloat(part.slice(1))
|
||||
|
||||
return `${axis}=${value}`
|
||||
})
|
||||
.join(' ')
|
||||
|
||||
command = `_CLIENT_LINEAR_MOVE ${gcode} F=${feedrate * 60}`
|
||||
}
|
||||
|
||||
this.doSend(command)
|
||||
}
|
||||
|
||||
doSend(gcode: string) {
|
||||
|
@ -250,6 +250,12 @@ export default class ExtruderControlPanel extends Mixins(BaseMixin, ExtruderMixi
|
||||
return this.feedamount * this.extrudeFactor > this.maxExtrudeOnlyDistance
|
||||
}
|
||||
|
||||
get existsClientLinearMoveMacro() {
|
||||
const macros = this.$store.state.printer?.gcode?.commands ?? {}
|
||||
|
||||
return '_CLIENT_LINEAR_MOVE' in macros
|
||||
}
|
||||
|
||||
@Watch('maxExtrudeOnlyDistance', { immediate: true })
|
||||
onMaxExtrudeOnlyDistanceChange(): void {
|
||||
/**
|
||||
@ -271,12 +277,16 @@ export default class ExtruderControlPanel extends Mixins(BaseMixin, ExtruderMixi
|
||||
}
|
||||
|
||||
sendCommand(length: number, loading: string): void {
|
||||
const gcode =
|
||||
let gcode =
|
||||
`SAVE_GCODE_STATE NAME=_ui_extrude\n` +
|
||||
`M83\n` +
|
||||
`G1 E${length} F${this.feedrate * 60}\n` +
|
||||
`RESTORE_GCODE_STATE NAME=_ui_extrude`
|
||||
|
||||
if (this.existsClientLinearMoveMacro) {
|
||||
gcode = `_CLIENT_LINEAR_MOVE E=${length} F=${this.feedrate * 60}`
|
||||
}
|
||||
|
||||
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
|
||||
this.$socket.emit('printer.gcode.script', { script: gcode }, { loading })
|
||||
}
|
||||
|
@ -16,9 +16,7 @@
|
||||
'col-3': el.is.large,
|
||||
}"
|
||||
class="v-subheader text--secondary mr-2">
|
||||
<v-icon small class="mr-1">
|
||||
{{ mdiCrosshairsGps }}
|
||||
</v-icon>
|
||||
<v-icon small class="mr-1">{{ mdiCrosshairsGps }}</v-icon>
|
||||
<span v-if="!el.is.xsmall" class="text-no-wrap">
|
||||
{{ $t('Panels.ToolheadControlPanel.Position') }}:
|
||||
</span>
|
||||
@ -27,12 +25,8 @@
|
||||
<v-col
|
||||
v-if="currentProfileName"
|
||||
class="v-subheader text--secondary pl-2 justify-end text-no-wrap text-truncate">
|
||||
<v-icon small class="mr-1">
|
||||
{{ mdiGrid }}
|
||||
</v-icon>
|
||||
<span class="text-no-wrap text-truncate">
|
||||
{{ currentProfileName }}
|
||||
</span>
|
||||
<v-icon small class="mr-1">{{ mdiGrid }}</v-icon>
|
||||
<span class="text-no-wrap text-truncate">{{ currentProfileName }}</span>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row v-if="showCoordinates" dense>
|
||||
@ -45,7 +39,7 @@
|
||||
:current-pos="gcodePositions.x"
|
||||
:readonly="['printing'].includes(printer_state)"
|
||||
:disabled="!xAxisHomed"
|
||||
@submit="sendCmd"></move-to-input>
|
||||
@submit="sendCmd" />
|
||||
</v-col>
|
||||
<v-col :class="el.is.xsmall ? 'col-12' : 'col-4'">
|
||||
<move-to-input
|
||||
@ -56,7 +50,7 @@
|
||||
:current-pos="gcodePositions.y"
|
||||
:readonly="['printing'].includes(printer_state)"
|
||||
:disabled="!yAxisHomed"
|
||||
@submit="sendCmd"></move-to-input>
|
||||
@submit="sendCmd" />
|
||||
</v-col>
|
||||
<v-col :class="el.is.xsmall ? 'col-12' : 'col-4'">
|
||||
<move-to-input
|
||||
@ -67,7 +61,7 @@
|
||||
:current-pos="gcodePositions.z"
|
||||
:readonly="['printing'].includes(printer_state)"
|
||||
:disabled="!zAxisHomed"
|
||||
@submit="sendCmd"></move-to-input>
|
||||
@submit="sendCmd" />
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
@ -170,24 +164,44 @@ export default class MoveToControl extends Mixins(BaseMixin, ControlMixin) {
|
||||
}
|
||||
|
||||
sendCmd(): void {
|
||||
const xPos = this.input.x.pos !== this.gcodePositions.x ? ` X${this.input.x.pos}` : ''
|
||||
const yPos = this.input.y.pos !== this.gcodePositions.y ? ` Y${this.input.y.pos}` : ''
|
||||
const zPos = this.input.z.pos !== this.gcodePositions.z ? ` Z${this.input.z.pos}` : ''
|
||||
|
||||
let gcode = ''
|
||||
if (!this.positionAbsolute) {
|
||||
gcode += 'G90\n'
|
||||
}
|
||||
if (zPos !== '') {
|
||||
gcode += `G1${zPos} F${this.feedrateZ * 60}\n`
|
||||
}
|
||||
if (xPos !== '' || yPos !== '') {
|
||||
gcode += `G1${xPos}${yPos} F${this.feedrateXY * 60}`
|
||||
let gcode: string[] = []
|
||||
if (!this.existsClientLinearMoveMacro) {
|
||||
gcode.push('SAVE_GCODE_STATE NAME=_ui_movement')
|
||||
gcode.push('G90')
|
||||
}
|
||||
|
||||
if (gcode !== '' && this.input.x.valid && this.input.y.valid && this.input.z.valid) {
|
||||
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
|
||||
this.$socket.emit('printer.gcode.script', { script: gcode })
|
||||
if (this.input.z.pos !== this.gcodePositions.z) {
|
||||
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.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_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}`
|
||||
|
||||
gcode.push(`G1${xPos}${yPos} F${this.feedrateXY * 60}`)
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.existsClientLinearMoveMacro) {
|
||||
gcode.push('RESTORE_GCODE_STATE NAME=_ui_movement')
|
||||
}
|
||||
|
||||
const gcodeStr = gcode.join('\n')
|
||||
|
||||
if (this.input.x.valid && this.input.y.valid && this.input.z.valid) {
|
||||
this.$store.dispatch('server/addEvent', { message: gcodeStr, type: 'command' })
|
||||
this.$socket.emit('printer.gcode.script', { script: gcodeStr })
|
||||
}
|
||||
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user