Switch move buttons to use jog
This implements a nicer version of jogging, with a defined interval of 1/3 second. This can be tuned depending on what we think makes sense. It might be good to re-use this for handling keypresses.
This commit is contained in:
parent
abda60adf6
commit
9ed850cc68
3 changed files with 60 additions and 12 deletions
|
|
@ -366,7 +366,9 @@ class SangaboardThing(BaseStage):
|
||||||
will terminate, and `self._jog_received` will be set again. This means that
|
will terminate, and `self._jog_received` will be set again. This means that
|
||||||
it should be safe to
|
it should be safe to
|
||||||
"""
|
"""
|
||||||
duration = 1 # How long to wait initially. This shouldn't ever need to be long.
|
duration = (
|
||||||
|
1.0 # How long to wait initially. This shouldn't ever need to be long.
|
||||||
|
)
|
||||||
# On subsequent loop iterations, we'll wait long enough that we expect the last
|
# On subsequent loop iterations, we'll wait long enough that we expect the last
|
||||||
# move to have finished.
|
# move to have finished.
|
||||||
previous_command: Optional[JogCommand] = None
|
previous_command: Optional[JogCommand] = None
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,6 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
onMoveStep(payload) {
|
onMoveStep(payload) {
|
||||||
const { x: x_steps, y: y_steps, z: z_steps } = payload;
|
|
||||||
const navigationStepSize = this.$store.state.navigationStepSize;
|
const navigationStepSize = this.$store.state.navigationStepSize;
|
||||||
const navigationInvert = this.$store.state.navigationInvert;
|
const navigationInvert = this.$store.state.navigationInvert;
|
||||||
const x = x_steps * navigationStepSize.x * (navigationInvert.x ? -1 : 1);
|
const x = x_steps * navigationStepSize.x * (navigationInvert.x ? -1 : 1);
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,52 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="uk-flex uk-flex-center uk-flex-middle uk-margin">
|
<div class="uk-flex uk-flex-center uk-flex-middle uk-margin">
|
||||||
<div class="dpad-grid">
|
<div class="dpad-grid">
|
||||||
<button id="up-button" class="uk-button uk-button-primary dpad-btn" @click="move(0, 1, 0)">
|
<button
|
||||||
|
id="up-button"
|
||||||
|
class="uk-button uk-button-primary dpad-btn"
|
||||||
|
@mousedown="jog(0, 1, 0)"
|
||||||
|
@mouseup="jogStop()"
|
||||||
|
@mouseOut="jogStop()"
|
||||||
|
>
|
||||||
<span class="material-symbols-outlined sync-icon"> arrow_upward </span>
|
<span class="material-symbols-outlined sync-icon"> arrow_upward </span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button id="left-button" class="uk-button uk-button-primary dpad-btn" @click="move(-1, 0, 0)">
|
<button
|
||||||
|
id="left-button"
|
||||||
|
class="uk-button uk-button-primary dpad-btn"
|
||||||
|
@mousedown="jog(-1, 0, 0)"
|
||||||
|
@mouseup="jogStop()"
|
||||||
|
@mouseOut="jogStop()"
|
||||||
|
>
|
||||||
<span class="material-symbols-outlined sync-icon"> arrow_back </span>
|
<span class="material-symbols-outlined sync-icon"> arrow_back </span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button id="right-button" class="uk-button uk-button-primary dpad-btn" @click="move(1, 0, 0)">
|
<button
|
||||||
|
id="right-button"
|
||||||
|
class="uk-button uk-button-primary dpad-btn"
|
||||||
|
@mousedown="jog(1, 0, 0)"
|
||||||
|
@mouseup="jogStop()"
|
||||||
|
@mouseOut="jogStop()"
|
||||||
|
>
|
||||||
<span class="material-symbols-outlined sync-icon"> arrow_forward </span>
|
<span class="material-symbols-outlined sync-icon"> arrow_forward </span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button id="down-button" class="uk-button uk-button-primary dpad-btn" @click="move(0, -1, 0)">
|
<button
|
||||||
|
id="down-button"
|
||||||
|
class="uk-button uk-button-primary dpad-btn"
|
||||||
|
@mousedown="jog(0, -1, 0)"
|
||||||
|
@mouseup="jogStop()"
|
||||||
|
@mouseOut="jogStop()"
|
||||||
|
>
|
||||||
<span class="material-symbols-outlined sync-icon"> arrow_downward </span>
|
<span class="material-symbols-outlined sync-icon"> arrow_downward </span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
id="focus-out-button"
|
id="focus-out-button"
|
||||||
class="uk-button uk-button-primary dpad-btn"
|
class="uk-button uk-button-primary dpad-btn"
|
||||||
@click="move(0, 0, -1)"
|
@mousedown="jog(0, 0, -1)"
|
||||||
|
@mouseup="jogStop()"
|
||||||
|
@mouseOut="jogStop()"
|
||||||
>
|
>
|
||||||
<span class="material-symbols-outlined sync-icon"> remove </span>
|
<span class="material-symbols-outlined sync-icon"> remove </span>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -28,7 +54,9 @@
|
||||||
<button
|
<button
|
||||||
id="focus-in-button"
|
id="focus-in-button"
|
||||||
class="uk-button uk-button-primary dpad-btn"
|
class="uk-button uk-button-primary dpad-btn"
|
||||||
@click="move(0, 0, 1)"
|
@mousedown="jog(0, 0, 1)"
|
||||||
|
@mouseup="jogStop()"
|
||||||
|
@mouseOut="jogStop()"
|
||||||
>
|
>
|
||||||
<span class="material-symbols-outlined sync-icon"> add </span>
|
<span class="material-symbols-outlined sync-icon"> add </span>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -37,13 +65,32 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { eventBus } from "../../../eventBus.js";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "StageControlButtons",
|
name: "StageControlButtons",
|
||||||
|
data: () => ({
|
||||||
|
jogIntervalId: null,
|
||||||
|
jogDistance: 600,
|
||||||
|
jogTime: 300,
|
||||||
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
move(x, y, z) {
|
jog(x, y, z) {
|
||||||
eventBus.emit("globalMoveStepEvent", { x, y, z, absolute: false });
|
if (this.jogIntervalId) {
|
||||||
|
clearInterval(this.jogIntervalId);
|
||||||
|
}
|
||||||
|
let invokeJog = () =>
|
||||||
|
this.invokeAction("stage", "jog", {
|
||||||
|
x: x * this.jogDistance,
|
||||||
|
y: y * this.jogDistance,
|
||||||
|
z: z * this.jogDistance,
|
||||||
|
});
|
||||||
|
invokeJog();
|
||||||
|
this.jogIntervalId = setInterval(invokeJog, this.jogTime);
|
||||||
|
},
|
||||||
|
jogStop() {
|
||||||
|
if (this.jogIntervalId) {
|
||||||
|
clearInterval(this.jogIntervalId);
|
||||||
|
}
|
||||||
|
this.invokeAction("stage", "jog", { stop: true });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue