Skip to content

Commit

Permalink
fix: fix gcode from macros with single char attributes (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Feb 28, 2022
1 parent 5d146e9 commit 18294b6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/components/inputs/MacroButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export default class MacroButton extends Mixins(BaseMixin) {
private paramArray: string[] = []
private params: params = {}
@Prop({ required: true }) declare readonly macro: GuiMacrosStateMacrogroupMacro
@Prop({ required: true })
declare readonly macro: GuiMacrosStateMacrogroupMacro
@Prop({ default: 'primary' }) declare readonly color: string
get klipperMacro() {
Expand Down Expand Up @@ -110,15 +111,23 @@ export default class MacroButton extends Mixins(BaseMixin) {
}
doSendMacro(gcode: string) {
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
this.$store.dispatch('server/addEvent', {
message: gcode,
type: 'command',
})
this.$socket.emit('printer.gcode.script', { script: gcode }, { loading: 'macro_' + gcode })
}
sendWithParams() {
let params: string[] = []
this.paramArray.forEach((paramname: string) => {
if (this.params[paramname].value !== null && this.params[paramname].value !== '')
params.push(paramname + '=' + this.params[paramname].value)
if (this.params[paramname].value !== null && this.params[paramname].value !== '') {
let tmp: string = paramname
if (paramname.length === 1) tmp += this.params[paramname].value
else tmp += '=' + this.params[paramname].value
params.push(tmp)
}
})
const gcode = this.macro.name + ' ' + params.join(' ')
Expand Down

0 comments on commit 18294b6

Please sign in to comment.