Skip to content

Commit

Permalink
feat: hide "motors off" if no steppers are enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas committed Dec 1, 2023
1 parent 3ca1aba commit 8196090
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/components/widgets/toolhead/ToolheadCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
</app-btn>

<app-btn
v-if="hasSteppersEnabled"
:disabled="!klippyReady || printerPrinting"
small
class="ms-1 my-1"
Expand Down Expand Up @@ -366,6 +367,10 @@ export default class ToolheadCard extends Mixins(StateMixin, ToolheadMixin) {
)
}
get hasSteppersEnabled (): boolean {
return this.$store.getters['printer/getHasSteppersEnabled'] as boolean
}
get hasRoundBed (): boolean {
return this.$store.getters['printer/getHasRoundBed'] as boolean
}
Expand Down
22 changes: 13 additions & 9 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,23 @@ export const getters: GetterTree<PrinterState, RootState> = {
return steppers
},

getHasSteppersEnabled: (state, getters): boolean => {
const steppers = getters.getSteppers as Stepper[]

return Object.values(steppers)
.some(stepper => stepper.enabled == null || stepper.enabled)
},

/**
* Given axes, returns a boolean indicating if the axes are homed.
*/
getHomedAxes: (state) => (axes?: string): boolean => {
if (axes && axes.length > 0) {
let r = false
const a = axes.split('')
a.forEach((char) => {
r = state.printer.toolhead.homed_axes.includes(char)
})
return r
}
return false
return (
axes != null &&
axes.length > 0 &&
axes.split('')
.every(char => state.printer.toolhead.homed_axes.includes(char))
)
},

getRunoutSensors: (state): RunoutSensor[] => {
Expand Down

0 comments on commit 8196090

Please sign in to comment.