Skip to content

Commit

Permalink
feat: hide extruder controls if none defined
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas committed Nov 6, 2023
1 parent 6ce9bc0 commit 0844424
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
15 changes: 5 additions & 10 deletions src/components/widgets/toolhead/Toolhead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
align="start"
>
<v-col class="controls-wrapper">
<extruder-selection v-if="multipleExtruders" />
<extruder-selection v-if="hasMultipleExtruders" />
<toolhead-control-cross v-if="!printerPrinting && toolheadControlStyle === 'cross'" />
<toolhead-control-bars v-else-if="!printerPrinting && toolheadControlStyle === 'bars'" />
<z-height-adjust v-if="printerPrinting" />
</v-col>

<v-col class="controls-wrapper">
<toolhead-position />
<extruder-moves v-if="!printerPrinting" />
<extruder-moves v-if="!printerPrinting && hasExtruder" />
<z-height-adjust v-if="!printerPrinting" />
</v-col>
</v-row>
Expand All @@ -42,6 +42,7 @@
<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import StateMixin from '@/mixins/state'
import ToolheadMixin from '@/mixins/toolhead'
import ToolheadControlCross from './ToolheadControlCross.vue'
import ToolheadControlBars from './ToolheadControlBars.vue'
import ExtruderMoves from './ExtruderMoves.vue'
Expand All @@ -53,7 +54,6 @@ import PressureAdvanceAdjust from './PressureAdvanceAdjust.vue'
import ExtruderStats from './ExtruderStats.vue'
import ExtruderSteppers from './ExtruderSteppers.vue'
import ToolChangeCommands from './ToolChangeCommands.vue'
import type { Extruder } from '@/store/printer/types'
import type { ToolheadControlStyle } from '@/store/config/types'
@Component({
Expand All @@ -71,14 +71,9 @@ import type { ToolheadControlStyle } from '@/store/config/types'
ToolChangeCommands
}
})
export default class Toolhead extends Mixins(StateMixin) {
get multipleExtruders (): boolean {
return this.$store.getters['printer/getExtruders'].length > 1
}
export default class Toolhead extends Mixins(StateMixin, ToolheadMixin) {
get showPressureAdvance (): boolean {
const extruder = this.$store.getters['printer/getActiveExtruder'] as Extruder | undefined
return extruder?.pressure_advance !== undefined
return this.activeExtruder?.pressure_advance !== undefined
}
get toolheadControlStyle (): ToolheadControlStyle {
Expand Down
2 changes: 1 addition & 1 deletion src/components/widgets/toolhead/ToolheadCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-icon
v-show="!extruderReady"
v-show="hasExtruder && !extruderReady"
v-bind="attrs"
class="ml-3"
color="info"
Expand Down
20 changes: 16 additions & 4 deletions src/mixins/toolhead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@ import type { Extruder } from '@/store/printer/types'

@Component
export default class ToolheadMixin extends Vue {
get hasExtruder (): boolean {
return this.$store.getters['printer/getHasExtruder'] as boolean
}

get hasMultipleExtruders (): boolean {
return this.$store.getters['printer/getHasMultipleExtruders'] as boolean
}

get activeExtruder (): Extruder | undefined {
return this.$store.getters['printer/getActiveExtruder'] as Extruder | undefined
}

get extruderReady (): boolean {
const extruder = this.activeExtruder
return (extruder && extruder.temperature >= 0 && extruder.min_extrude_temp >= 0)
? (extruder.temperature >= extruder.min_extrude_temp)
: false
const activeExtruder = this.activeExtruder

return (
activeExtruder !== undefined &&
activeExtruder.temperature >= 0 &&
activeExtruder.min_extrude_temp >= 0 &&
activeExtruder.temperature >= activeExtruder.min_extrude_temp
)
}

get filamentDiameter (): number {
Expand Down
11 changes: 11 additions & 0 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@ export const getters: GetterTree<PrinterState, RootState> = {
return mcus
},

getHasExtruder: (state) => {
return state.printer.extruder
},

getHasMultipleExtruders: (state) => {
return (
state.printer.extruder &&
state.printer.extruder1
)
},

/**
* Return known extruders, giving them a friendly name.
*/
Expand Down

0 comments on commit 0844424

Please sign in to comment.