diff --git a/src/components/panels/ToolheadControls/ZoffsetControl.vue b/src/components/panels/ToolheadControls/ZoffsetControl.vue index 2eae278c..52f974ca 100644 --- a/src/components/panels/ToolheadControls/ZoffsetControl.vue +++ b/src/components/panels/ToolheadControls/ZoffsetControl.vue @@ -27,11 +27,7 @@ {{ $t('Panels.ZoffsetPanel.Clear') }} {{ mdiContentSave }} {{ $t('Panels.ZoffsetPanel.Save') }} - - - - - - {{ mdiElectricSwitch }} - {{ $t('Panels.ZoffsetPanel.ToEndstop') }} - - - - - {{ mdiElevator }} - {{ $t('Panels.ZoffsetPanel.ToProbe') }} - - - - @@ -123,7 +94,7 @@ @@ -160,12 +131,9 @@ import Responsive from '@/components/ui/Responsive.vue' import { mdiBroom, - mdiElectricSwitch, - mdiElevator, mdiContentSave, mdiArrowCollapseDown, mdiInformation, - mdiMenuDown, mdiArrowExpandUp, mdiLayersOutline, } from '@mdi/js' @@ -174,16 +142,13 @@ import { }) export default class ZoffsetControl extends Mixins(BaseMixin) { mdiBroom = mdiBroom - mdiElectricSwitch = mdiElectricSwitch - mdiElevator = mdiElevator mdiContentSave = mdiContentSave mdiArrowCollapseDown = mdiArrowCollapseDown mdiInformation = mdiInformation - mdiMenuDown = mdiMenuDown mdiArrowExpandUp = mdiArrowExpandUp mdiLayersOutline = mdiLayersOutline - private saveOffsetDialog = false + saveOffsetDialog = false get homing_origin() { return this.$store.state.printer?.gcode_move?.homing_origin ?? [] @@ -198,13 +163,37 @@ export default class ZoffsetControl extends Mixins(BaseMixin) { } get homed_axis() { - return this.$store.state.printer.toolhead.homed_axes ?? '' + return this.$store.state.printer.toolhead?.homed_axes ?? '' } get helplist() { return this.$store.state.printer.helplist ?? [] } + get settings() { + return this.$store.state.printer.configfile?.settings ?? {} + } + + get kinematics() { + return this.settings.printer?.kinematics ?? 'cartesian' + } + + get stepper_name() { + if (this.kinematics === 'delta') return 'stepper_a' + + return 'stepper_z' + } + + get endstop_pin() { + const stepperConfig = this.settings[this.stepper_name] ?? {} + + return stepperConfig?.endstop_pin + } + + get isEndstopProbe() { + return this.endstop_pin.search('probe:z_virtual_endstop') !== -1 + } + get existZOffsetApplyProbe() { return this.helplist.findIndex((gcode: CommandHelp) => gcode.commandLow === 'z_offset_apply_probe') !== -1 } @@ -217,6 +206,17 @@ export default class ZoffsetControl extends Mixins(BaseMixin) { return this.$store.state.printer?.gcode_move?.homing_origin[2].toFixed(3) } + get showSaveButton() { + // hide button when offset is 0 + if (this.z_gcode_offset === 0) return false + + // show button when z endstop is probe and probe gcode exists + if (this.isEndstopProbe && this.existZOffsetApplyProbe) return true + + // show button when z endstop is endstop and endstop gcode exists + return !this.isEndstopProbe && this.existZOffsetApplyEndstop + } + sendBabyStepDown(offset: number): void { const gcode = `SET_GCODE_OFFSET Z_ADJUST=-${offset} ${this.homed_axis === 'xyz' ? 'MOVE=1' : ''}` this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' }) @@ -236,12 +236,12 @@ export default class ZoffsetControl extends Mixins(BaseMixin) { } saveZOffset(): void { - if (this.existZOffsetApplyProbe && !this.existZOffsetApplyEndstop) { + if (this.isEndstopProbe && this.existZOffsetApplyProbe) { this.saveZOffsetToProbe() + return } - if (!this.existZOffsetApplyProbe && this.existZOffsetApplyEndstop) { - this.saveZOffsetToEndstop() - } + + this.saveZOffsetToEndstop() } saveZOffsetToEndstop(): void {