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). // Home every enabled axis (legacy Onefinity "Home All"). Sequence:
// The XYZ home is fired first via the standard /api/home endpoint, // 1. Z, X, Y (and A/B/C if enabled) via /api/home on the AVR
// then the W axis is homed if it is enabled. The two cycles run // 2. W axis via /api/aux/home on the ESP
// in parallel — W is on the auxcnc ESP and doesn't share motors // The two cycles are dispatched serially: we wait for the main
// with the AVR — so the user sees one click homing everything. // homing cycle to drop back to idle before kicking off W so the
home_all: function () { // gantry never moves while the W spindle is also homing.
home_all: async function () {
this.ask_home = false; this.ask_home = false;
api.put("home"); try {
if (this.w && this.w.enabled) { await api.put("home");
api.put("aux/home").catch(function (err) { } catch (e) {
console.error("W home failed:", err); 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) { aux_jog: function (delta_mm) {