diff --git a/index.html b/index.html index 4e600c9..10fc514 100644 --- a/index.html +++ b/index.html @@ -51,15 +51,15 @@
-
Override axes
with WASD
+
Override axes
with WASD
-
+
-
Help/Info!
+
Help/Info!
-
+
diff --git a/index.js b/index.js index 5761b5a..f314d75 100644 --- a/index.js +++ b/index.js @@ -11,9 +11,6 @@ let buttonCallback = null let mobileElements = document.getElementsByClassName("mobile-only"); let desktopElements = document.getElementsByClassName("desktop-only"); - -let helpRow = document.getElementsByClassName("help-row"); - let infoElement = document.getElementById("info-container"); let hackSpacerElement = document.getElementById("hack-spacer"); @@ -32,8 +29,6 @@ if (localStorage.getItem(toggleMobile.id) == null) { updateMobileSlider(toggleMobile, false); } - if(isMobile) for (let element of helpRow) element.style.display = "none"; - document.addEventListener('DOMContentLoaded', function () { updateMobileSlider(toggleMobile, toggleState=false); updateSlider(toggleKeyboardWASD, toggleState=false); @@ -107,7 +102,7 @@ function renderLoop() { //bytes 0: packet version //bytes 1-4: axes //bytes 5-6: button states - //bytes 7-17: pressed keyboard keys + //bytes 7-19: pressed keyboard keys let rawPacket = new Uint8Array(1 + 4 + 2 + 11) rawPacket[0] = 0x01; //packet version @@ -147,7 +142,7 @@ function renderLoop() { if (!document.hasFocus()) { rawPacket.fill(0, 0, 20); } - console.log(rawPacket) + //console.log(rawPacket) bleAgent.attemptSend(rawPacket); } @@ -210,9 +205,9 @@ function createBleAgent() { await device.addEventListener('gattserverdisconnected', robotDisconnect); + displayBleStatus('Connected', '#4dae50'); //green isConnectedBLE = true; buttonBLE.innerHTML = '❌'; - batteryWatchdogReset(); } catch (error) { if (error.name === 'NotFoundError') { @@ -228,7 +223,6 @@ function createBleAgent() { } function handleBatteryCharacteristic(event){ - batteryWatchdogReset(); let value = event.target.value.getUint8(0); let voltage = (value/255.0) * 12 batteryDisplay.innerHTML = "🔋:" + voltage.toFixed(2) + "V"; @@ -237,7 +231,6 @@ function createBleAgent() { async function disconnectBLE() { displayBleStatus('Disconnecting'); try { - batteryWatchdogStop(); await device.removeEventListener('gattserverdisconnected', robotDisconnect); await device.gatt.disconnect(); @@ -253,7 +246,6 @@ function createBleAgent() { } function robotDisconnect(event) { - batteryWatchdogStop(); displayBleStatus('Not Connected', 'grey'); isConnectedBLE = false; connectBLE(); @@ -269,30 +261,11 @@ function createBleAgent() { } } - // Function to create and manage the watchdog timer - let timer; - const timeout = 1000; // 400ms - // Function to start or reset the watchdog timer - function batteryWatchdogReset() { - displayBleStatus('Connected', '#4dae50'); //green - if (timer) {clearTimeout(timer);} - timer = setTimeout(() => { - displayBleStatus('timeout?', 'black'); - }, timeout); - } - // Function to stop the watchdog timer - function batteryWatchdogStop() { - batteryWatchdogReset() - if (timer) {clearTimeout(timer);timer = null;} - } - return { attemptSend: sendPacketBLE }; } - - // -------------------------------------------- mobile --------------------------------------- // function createMobileAxisAgent() { diff --git a/styles.css b/styles.css index 45cc67c..f74d24b 100644 --- a/styles.css +++ b/styles.css @@ -135,13 +135,13 @@ body { grid-column: 1; cursor: pointer; border: none; - color: #e6e5e5; + color: #fff; text-align: center; transition: background-color 0.3s, transform 0.1s, box-shadow 0.3s; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); } #ble-button:hover { - background-color: rgb(121, 121, 121); + background-color: rgb(169, 169, 169); } #ble-button:active { background-color: rgb(159, 159, 159); @@ -155,6 +155,7 @@ body { font-size: 2vw; grid-row: 1; grid-column: 2; + cursor: pointer; } #ble-status { @@ -163,6 +164,7 @@ body { grid-row: 2; grid-column: 1; grid-column: span 2; + cursor: pointer; }