diff --git a/src/js/motor-view.js b/src/js/motor-view.js index cc7fedd..4c9ed6d 100644 --- a/src/js/motor-view.js +++ b/src/js/motor-view.js @@ -87,27 +87,47 @@ module.exports = { return this.stallRPM * this.stepsPerRev * ustep / 60; }, - current_axis_value: function() { + current_axis: function() { return this.state[this.index + 'an']; }, - current_max_velocity_value: function() { + current_max_velocity: function() { return this.state[this.index + 'vm']; - } + }, + + current_max_soft_limit: function() { + return this.state[this.index + 'tm']; + }, + + current_min_soft_limit: function() { + return this.state[this.index + 'tn']; + }, }, watch: { - current_axis_value(new_value) { + current_axis(new_value) { const motor_axes = ["X", "Y", "Z", "A", "B", "C"] if(motor_axes[new_value] != this.motor['axis']){ this.motor['axis'] = motor_axes[new_value]; } }, - current_max_velocity_value(new_value) { + current_max_velocity(new_value) { if(new_value != this.motor['max-velocity']) { this.motor['max-velocity'] = new_value; } + }, + + current_max_soft_limit(new_value) { + if(new_value != this.motor['max-soft-limit']) { + this.motor['max-soft-limit'] = new_value; + } + }, + + current_min_soft_limit(new_value) { + if(new_value != this.motor['min-soft-limit']) { + this.motor['min-soft-limit'] = new_value; + } } }, diff --git a/src/py/bbctrl/Web.py b/src/py/bbctrl/Web.py index 7b8e762..e0a19c2 100644 --- a/src/py/bbctrl/Web.py +++ b/src/py/bbctrl/Web.py @@ -639,6 +639,19 @@ class RotaryHandler(bbctrl.APIHandler): motor_2["axis"] = "Y" if is_axis_A else "A" motor_1["max-velocity"] *= 2 if is_axis_A else 0.5 + if is_axis_A: + if 'min-soft-limit-backup' in motor_2 and 'max-soft-limit-backup' in motor_2: + motor_2['min-soft-limit'] = motor_2['min-soft-limit-backup'] + motor_2['max-soft-limit'] = motor_2['max-soft-limit-backup'] + else: + raise ValueError("Backup soft limits are missing for motor_2.") + else: + motor_2['min-soft-limit-backup'] = motor_2['min-soft-limit'] + motor_2['max-soft-limit-backup'] = motor_2['max-soft-limit'] + + motor_2['min-soft-limit'] = -720 + motor_2['max-soft-limit'] = 720 + config.save(config_data) except FileNotFoundError: diff --git a/src/resources/config-template.json b/src/resources/config-template.json index bf1ea86..446bcfd 100644 --- a/src/resources/config-template.json +++ b/src/resources/config-template.json @@ -142,6 +142,22 @@ "default": 0, "code": "tm" }, + "min-soft-limit-backup": { + "type": "float", + "unit": "mm", + "iunit": "in", + "scale": 25.4, + "default": 0, + "code": "tnb" + }, + "max-soft-limit-backup": { + "type": "float", + "unit": "mm", + "iunit": "in", + "scale": 25.4, + "default": 0, + "code": "tmb" + }, "min-switch": { "type": "enum", "values": ["disabled", "normally-open", "normally-closed"],