moving the toggle_rotary to backend

This commit is contained in:
sanjayk03-dev
2024-12-04 14:24:29 +05:30
parent 9cec47ef3f
commit 1ad8bb6cbc
3 changed files with 17 additions and 3 deletions

View File

@@ -238,12 +238,12 @@ module.exports = new Vue({
},
is_rotary_active: function() {
if(this.config.motors[2]['axis'] == 'Y') return false;
if(this.state["2an"] == 1) return false;
return true;
},
enable_rotary: function() {
if(this.config.motors[2]['axis'] == 'Y' || this.config.motors[2]['axis'] == 'A') return true;
if(this.state["2an"] == 1 || this.state["2an"] == 3) return true;
return false;
}
},
@@ -338,6 +338,7 @@ module.exports = new Vue({
this.config.motors[1]['max-velocity'] /= 2;
}
try {
await api.put("rotary", {status : motor['axis'] == 'A'});
await api.put("config/save", this.config);
} catch (error) {
console.error("Restore failed:", error);

View File

@@ -98,7 +98,7 @@ script#control-view-template(type="text/x-template")
button(:style="getJogIncrStyle('large')", @click="jog_incr = 'large'")
span {{jog_incr_amounts[display_units].large}}#[span.jog-units {{metric ? 'mm' : 'in'}}]
tr(v-if="config.motors[2]['axis'] == 'A'")
tr(v-if="state['2an'] == 3")
td(style="height:100px", align="center", colspan="1")
button(@click="showProbeDialog('a')")
| Probe

View File

@@ -603,6 +603,18 @@ class TimeHandler(bbctrl.APIHandler):
except Exception as e:
self.get_log('TimeHandler').info('Error: {}'.format(e))
class RotaryHandler(bbctrl.APIHandler):
def put_ok(self):
status = self.json.get('status', None)
state = self.get_ctrl().state
try:
self.get_log('RotaryHandler').info('Status: {}'.format(status))
state.set("rotary", status)
except Exception as e:
self.get_log('RotaryHandler').info('Error: {}'.format(e))
class RemoteDiagnosticsHandler(bbctrl.APIHandler):
@@ -776,6 +788,7 @@ class Web(tornado.web.Application):
(r'/api/video', bbctrl.VideoHandler),
(r'/api/screen-rotation', ScreenRotationHandler),
(r'/api/time', TimeHandler),
(r'/api/rotary', RotaryHandler),
(r'/api/remote-diagnostics', RemoteDiagnosticsHandler),
(r'/(.*)', StaticFileHandler,
{'path': bbctrl.get_resource('http/'),