control: home W last in 'Home All'

Previously XYZ and W homing dispatched in parallel. Wait for the
main AVR homing cycle to return to idle before kicking off the W
auxcnc home so they never run simultaneously.
This commit is contained in:
muehe
2026-05-01 16:16:51 +02:00
parent b0f38619ba
commit cfc14643d2

View File

@@ -255,19 +255,32 @@ module.exports = {
});
},
// Home every enabled axis at once (legacy Onefinity behavior).
// The XYZ home is fired first via the standard /api/home endpoint,
// then the W axis is homed if it is enabled. The two cycles run
// in parallel — W is on the auxcnc ESP and doesn't share motors
// with the AVR — so the user sees one click homing everything.
home_all: function () {
// Home every enabled axis (legacy Onefinity "Home All"). Sequence:
// 1. Z, X, Y (and A/B/C if enabled) via /api/home on the AVR
// 2. W axis via /api/aux/home on the ESP
// The two cycles are dispatched serially: we wait for the main
// homing cycle to drop back to idle before kicking off W so the
// gantry never moves while the W spindle is also homing.
home_all: async function () {
this.ask_home = false;
api.put("home");
if (this.w && this.w.enabled) {
api.put("aux/home").catch(function (err) {
console.error("W home failed:", err);
});
try {
await api.put("home");
} catch (e) {
console.error("Home all (XYZ) failed:", e);
return;
}
if (!this.w || !this.w.enabled) return;
// Poll state.cycle until the main homing cycle finishes. The
// homing cycle leaves state.cycle as 'homing' until done, then
// returns to 'idle'.
const start = Date.now();
while (Date.now() - start < 120000) {
if (this.state && this.state.cycle == "idle") break;
await new Promise(r => setTimeout(r, 200));
}
api.put("aux/home").catch(function (err) {
console.error("W home failed:", err);
});
},
aux_jog: function (delta_mm) {