diff --git a/src/components/mixins/control.ts b/src/components/mixins/control.ts index 849a88878..f9d1d8ba0 100644 --- a/src/components/mixins/control.ts +++ b/src/components/mixins/control.ts @@ -110,14 +110,24 @@ export default class ControlMixin extends Vue { } get toolchangeMacros(): string[] { - return Object.keys(this.$store.state.printer.gcode?.commands ?? {}) - .filter((gcode) => gcode.match(/^T\d+/)) - .sort((a: string, b: string) => { - const numberA = parseInt(a.slice(1)) - const numberB = parseInt(b.slice(1)) - - return numberA - numberB - }) + const sortToolchangeMacros = (a: string, b: string) => { + const numberA = parseInt(a.slice(1)) + const numberB = parseInt(b.slice(1)) + + return numberA - numberB + } + + const commands = this.$store.state.printer.gcode?.commands ?? null + if (commands) { + return Object.keys(commands) + .filter((gcode) => gcode.match(/^T\d+/)) + .sort(sortToolchangeMacros) + } + + return Object.keys(this.$store.state.printer) + .filter((gcode) => gcode.toLowerCase().match(/^gcode_macro t\d+/)) + .map((gcode) => gcode.slice(gcode.indexOf(' ') + 1)) + .sort(sortToolchangeMacros) } get existsClientLinearMoveMacro() { diff --git a/src/store/printer/getters.ts b/src/store/printer/getters.ts index e5c800a24..f5dabd917 100644 --- a/src/store/printer/getters.ts +++ b/src/store/printer/getters.ts @@ -780,9 +780,19 @@ export const getters: GetterTree = { }, existsZtilt: (state) => { - if (!state.gcode) return false + // check for new Klipper gcode.commands for Z_TILT_ADJUST command + const commands = state.gcode?.commands ?? null + if (commands) { + return 'Z_TILT_ADJUST' in commands + } - return 'Z_TILT_ADJUST' in state.gcode.commands + // fallback for older Klipper versions + const settings = state.configfile?.settings ?? null + if (settings) { + return 'z_tilt' in settings + } + + return false }, existsBedTilt: (state) => {