Rebuilt the "Move to [XY|Z] zero?" dialogs in Svelte.
This commit is contained in:
@@ -48,8 +48,6 @@ module.exports = {
|
|||||||
c: false
|
c: false
|
||||||
},
|
},
|
||||||
ask_home: true,
|
ask_home: true,
|
||||||
ask_zero_xy_msg: false,
|
|
||||||
ask_zero_z_msg: false,
|
|
||||||
showGcodeMessage: false
|
showGcodeMessage: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -244,7 +242,6 @@ module.exports = {
|
|||||||
SvelteComponents.registerControllerMethods({
|
SvelteComponents.registerControllerMethods({
|
||||||
stop: (...args) => this.stop(...args),
|
stop: (...args) => this.stop(...args),
|
||||||
send: (...args) => this.send(...args),
|
send: (...args) => this.send(...args),
|
||||||
goto_zero: (...args) => this.goto_zero(...args),
|
|
||||||
isAxisHomed: (axis) => this[axis].homed,
|
isAxisHomed: (axis) => this[axis].homed,
|
||||||
unhome: (...args) => this.unhome(...args),
|
unhome: (...args) => this.unhome(...args),
|
||||||
set_position: (...args) => this.set_position(...args),
|
set_position: (...args) => this.set_position(...args),
|
||||||
@@ -253,18 +250,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
goto_zero(zero_x, zero_y, zero_z, zero_a) {
|
|
||||||
const xcmd = zero_x ? "X0" : "";
|
|
||||||
const ycmd = zero_y ? "Y0" : "";
|
|
||||||
const zcmd = zero_z ? "Z0" : "";
|
|
||||||
const acmd = zero_a ? "A0" : "";
|
|
||||||
|
|
||||||
this.ask_zero_xy_msg = false;
|
|
||||||
this.ask_zero_z_msg = false;
|
|
||||||
|
|
||||||
this.send('G90\nG0' + xcmd + ycmd + zcmd + acmd + '\n');
|
|
||||||
},
|
|
||||||
|
|
||||||
getJogIncrStyle(value) {
|
getJogIncrStyle(value) {
|
||||||
const weight = `font-weight:${this.jog_incr === value ? 'bold' : 'normal'}`;
|
const weight = `font-weight:${this.jog_incr === value ? 'bold' : 'normal'}`;
|
||||||
const color = this.jog_incr === value ? "color:#0078e7" : "";
|
const color = this.jog_incr === value ? "color:#0078e7" : "";
|
||||||
|
|||||||
@@ -10,32 +10,6 @@ script#control-view-template(type="text/x-template")
|
|||||||
div(slot="footer")
|
div(slot="footer")
|
||||||
label Simulating {{(toolpath_progress || 0) | percent}}
|
label Simulating {{(toolpath_progress || 0) | percent}}
|
||||||
|
|
||||||
message(:show.sync=`ask_zero_xy_msg`)
|
|
||||||
h3(slot="header") XY Origin
|
|
||||||
|
|
||||||
div(slot="body")
|
|
||||||
p Move to XY origin?
|
|
||||||
|
|
||||||
div(slot="footer")
|
|
||||||
button.pure-button(@click="goto_zero(1,1,0,0)")
|
|
||||||
| Confirm
|
|
||||||
|
|
||||||
button.pure-button(@click='ask_zero_xy_msg = false')
|
|
||||||
| Cancel
|
|
||||||
|
|
||||||
message(:show.sync=`ask_zero_z_msg`)
|
|
||||||
h3(slot="header") Z Origin
|
|
||||||
|
|
||||||
div(slot="body")
|
|
||||||
p Move to Z origin?
|
|
||||||
|
|
||||||
div(slot="footer")
|
|
||||||
button.pure-button(@click="goto_zero(0,0,1,0)")
|
|
||||||
| Confirm
|
|
||||||
|
|
||||||
button.pure-button(@click='ask_zero_z_msg = false')
|
|
||||||
| Cancel
|
|
||||||
|
|
||||||
table(style="table-layout: fixed; width: 100%;")
|
table(style="table-layout: fixed; width: 100%;")
|
||||||
tr(style="height: fit-content;")
|
tr(style="height: fit-content;")
|
||||||
td(style="white-space: nowrap; width: 410px;", rowspan="2")
|
td(style="white-space: nowrap; width: 410px;", rowspan="2")
|
||||||
@@ -60,12 +34,12 @@ script#control-view-template(type="text/x-template")
|
|||||||
td(style="height:100px",align="center")
|
td(style="height:100px",align="center")
|
||||||
button(@click="jog_fn(-1,0,0,0)") X-
|
button(@click="jog_fn(-1,0,0,0)") X-
|
||||||
td(style="height:100px",align="center")
|
td(style="height:100px",align="center")
|
||||||
button(@click="ask_zero_xy_msg = true")
|
button(@click="showMoveToZeroDialog('xy')")
|
||||||
.fa.fa-bullseye(style="font-size: 173%")
|
.fa.fa-bullseye(style="font-size: 173%")
|
||||||
td(style="height:100px",align="center")
|
td(style="height:100px",align="center")
|
||||||
button(@click="jog_fn(1,0,0,0)") X+
|
button(@click="jog_fn(1,0,0,0)") X+
|
||||||
td(style="height:100px",align="center")
|
td(style="height:100px",align="center")
|
||||||
button(@click='ask_zero_z_msg = true') Z0
|
button(@click="showMoveToZeroDialog('z')") Z0
|
||||||
tr
|
tr
|
||||||
td(style="height:100px",align="center")
|
td(style="height:100px",align="center")
|
||||||
button(@click="jog_fn(-1,-1,0,0)")
|
button(@click="jog_fn(-1,-1,0,0)")
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
import SetTimeDialog from "./SetTimeDialog.svelte";
|
import SetTimeDialog from "./SetTimeDialog.svelte";
|
||||||
import ManualHomeAxisDialog from "./ManualHomeAxisDialog.svelte";
|
import ManualHomeAxisDialog from "./ManualHomeAxisDialog.svelte";
|
||||||
import SetAxisPositionDialog from "./SetAxisPositionDialog.svelte";
|
import SetAxisPositionDialog from "./SetAxisPositionDialog.svelte";
|
||||||
|
import MoveToZeroDialog from "./MoveToZeroDialog.svelte";
|
||||||
import ShutdownDialog from "./ShutdownDialog.svelte";
|
import ShutdownDialog from "./ShutdownDialog.svelte";
|
||||||
|
|
||||||
const HomeMachineDialogProps = writable<HomeMachineDialogPropsType>();
|
const HomeMachineDialogProps = writable<HomeMachineDialogPropsType>();
|
||||||
@@ -50,6 +51,12 @@
|
|||||||
axis: string;
|
axis: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const MoveToZeroDialogProps = writable<MoveToZeroDialogPropsType>();
|
||||||
|
type MoveToZeroDialogPropsType = {
|
||||||
|
open: boolean;
|
||||||
|
axes: "xy" | "z";
|
||||||
|
};
|
||||||
|
|
||||||
const ShutdownDialogProps = writable<ShutdownDialogPropsType>();
|
const ShutdownDialogProps = writable<ShutdownDialogPropsType>();
|
||||||
type ShutdownDialogPropsType = {
|
type ShutdownDialogPropsType = {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -90,6 +97,11 @@
|
|||||||
props: Omit<SetAxisPositionDialogPropsType, "open">
|
props: Omit<SetAxisPositionDialogPropsType, "open">
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export function showDialog(
|
||||||
|
dialog: "MoveToZero",
|
||||||
|
props: Omit<MoveToZeroDialogPropsType, "open">
|
||||||
|
);
|
||||||
|
|
||||||
export function showDialog(
|
export function showDialog(
|
||||||
dialog: "Shutdown",
|
dialog: "Shutdown",
|
||||||
props: Omit<ShutdownDialogPropsType, "open">
|
props: Omit<ShutdownDialogPropsType, "open">
|
||||||
@@ -125,6 +137,10 @@
|
|||||||
SetAxisPositionDialogProps.set({ ...props, open: true });
|
SetAxisPositionDialogProps.set({ ...props, open: true });
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "MoveToZero":
|
||||||
|
MoveToZeroDialogProps.set({ ...props, open: true });
|
||||||
|
break;
|
||||||
|
|
||||||
case "Shutdown":
|
case "Shutdown":
|
||||||
ShutdownDialogProps.set({ ...props, open: true });
|
ShutdownDialogProps.set({ ...props, open: true });
|
||||||
break;
|
break;
|
||||||
@@ -195,7 +211,6 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<HomeMachineDialog {...$HomeMachineDialogProps} />
|
<HomeMachineDialog {...$HomeMachineDialogProps} />
|
||||||
<ProbeDialog {...$ProbeDialogProps} />
|
<ProbeDialog {...$ProbeDialogProps} />
|
||||||
<ScreenRotationDialog {...$ScreenRotationDialogProps} />
|
<ScreenRotationDialog {...$ScreenRotationDialogProps} />
|
||||||
@@ -203,4 +218,5 @@
|
|||||||
<SetTimeDialog {...$SetTimeDialogProps} />
|
<SetTimeDialog {...$SetTimeDialogProps} />
|
||||||
<ManualHomeAxisDialog {...$ManualHomeAxisDialogProps} />
|
<ManualHomeAxisDialog {...$ManualHomeAxisDialogProps} />
|
||||||
<SetAxisPositionDialog {...$SetAxisPositionDialogProps} />
|
<SetAxisPositionDialog {...$SetAxisPositionDialogProps} />
|
||||||
|
<MoveToZeroDialog {...$MoveToZeroDialogProps} />
|
||||||
<ShutdownDialog {...$ShutdownDialogProps} />
|
<ShutdownDialog {...$ShutdownDialogProps} />
|
||||||
|
|||||||
33
src/svelte-components/src/dialogs/MoveToZeroDialog.svelte
Normal file
33
src/svelte-components/src/dialogs/MoveToZeroDialog.svelte
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import Dialog, { Title, Actions, InitialFocus } from "@smui/dialog";
|
||||||
|
import Button, { Label } from "@smui/button";
|
||||||
|
import { ControllerMethods } from "$lib/RegisterControllerMethods";
|
||||||
|
|
||||||
|
export let open;
|
||||||
|
export let axes: "xy" | "z";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Dialog
|
||||||
|
bind:open
|
||||||
|
scrimClickAction=""
|
||||||
|
aria-labelledby="move-to-zero-dialog-title"
|
||||||
|
aria-describedby="move-to-zero-dialog-content"
|
||||||
|
>
|
||||||
|
<Title id="move-to-zero-dialog-title">
|
||||||
|
Move to ${(axes || "").toUpperCase()} origin?
|
||||||
|
</Title>
|
||||||
|
|
||||||
|
<Actions>
|
||||||
|
<Button>
|
||||||
|
<Label>Cancel</Label>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
defaultAction
|
||||||
|
use={[InitialFocus]}
|
||||||
|
on:click={() => ControllerMethods.gotoZero(axes)}
|
||||||
|
>
|
||||||
|
<Label>Confirm</Label>
|
||||||
|
</Button>
|
||||||
|
</Actions>
|
||||||
|
</Dialog>
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
await stepCompleted("Done", userAcknowledged);
|
await stepCompleted("Done", userAcknowledged);
|
||||||
|
|
||||||
if (probeType === "xyz") {
|
if (probeType === "xyz") {
|
||||||
ControllerMethods.goto_zero(1, 1, 0, 0);
|
ControllerMethods.gotoZero("xy");
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.message !== "cancelled") {
|
if (err.message !== "cancelled") {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
type ControllerMethods = {
|
interface RegisterableControllerMethods {
|
||||||
stop: () => void;
|
stop: () => void;
|
||||||
send: (gcode: string) => void;
|
send: (gcode: string) => void;
|
||||||
goto_zero: (x: number, y: number, z: number, a: number) => void;
|
|
||||||
dispatch: (event: string, ...args: any[]) => void;
|
dispatch: (event: string, ...args: any[]) => void;
|
||||||
isAxisHomed: (axis: string) => boolean;
|
isAxisHomed: (axis: string) => boolean;
|
||||||
unhome: (axis: string) => void;
|
unhome: (axis: string) => void;
|
||||||
@@ -9,11 +8,37 @@ type ControllerMethods = {
|
|||||||
set_home: (axis: string, value: number) => void;
|
set_home: (axis: string, value: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ControllerMethods extends RegisterableControllerMethods {
|
||||||
|
gotoZero: (axes: "xy" | "z") => void;
|
||||||
|
}
|
||||||
|
|
||||||
export let ControllerMethods: ControllerMethods;
|
export let ControllerMethods: ControllerMethods;
|
||||||
|
|
||||||
export function registerControllerMethods(methods: Partial<ControllerMethods>) {
|
export function registerControllerMethods(methods: Partial<RegisterableControllerMethods>) {
|
||||||
ControllerMethods = {
|
ControllerMethods = {
|
||||||
...ControllerMethods,
|
...ControllerMethods,
|
||||||
...methods
|
...methods,
|
||||||
|
gotoZero
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gotoZero(axes: "xy" | "z") {
|
||||||
|
let axesClause = "";
|
||||||
|
switch (axes.toLowerCase()) {
|
||||||
|
case "xy":
|
||||||
|
axesClause = "X0Y0";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "z":
|
||||||
|
axesClause = "Z0";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Error(`Invalid axes: ${axes}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
ControllerMethods.send(`
|
||||||
|
G90
|
||||||
|
G0 ${axesClause}
|
||||||
|
`);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user