diff --git a/src/js/axis-vars.js b/src/js/axis-vars.js index 344a497..abe96c0 100644 --- a/src/js/axis-vars.js +++ b/src/js/axis-vars.js @@ -32,6 +32,10 @@ module.exports = { return this._compute_axis("c"); }, + w: function() { + return this._compute_aux_axis(); + }, + axes: function() { return this._compute_axes(); } @@ -203,6 +207,52 @@ module.exports = { return false; }, + _compute_aux_axis: function() { + // Virtual W axis driven by the auxcnc ESP32. Position, homed + // flag and presence come from the bbctrl AuxAxis driver via + // state.aux_*. No motor mapping, no soft-limit warnings on + // toolpath bounds (auxcnc enforces its own). + const enabled = !!this.state.aux_enabled; + const present = !!this.state.aux_present; + const homed = !!this.state.aux_homed; + const pos = this.state.aux_pos || 0; + + let klass = `${homed ? "homed" : "unhomed"} axis-w`; + let state = present ? "UNHOMED" : "OFFLINE"; + let icon = present ? "question-circle" : "plug"; + let title = present + ? "Click the home button to home W axis." + : "Aux controller not connected on /dev/ttyUSB0."; + if (homed) { + state = "HOMED"; + icon = "check-circle"; + title = "W axis successfully homed."; + } else if (!present) { + klass += " error"; + } + + return { + pos: pos, + abs: pos, + off: 0, + min: 0, max: 0, dim: 0, + pathMin: 0, pathMax: 0, pathDim: 0, + motor: -1, + enabled: enabled, + homingMode: "limit-switch", + homed: homed, + klass: klass, + state: state, + icon: icon, + title: title, + ticon: "check-circle", + tstate: "OK", + toolmsg: "W axis is not constrained by tool path bounds.", + tklass: `${homed ? "homed" : "unhomed"} axis-w`, + isAux: true, + }; + }, + _compute_axes: function() { let homed = false; diff --git a/src/js/control-view.js b/src/js/control-view.js index a22de0b..0fc9e3b 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -765,6 +765,24 @@ module.exports = { api.put(`home/${axis}/clear`); }, + aux_home: function () { + api.put("aux/home").catch(function (err) { + console.error("W home failed:", err); + }); + }, + + aux_set_zero: function () { + api.put("aux/set-zero", { mm: 0 }).catch(function (err) { + console.error("W set-zero failed:", err); + }); + }, + + aux_jog: function (delta_mm) { + api.put("aux/jog", { mm: delta_mm }).catch(function (err) { + console.error("W jog failed:", err); + }); + }, + show_set_position: function (axis) { SvelteComponents.showDialog("SetAxisPosition", { axis }); }, diff --git a/src/pug/templates/control-view.pug b/src/pug/templates/control-view.pug index 06077d3..84470c6 100644 --- a/src/pug/templates/control-view.pug +++ b/src/pug/templates/control-view.pug @@ -191,6 +191,28 @@ script#control-view-template(type="text/x-template") button.pure-button(:disabled="!is_idle", @click=`home('${axis}')`, title=`Home {{'${axis}' | upper}} axis.`, style="height:60px;width:60px") .fa.fa-home + + // Auxiliary W axis (auxcnc ESP32 over /dev/ttyUSB0) + tr.axis(:class="w.klass", v-if="w.enabled", :title="w.title") + th.name w + td.position: unit-value(:value="w.pos", precision=4) + td.absolute: unit-value(:value="w.abs", precision=3) + td.offset — + td.state + .fa(:class="'fa-' + w.icon") + | {{w.state}} + td.tstate(:class="w.tklass", :title="w.toolmsg") + .fa(:class="'fa-' + w.ticon") + | {{w.tstate}} + + th.actions + button.pure-button(title="Set W axis position to 0.", + @click="aux_set_zero()", style="height:60px;width:60px") + .fa.fa-map-marker + + button.pure-button(:disabled="!w.enabled", @click="aux_home()", + title="Home W axis.", style="height:60px;width:60px") + .fa.fa-home tr(style="vertical-align: top;") td