Skip to content

Commit

Permalink
spool join and toolhead remap component prepared
Browse files Browse the repository at this point in the history
  • Loading branch information
HelgeKeck committed Aug 5, 2024
1 parent 1b37ec2 commit 93c4cd4
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 215 deletions.
10 changes: 0 additions & 10 deletions src/components/widgets/extruder/ExtruderSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,11 @@ export default class ExtruderSelection extends Mixins(StateMixin, ToolheadMixin,
</script>

<style scoped>
.no-padding :deep(.v-input__slot) {
padding-left: 0px !important;
padding-right: 0px !important;
}
.v-expansion-panel-header>>> .v-expansion-panel-header--active {
padding: 0 !important;
}
.v-expansion-panel-content>>> .v-expansion-panel-content__wrap {
padding: 0 !important;
}
.no-underline .v-select__selections {
border-bottom: none !important;
box-shadow: none !important;
}
</style>
10 changes: 0 additions & 10 deletions src/components/widgets/extruder/ExtruderStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,11 @@ export default class ExtruderMoves extends Mixins(StateMixin, ToolheadMixin) {
</script>

<style scoped>
.no-padding :deep(.v-input__slot) {
padding-left: 0px !important;
padding-right: 0px !important;
}
.v-expansion-panel-header>>> .v-expansion-panel-header--active {
padding: 0 !important;
}
.v-expansion-panel-content>>> .v-expansion-panel-content__wrap {
padding: 0 !important;
}
.no-underline .v-select__selections {
border-bottom: none !important;
box-shadow: none !important;
}
</style>
10 changes: 0 additions & 10 deletions src/components/widgets/extruder/ExtruderStepperSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@ export default class ExtruderStepperSelection extends Mixins(StateMixin) {
</script>

<style scoped>
.no-padding :deep(.v-input__slot) {
padding-left: 0px !important;
padding-right: 0px !important;
}
.v-expansion-panel-header>>> .v-expansion-panel-header--active {
padding: 0 !important;
}
Expand All @@ -161,11 +156,6 @@ export default class ExtruderStepperSelection extends Mixins(StateMixin) {
padding-top: 4px;
}
.no-underline .v-select__selections {
border-bottom: none !important;
box-shadow: none !important;
}
.v-select>>> .v-select__suffix {
opacity: 0.5;
}
Expand Down
94 changes: 94 additions & 0 deletions src/components/widgets/toolhead/SpoolJoining.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<template>
<v-expansion-panels
v-if="allowsSpoolJoining"
:disabled="!klippyReady || printerPrinting || (isIdex && (idexCopy || idexMirror))"
accordion
multiple
flat
class="pb-2 pt-0 mt-4"
>
<v-expansion-panel>
<v-expansion-panel-header
class="pl-0 pr-0 pb-0 pt-0"
>
<template #actions>
<v-icon
small
class="pa-0 ma-0 mr-1"
>
$expand
</v-icon>
</template>
<template #default>
<v-row
no-gutters
justify="start"
>
<v-col>
<v-icon
small
primary
class="mb-1"
:color="spoolJoinActive ? 'primary' : ''"
style="transform: translateY(1px);"
>
$filament
</v-icon>
<span
:class="spoolJoinActive ? 'primary--text mr-3' : 'mr-3'"
style="font-size: 14px"
>
Spool joining
</span>
</v-col>
</v-row>
</template>
</v-expansion-panel-header>
<v-expansion-panel-content>
<div
class="text-center pa-0 pb-0 mt-3"
:class="{ 'text--disabled': !klippyReady }"
>
<p
v-html="'Spool joining'"
/>
</div>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import ToolheadMixin from '@/mixins/toolhead'
import StateMixin from '@/mixins/state'
@Component({})
export default class SpoolJoining extends Mixins(StateMixin, ToolheadMixin) {
setSpoolJoin () {
if (this.isIdex) {
if (this.spoolJoinActive) {
this.sendGcode('SET_GCODE_VARIABLE MACRO=T0 VARIABLE=join VALUE=0')
this.sendGcode('SET_GCODE_VARIABLE MACRO=T1 VARIABLE=join VALUE=1')
this.sendGcode('M117 Spool joining disabled!')
} else {
this.sendGcode('SET_GCODE_VARIABLE MACRO=T0 VARIABLE=join VALUE=1')
this.sendGcode('SET_GCODE_VARIABLE MACRO=T1 VARIABLE=join VALUE=0')
this.sendGcode('M117 Spool joining enabled!')
}
} else {
this.sendGcode('M117 Not implemented yet!')
}
}
}
</script>

<style scoped>
.v-expansion-panel-header>>> .v-expansion-panel-header--active {
padding: 0 !important;
}
.v-expansion-panel-content>>> .v-expansion-panel-content__wrap {
padding: 0 !important;
}
</style>
182 changes: 0 additions & 182 deletions src/components/widgets/toolhead/ToolChangeCommands.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,36 +45,6 @@
</template>
{{ macro.description }}
</v-tooltip>
<app-btn
v-if="toolheadRemapAllowed"
min-width="10"
:color="toolheadRemapActive ? allHomed ? 'primary' : 'secondary' : undefined"
:disabled="!klippyReady || printerPrinting || (isIdex && (idexCopy || idexMirror))"
class="px-2"
description="Toolhead remapping"
@click="setToolRemap()"
>
<v-icon
class="mr-1 spool-icon"
>
$chart
</v-icon>
</app-btn>
<app-btn
v-if="spoolJoinAllowed"
min-width="10"
:color="spoolJoinActive ? allHomed ? 'primary' : 'secondary' : undefined"
:disabled="!klippyReady || printerPrinting || (isIdex && (idexCopy || idexMirror))"
class="px-2"
description="Spool joining"
@click="setSpoolJoin()"
>
<v-icon
class="mr-1 spool-icon"
>
$filament
</v-icon>
</app-btn>
</app-btn-group>
</v-col>
</v-row>
Expand All @@ -84,169 +54,17 @@
import { Component, Mixins } from 'vue-property-decorator'
import StateMixin from '@/mixins/state'
import ToolheadMixin from '@/mixins/toolhead'
import type { GcodeCommands } from '@/store/printer/types'
import type { TranslateResult } from 'vue-i18n'
import type { Spool } from '@/store/spoolman/types'
type ToolChangeCommand = {
name: string,
description: string | TranslateResult,
color?: string,
active?: boolean,
spoolId?: number,
default?: boolean,
remap?: number,
join?: number
}
@Component({})
export default class ToolChangeCommands extends Mixins(ToolheadMixin, StateMixin) {
get hasIdexFilamentSensors (): boolean {
try {
const toolhead_filament_sensor_t0 = this.$store.state.printer.printer.configfile?.settings?.toolhead_filament_sensor_t0
const toolhead_filament_sensor_t1 = this.$store.state.printer.printer.configfile?.settings?.toolhead_filament_sensor_t1
if (toolhead_filament_sensor_t0 !== undefined && toolhead_filament_sensor_t1 !== undefined) {
return true
}
return true
} catch { }
try {
const feeder_filament_sensor_t0 = this.$store.state.printer.printer.configfile?.settings?.feeder_filament_sensor_t0
const feeder_filament_sensor_t1 = this.$store.state.printer.printer.configfile?.settings?.feeder_filament_sensor_t1
if (feeder_filament_sensor_t0 !== undefined && feeder_filament_sensor_t1 !== undefined) {
return true
}
return true
} catch { }
return false
}
get availableCommands (): GcodeCommands {
return this.$store.getters['printer/getAvailableCommands'] as GcodeCommands
}
get toolChangeCommands (): ToolChangeCommand[] {
const availableCommands = this.availableCommands
return Object.keys(availableCommands)
.filter(command => /^t\d+$/i.test(command))
.map(command => {
const { help } = availableCommands[command]
const description = help && help !== 'G-Code macro'
? help
: this.$t('app.tool.tooltip.select_tool', { tool: command.substring(1) })
const macro = this.$store.getters['macros/getMacroByName'](command.toLowerCase())
return {
name: command,
description,
color: macro?.variables?.color ? `#${macro.variables.color}` : undefined,
active: macro?.variables?.active ?? false,
spoolId: macro?.variables?.spool_id,
default: macro?.variables?.default ?? false,
remap: macro?.variables?.remap,
join: macro?.variables?.join
} satisfies ToolChangeCommand
})
.sort((a, b) => {
const numberA = parseInt(a.name.substring(1))
const numberB = parseInt(b.name.substring(1))
return numberA - numberB
})
}
getSpoolById (id: number): Spool | undefined {
return this.$store.getters['spoolman/getSpoolById'](id)
}
getSpoolColor (spool: Spool | undefined) {
return `#${spool?.filament.color_hex ?? (this.$vuetify.theme.dark ? 'fff' : '000')}`
}
get spoolJoinAllowed (): boolean {
if (this.isIdex) {
if (!this.hasIdexFilamentSensors) {
return false
}
}
for (const txMacro of this.toolChangeCommands) {
if (txMacro.join === undefined) {
return false
}
}
return true
}
get toolheadRemapAllowed (): boolean {
for (const txMacro of this.toolChangeCommands) {
if (txMacro.remap === undefined) {
return false
}
}
return true
}
get spoolJoinActive (): boolean {
if (!this.spoolJoinAllowed) {
return false
}
for (const txMacro of this.toolChangeCommands) {
if (txMacro.join?.toString() !== txMacro.name.substring(1)) {
return true
}
}
return false
}
get toolheadRemapActive (): boolean {
if (!this.toolheadRemapAllowed) {
return false
}
for (const txMacro of this.toolChangeCommands) {
if (txMacro.remap?.toString() !== txMacro.name.substring(1)) {
return true
}
}
return false
}
setSpoolJoin () {
if (this.isIdex) {
if (this.spoolJoinActive) {
this.sendGcode('SET_GCODE_VARIABLE MACRO=T0 VARIABLE=join VALUE=0')
this.sendGcode('SET_GCODE_VARIABLE MACRO=T1 VARIABLE=join VALUE=1')
this.sendGcode('M117 Spool joining disabled!')
} else {
this.sendGcode('SET_GCODE_VARIABLE MACRO=T0 VARIABLE=join VALUE=1')
this.sendGcode('SET_GCODE_VARIABLE MACRO=T1 VARIABLE=join VALUE=0')
this.sendGcode('M117 Spool joining enabled!')
}
this.$forceUpdate()
} else {
// for MMUs or toolchangers open a configuration dialog
this.sendGcode('M117 Not implemented yet!')
}
}
setToolRemap () {
if (this.isIdex) {
if (this.toolheadRemapActive) {
this.sendGcode('SET_GCODE_VARIABLE MACRO=T0 VARIABLE=remap VALUE=0')
this.sendGcode('SET_GCODE_VARIABLE MACRO=T1 VARIABLE=remap VALUE=1')
this.sendGcode('M117 Toolhead remapping disabled!')
} else {
this.sendGcode('SET_GCODE_VARIABLE MACRO=T0 VARIABLE=remap VALUE=1')
this.sendGcode('SET_GCODE_VARIABLE MACRO=T1 VARIABLE=remap VALUE=0')
this.sendGcode('M117 Toolhead remapping enabled!')
}
this.$forceUpdate()
} else {
// for MMUs or toolchangers open a configuration dialog
this.sendGcode('M117 Not implemented yet!')
}
}
}
</script>

Expand Down
Loading

0 comments on commit 93c4cd4

Please sign in to comment.