-
-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds Tool Changer controls (#1111)
Signed-off-by: Pedro Lamas <[email protected]>
- Loading branch information
1 parent
2dfca71
commit a7509e7
Showing
3 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters