From eb389cb1dd055a389b5d9ee248d7bc3f3abc97ad Mon Sep 17 00:00:00 2001 From: sanjayk03-dev Date: Thu, 5 Dec 2024 15:42:44 +0530 Subject: [PATCH] updating control view using state --- src/js/app.js | 13 ++----------- src/js/axis-vars.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/js/app.js b/src/js/app.js index 36fc603..5700078 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -329,19 +329,10 @@ module.exports = new Vue({ }, toggle_rotary: async function() { - let motor = this.config.motors[2]; - if(motor['axis'] == 'A'){ - motor['axis'] = 'Y'; - this.config.motors[1]['max-velocity'] *= 2; - } else { - motor['axis'] = 'A'; - this.config.motors[1]['max-velocity'] /= 2; - } try { - await api.put("rotary", {status : motor['axis'] == 'A'}); - await api.put("config/save", this.config); + await api.put("rotary"); } catch (error) { - console.error("Restore failed:", error); + console.error(error); alert("Error occured"); } }, diff --git a/src/js/axis-vars.js b/src/js/axis-vars.js index 64bc1da..344a497 100644 --- a/src/js/axis-vars.js +++ b/src/js/axis-vars.js @@ -53,7 +53,7 @@ module.exports = { const off = this.state[`offset_${axis}`]; const motor_id = this._get_motor_id(axis); const motor = motor_id == -1 ? {} : this.config.motors[motor_id]; - const enabled = typeof motor.enabled != "undefined" && motor.enabled; + const enabled = this._check_is_enabled(axis); const homingMode = motor["homing-mode"]; const homed = this.state[`${motor_id}homed`]; const min = this.state[`${motor_id}tn`]; @@ -193,6 +193,16 @@ module.exports = { return -1; }, + _check_is_enabled: function(axis){ + const axes = { x: 0, y: 1, z: 2, a: 3 }; + for(let i = 0; i < this.config.motors.length; i++){ + if(this.state[`${i}an`] == axes[axis]){ + return true; + } + } + return false; + }, + _compute_axes: function() { let homed = false;