delete homing. Have to redo

This commit is contained in:
PROFERIS - Mi³osz Stocki
2026-07-06 15:40:15 +02:00
parent ee8a2d97ed
commit f652b741ae
5 changed files with 119 additions and 208 deletions
+2 -85
View File
@@ -47,7 +47,6 @@ const PX_D2 = IK.ARM.d2 * SV.SCALE;
// ── Section state ─────────────────────────────────────────────────
let steps1 = 0;
let steps2 = 0;
let isHoming = false; // blocks all controls during homing sequence
let eventCleanup = [];
// ── SVG element refs ──────────────────────────────────────────────
@@ -226,58 +225,9 @@ async function zeroMotor(motor) {
}
// ─────────────────────────────────────────────────────────────────
// Homing
// Manual jog
// ─────────────────────────────────────────────────────────────────
/** Block / unblock all interactive controls while homing is running. */
function setHomingActive(active) {
isHoming = active;
const root = document.querySelector('.section-page');
if (!root) return;
if (active) {
root.classList.add('homing-active');
} else {
root.classList.remove('homing-active');
}
// Update the button label
const btn = document.getElementById('btn-find-home');
const spin = document.getElementById('home-spinner');
const lbl = document.getElementById('home-label');
if (!btn) return;
btn.disabled = active;
if (spin) spin.style.display = active ? '' : 'none';
if (lbl) lbl.textContent = active ? 'Homing…' : 'Find Home';
}
/** Called when the firmware sends HOMED or when simulating. */
function onHomingComplete() {
steps1 = 0;
steps2 = 0;
setHomingActive(false);
renderArmFromSteps();
UI.log('✓ Homing complete — step counters reset to zero.', 'success');
}
async function startHoming() {
if (isHoming) return;
setHomingActive(true);
UI.log('⧐ Homing started — arm moving to mechanical stops…', 'warn');
if (BLE.isConnected()) {
try {
await BLE.write('HOME');
// onHomingComplete() will be called when HOMED notify arrives
} catch (e) {
UI.log(`BLE error during home: ${e.message}`, 'error');
setHomingActive(false);
}
} else {
// Simulation: instant reset
UI.log('[sim] HOME command sent — simulating instant home', 'info');
setTimeout(onHomingComplete, 600);
}
}
// ─────────────────────────────────────────────────────────────────
// SVG workspace zones (pre-computed)
// ─────────────────────────────────────────────────────────────────
@@ -401,19 +351,7 @@ function buildHTML() {
.quick-steps button { flex:1; min-width:30px; padding:4px 2px; font-size:0.68rem;
border-radius:var(--radius-xs); }
/* Disable all interactive elements during homing */
.homing-active button:not(#btn-find-home),
.homing-active input,
.homing-active #scara-svg {
pointer-events: none;
opacity: 0.4;
}
/* Spinner animation for homing button */
@keyframes spin { to { transform: rotate(360deg); } }
.home-spin { display:inline-block; width:13px; height:13px;
border:2px solid currentColor; border-top-color:transparent;
border-radius:50%; animation:spin 0.7s linear infinite;
vertical-align:middle; margin-right:5px; }
</style>
<div class="section-page fade-in">
@@ -614,19 +552,6 @@ function buildHTML() {
<span style="font-size:0.72rem;color:var(--text-muted)">Incremental step control — bypasses IK</span>
</div>
<!-- Find Home -->
<div style="padding:4px 0 14px;border-bottom:1px solid var(--border);margin-bottom:12px">
<div style="font-size:0.70rem;color:var(--text-muted);margin-bottom:8px;line-height:1.5">
⚠️ Drives each arm slowly into its mechanical stop then backs off to
operating home. Takes ~1520s. All controls are locked during homing.
</div>
<button class="btn btn-full" id="btn-find-home"
style="background:rgba(255,152,0,0.12);border:1px solid rgba(255,152,0,0.35);
color:var(--accent-amber);font-weight:700;font-size:0.85rem;padding:10px">
<span class="home-spin" id="home-spinner" style="display:none"></span>
<span id="home-label">⌂ Find Home</span>
</button>
</div>
<div class="jog-compact">
<!-- Motor 1 -->
@@ -818,11 +743,6 @@ const StepperTestSection = {
// ── BLE NOTIFY position feedback ──────────────────────────────
function onBLEStatus(e) {
const msg = e.detail;
if (msg === 'HOMED') {
// Firmware completed homing — sync browser counters
onHomingComplete();
return;
}
if (msg.startsWith('P:')) {
const [s1, s2] = msg.slice(2).split(',').map(Number);
steps1 = s1; steps2 = s2;
@@ -831,9 +751,6 @@ const StepperTestSection = {
}
document.addEventListener('ble:status', onBLEStatus);
// ── Find Home button ──────────────────────────────────────
document.getElementById('btn-find-home').addEventListener('click', startHoming);
eventCleanup = [
() => BLE.off('connected', updateBadge),
() => BLE.off('disconnected', updateBadge),