diff --git a/TODO.md b/TODO.md index b859b57..b7caa79 100644 --- a/TODO.md +++ b/TODO.md @@ -1 +1 @@ -Implement mechanical stall homing \ No newline at end of file +I want you to implement proper motor homing. I think the original used stall homing, please look it up and reimplement it properly. Make sure map on the website starts in proper place. Please update both web (kinematics.js and stepper-test.js) and mcu (main.cpp) code and make sure we are updated on this topic in gemini.md. I have had some desync issues with agent before so there may be some remnants. \ No newline at end of file diff --git a/index.html b/index.html index bbb7ffa..cf90dda 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,12 @@ + WijiBoard – Control Dashboard - + @@ -12,193 +14,186 @@ -
+
- - + + - - - - -
- - -
- -
+ +
+ + WijiBoard +
+ + +
+ +
+
+ Disconnected +
+ + + +
+ + + +
+ +
+
+ - + + + // Close sidebar on small screens when nav link clicked + document.querySelectorAll('.sidebar-nav-item[data-route]').forEach(link => { + link.addEventListener('click', (e) => { + e.preventDefault(); + const route = link.dataset.route; + Router.navigate('#' + route); + if (window.innerWidth < 900) setSidebarOpen(false); + }); + }); + + // Collapse sidebar by default on small screens + if (window.innerWidth < 900) setSidebarOpen(false); + + // ── Wire BLE events to shared UI ────────────────────────────── + UI.initBLEListeners(); + + // Connect button handler (initial state) + document.getElementById('btn-ble-connect').addEventListener('click', () => { + if (BLE.isConnected()) { + BLE.disconnect(); + } else { + BLE.connect().catch(e => { + if (!e.message?.includes('cancelled') && !e.name?.includes('NotFound')) { + UI.log(`Connect error: ${e.message}`, 'error'); + } + }); + } + }); + + // ── Init router (last step) ──────────────────────────────────── + Router.init('#view', '#home'); + + // ── Check Web Bluetooth availability ────────────────────────── + if (!navigator.bluetooth) { + setTimeout(() => { + UI.log('⚠ Web Bluetooth not available. Use Chrome or Edge on localhost/HTTPS.', 'error'); + }, 600); + } + - + + \ No newline at end of file diff --git a/web/js/ui.js b/web/js/ui.js index d5bc7f3..712758a 100644 --- a/web/js/ui.js +++ b/web/js/ui.js @@ -37,15 +37,15 @@ const UI = (() => { // ── BLE status indicator (top bar) ────────────────────────── function setConnectionStatus(connected, deviceName = null) { const statusEl = document.getElementById('ble-status'); - const labelEl = document.getElementById('ble-label'); - const btn = document.getElementById('btn-ble-connect'); + const labelEl = document.getElementById('ble-label'); + const btn = document.getElementById('btn-ble-connect'); if (statusEl) statusEl.classList.toggle('connected', connected); - if (labelEl) labelEl.textContent = connected + if (labelEl) labelEl.textContent = connected ? (deviceName ?? 'Connected') : 'Disconnected'; if (btn) { - btn.disabled = connected; + btn.disabled = connected; btn.innerHTML = connected ? 'Disconnect' : 'Connect'; @@ -57,10 +57,10 @@ const UI = (() => { btn.onclick = connected ? () => BLE.disconnect() : () => BLE.connect().catch(e => { - if (!e.message?.includes('cancelled')) { - log(`Connect failed: ${e.message}`, 'error'); - } - }); + if (!e.message?.includes('cancelled')) { + log(`Connect failed: ${e.message}`, 'error'); + } + }); } }