Skip to content

Commit

Permalink
feat: adds Tool Changer controls (#1111)
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas authored Jun 22, 2023
1 parent 2dfca71 commit a7509e7
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/components/widgets/toolhead/ExtruderSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
v-model="extruder"
:items="extruders"
:readonly="printerPrinting"
:disabled="!klippyReady"
:disabled="!klippyReady || printerPrinting"
item-value="key"
item-text="name"
hide-details
Expand All @@ -18,9 +18,7 @@
import { Component, Mixins } from 'vue-property-decorator'
import StateMixin from '@/mixins/state'
@Component({
components: {}
})
@Component({})
export default class ExtruderSelection extends Mixins(StateMixin) {
get extruders () {
return this.$store.getters['printer/getExtruders']
Expand Down
56 changes: 56 additions & 0 deletions src/components/widgets/toolhead/ToolChangeMacros.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<v-row v-if="toolChangeMacros.length > 0">
<v-col>
<app-btn-group>
<app-btn
v-for="(macro, index) of toolChangeMacros"
:key="index"
min-width="10"
:color="macro.color"
:disabled="!klippyReady || printerPrinting"
class="px-0 flex-grow-1"
@click="sendGcode(macro.name)"
>
{{ macro.name }}
</app-btn>
</app-btn-group>
</v-col>
</v-row>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import StateMixin from '@/mixins/state'
import { Macro } from '@/store/macros/types'
const toolChangeMacroRegExp = /^t\d+$/i
type ToolChangeMacro = {
name: string,
color?: string,
active?: boolean
}
@Component({})
export default class ToolChangeMacros extends Mixins(StateMixin) {
get macros (): Macro[] {
return this.$store.getters['macros/getMacros'] as Macro[]
}
get toolChangeMacros (): ToolChangeMacro[] {
return this.macros
.filter(macro => toolChangeMacroRegExp.test(macro.name))
.map(macro => ({
name: macro.name.toUpperCase(),
color: macro.variables?.color ? `#${macro.variables.color}` : undefined,
active: macro.variables?.active ?? false
} as ToolChangeMacro))
.sort((a, b) => {
const numberA = parseInt(a.name.substring(1))
const numberB = parseInt(b.name.substring(1))
return numberA - numberB
})
}
}
</script>
6 changes: 5 additions & 1 deletion src/components/widgets/toolhead/Toolhead.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<template>
<div>
<v-card-text>
<tool-change-macros />

<v-row
justify="space-between"
align="start"
Expand Down Expand Up @@ -48,6 +50,7 @@ import SpeedAndFlowAdjust from './SpeedAndFlowAdjust.vue'
import PressureAdvanceAdjust from './PressureAdvanceAdjust.vue'
import ExtruderStats from './ExtruderStats.vue'
import ExtruderSteppers from './ExtruderSteppers.vue'
import ToolChangeMacros from './ToolChangeMacros.vue'
import { Extruder } from '@/store/printer/types'
@Component({
Expand All @@ -60,7 +63,8 @@ import { Extruder } from '@/store/printer/types'
SpeedAndFlowAdjust,
PressureAdvanceAdjust,
ExtruderStats,
ExtruderSteppers
ExtruderSteppers,
ToolChangeMacros
}
})
export default class Toolhead extends Mixins(StateMixin) {
Expand Down

0 comments on commit a7509e7

Please sign in to comment.