Skip to content

Commit 8d57751

Browse files
committed
feat: add drop tool G-code functionality and related UI settings
Signed-off-by: topi314 <git@topi.wtf>
1 parent 0d88d0e commit 8d57751

5 files changed

Lines changed: 58 additions & 0 deletions

File tree

src/components/settings/ToolheadSettings.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,23 @@
376376
<v-divider />
377377
</template>
378378

379+
<app-setting
380+
:title="$t('app.setting.label.toolhead_drop_tool_gcode')"
381+
:sub-title="$t('app.setting.tooltip.toolhead_drop_tool_gcode')"
382+
>
383+
<app-text-field
384+
:value="toolheadDropToolGcode"
385+
filled
386+
dense
387+
single-line
388+
hide-details="auto"
389+
submit-on-change
390+
@submit="setToolheadDropToolGcode"
391+
/>
392+
</app-setting>
393+
394+
<v-divider />
395+
379396
<app-setting :title="$t('app.setting.label.reset')">
380397
<app-btn
381398
outlined
@@ -479,6 +496,18 @@ export default class ToolHeadSettings extends Mixins(ToolheadMixin) {
479496
})
480497
}
481498
499+
get toolheadDropToolGcode (): string {
500+
return this.$typedState.config.uiSettings.general.toolheadDropToolGcode
501+
}
502+
503+
setToolheadDropToolGcode (value: string) {
504+
this.$typedDispatch('config/saveByPath', {
505+
path: 'uiSettings.general.toolheadDropToolGcode',
506+
value: value.trim(),
507+
server: true
508+
})
509+
}
510+
482511
get zAdjustValues (): number[] {
483512
return this.$typedState.config.uiSettings.general.zAdjustDistances
484513
}

src/components/widgets/toolhead/ToolChangeCommands.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@
4848
</template>
4949
{{ macro.description }}
5050
</v-tooltip>
51+
<v-tooltip
52+
v-if="dropToolGcode && index2 === toolChangeCommandsGrouped.length - 1"
53+
top
54+
>
55+
<template #activator="{ on, attrs }">
56+
<app-btn
57+
v-bind="attrs"
58+
min-width="10"
59+
:disabled="!klippyReady || printerPrinting"
60+
class="px-0 flex-grow-1"
61+
v-on="on"
62+
@click="sendGcode(dropToolGcode)"
63+
>
64+
<v-icon small>
65+
$mmuEject
66+
</v-icon>
67+
</app-btn>
68+
</template>
69+
{{ $t('app.tool.tooltip.drop_tool') }}
70+
</v-tooltip>
5171
</app-btn-group>
5272
</v-col>
5373
</v-row>
@@ -100,6 +120,10 @@ export default class ToolChangeCommands extends Mixins(StateMixin) {
100120
.sort((a, b) => +a.name.substring(1) - +b.name.substring(1))
101121
}
102122
123+
get dropToolGcode (): string {
124+
return this.$typedState.config.uiSettings.general.toolheadDropToolGcode
125+
}
126+
103127
get toolChangeCommandsGrouped (): ToolChangeCommand[][] {
104128
const toolChangeCommands = this.toolChangeCommands
105129

src/locales/en.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ app:
783783
to_browser_local_storage: To browser local storage
784784
to_browser_session_storage: To browser session storage
785785
toolhead_control_style: Toolhead control style
786+
toolhead_drop_tool_gcode: Drop tool G-code
786787
toolhead_move_distances: Toolhead distance values
787788
toolhead_xy_move_distances: Toolhead XY distance values
788789
toolhead_z_move_distances: Toolhead Z distance values
@@ -828,6 +829,7 @@ app:
828829
[BETA] Enable and press '?' to view the list of available keyboard shortcuts
829830
show_manual_probe_dialog_automatically: Automatically shows helper dialog if running a Manual Probe tool
830831
show_bed_screws_adjust_dialog_automatically: Automatically shows helper dialog if running BED_SCREWS_ADJUST tool
832+
toolhead_drop_tool_gcode: G-code command to run when dropping the current tool. Leave empty to hide the button.
831833
show_screws_tilt_adjust_dialog_automatically: Automatically shows helper dialog if running SCREWS_TILT_CALCULATE tool
832834
theme_disclaimer: >-
833835
These themes feature brand names and logos that are the intellectual property of their respective owners.<br>
@@ -904,6 +906,7 @@ app:
904906
manual_probe: Manual Probe
905907
motors_off: Motors Off
906908
relative_positioning: Relative Positioning
909+
drop_tool: Drop current tool
907910
select_tool: Select tool %{tool}
908911
tools: Tools
909912
label:

src/store/config/state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const defaultState = (): ConfigState => {
3131
defaultToolheadXYSpeed: 130,
3232
defaultToolheadZSpeed: 10,
3333
toolheadControlStyle: 'cross',
34+
toolheadDropToolGcode: 'TOOL_DROPOFF',
3435
toolheadMoveDistances: [0.1, 1, 10, 25, 50, 100],
3536
toolheadXYMoveDistances: [1, 10, 50],
3637
toolheadZMoveDistances: [0.1, 1, 10],

src/store/config/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export interface GeneralConfig {
109109
defaultToolheadXYSpeed: number;
110110
defaultToolheadZSpeed: number;
111111
toolheadControlStyle: ToolheadControlStyle;
112+
toolheadDropToolGcode: string;
112113
toolheadMoveDistances: number[];
113114
toolheadXYMoveDistances: number[];
114115
toolheadZMoveDistances: number[];

0 commit comments

Comments
 (0)