diff --git a/src/components/panels/MiscellaneousPanel.vue b/src/components/panels/MiscellaneousPanel.vue
index 06874e36..f4757f62 100644
--- a/src/components/panels/MiscellaneousPanel.vue
+++ b/src/components/panels/MiscellaneousPanel.vue
@@ -25,7 +25,7 @@
-
+
@@ -67,7 +67,7 @@
]),
},
mounted() {
- console.log(this.printer_state);
+ console.log(this.extrude_factor, this.speed_factor, this.printer_state);
}
}
diff --git a/src/inputs/ToolSlider.vue b/src/inputs/ToolSlider.vue
index a3bec1bd..957aff05 100644
--- a/src/inputs/ToolSlider.vue
+++ b/src/inputs/ToolSlider.vue
@@ -21,7 +21,7 @@
-
+
+
+
+ mdi-pencil
+
+
+
+ {{ label }}
+
+
+
+ {{ unit }}
+
+
+
+
+ Cancel
+
+ Ok
+
+
+
{{ value }} {{ unit }}
@@ -52,6 +84,57 @@
mdi-plus
+
+
+
+
+ mdi-menu-right
+
+
+
+
+ mdi-menu-left
+
+
+
+
+ mdi-menu-swap
+
+
+
+
+ mdi-minus
+
+
+
+ mdi-plus
+
+
@@ -104,6 +187,11 @@
required: false,
default: false
},
+ newDynamic: {
+ type: Boolean,
+ required: false,
+ default: false
+ },
defaultValue: {
type: Number,
required: false,
@@ -119,6 +207,11 @@
required: false,
default: 1
},
+ editable: {
+ type: Boolean,
+ required: false,
+ default: false
+ }
},
data() {
return {
@@ -128,7 +221,11 @@
processedMin: this.min,
processedMax: this.max,
dynamicStep: Math.floor((this.max - this.min) / 2),
- processingTimer: null
+ dynamicTimer: null,
+ dynamicValue: 30,
+ editing: false,
+ processingTimer: null,
+ clearInterval: (timer) => clearInterval(timer)
}
},
created() {
@@ -141,20 +238,74 @@
},
watch: {
- target: function(newVal) {
- this.value = newVal * this.multi;
+ target: {
+ immediate: true,
+ handler(newVal) {
+ this.value = newVal * this.multi;
+ if (!this.dynamicRange) {
+ return;
+ }
+ if (this.processingTimer) {
+ clearTimeout(this.processingTimer);
+ this.processingTimer = null;
+ }
+ if (this.value === this.processedMax || this.value === this.processedMin) {
+ this.processingTimer = setTimeout(() => {
+ this.processedMin = Math.max(0, this.value - this.dynamicStep);
+ this.processedMax = Math.min(1000, this.value + this.dynamicStep);
+ }, 1000);
+ }
+ }
},
},
methods: {
+ editSpeed() {
+ if (this.$refs.editInput) {
+ try {
+ const newValue = parseInt(this.$refs.editInput.internalValue);
+ if (!isNaN(newValue)) {
+ this.value = this.clamp(newValue, 1, 1000);
+ this.sendCmd(true);
+ }
+ } catch(e) {
+ console.error(e);
+ }
+ }
+ this.editing = false;
+ },
+ changeDynamicRange() {
+ if (this.dynamicTimer) {
+ clearInterval(this.dynamicTimer);
+ this.dynamicTimer = null;
+ }
+ const normalised = this.dynamicValue - 30;
+ const step = Math.abs(normalised) / 10;
+ console.log(normalised, step);
+ this.dynamicTimer = setInterval(() => {
+ let addVal = 0;
+ if (normalised < 0) {
+ addVal = -1;
+ } else if(normalised > 0) {
+ addVal = 1;
+ }
+ this.value = this.value + addVal;
+ }, 500 * (1 / (step * 10)));
+ },
processNewRange() {
if (!this.dynamicRange || !this.sliding) {
return;
}
if (this.processingTimer) {
- clearInterval(this.processingTimer);
+ clearTimeout(this.processingTimer);
this.processingTimer = null;
}
if (this.value === this.processedMax || this.value === this.processedMin) {
+ this.processingTimer = setTimeout(() => {
+ this.processedMin = Math.max(0, this.value - this.dynamicStep);
+ this.processedMax = Math.min(1000, this.value + this.dynamicStep);
+ }, 1000);
+ }
+ /*if (this.value === this.processedMax || this.value === this.processedMin) {
this.processingTimer = setInterval(() => {
let was = '';
if (this.value === this.processedMax) {
@@ -166,27 +317,26 @@
this.processedMax = Math.min(1000, this.value + this.dynamicStep);
this.value = was === 'max' ? this.processedMax : this.processedMin;
}, 500);
- }
+ }*/
},
- sendCmd() {
- if (this.sliding) {
+ sendCmd(btnPress = false) {
+ if (this.sliding || btnPress) {
let gcode = this.command + ' ' + this.attributeName + (Math.max(1, this.value) * this.attributeScale).toFixed(0)
this.$store.commit('server/addEvent', {message: gcode, type: 'command'})
this.$socket.sendObj('printer.gcode.script', {script: gcode})
this.sliding = false;
- if (this.processingTimer) {
- clearInterval(this.processingTimer);
- this.processingTimer = null;
- }
}
},
+ clamp(value, min, max) {
+ return Math.max(min, Math.min(max, value ?? 0));
+ },
decrement() {
- this.value = this.value > this.min ? (this.value - this.step).toFixed(0) : this.min
- this.sendCmd();
+ this.value = this.value > this.min ? this.value - this.step : this.min
+ this.sendCmd(true);
},
increment() {
- this.value = this.value < this.max ? (this.value + this.step).toFixed(0) : this.max
- this.sendCmd();
+ this.value = this.value < this.max ? this.value + this.step : this.max
+ this.sendCmd(true);
}
}
}