Skip to content

Commit

Permalink
Add disconnect button, fix memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevie-Ray committed Oct 25, 2024
1 parent b5f929f commit c131f37
Show file tree
Hide file tree
Showing 14 changed files with 275 additions and 221 deletions.
2 changes: 1 addition & 1 deletion examples/chart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"devDependencies": {
"@types/w3c-web-serial": "^1.0.7",
"typescript": "^5.6.3",
"vite": "^5.4.9"
"vite": "^5.4.10"
},
"workspaces": [
"examples"
Expand Down
13 changes: 13 additions & 0 deletions examples/chart/src/devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ export function setupDevice(massesElement: HTMLDivElement, outputElement: HTMLDi
deviceName.innerHTML = `${device.constructor.name}`
deviceControlDiv.appendChild(deviceName)

// Create the "Disconnect" button
const disconnectButton = document.createElement("button")
disconnectButton.innerHTML = `
<div>
<i class="fa-solid fa-link-slash"></i>
</div>
<div>Disconnect</div>
`
disconnectButton.addEventListener("click", async () => {
await device.disconnect()
})
deviceControlDiv.appendChild(disconnectButton)

// Create the "Stop" button
const streamButton = document.createElement("button")
streamButton.innerHTML = `
Expand Down
2 changes: 2 additions & 0 deletions examples/chart/src/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
faDownload,
faGamepad,
faGlobe,
faLinkSlash,
faScaleBalanced,
faStop,
faPlay,
Expand All @@ -32,6 +33,7 @@ export function setupFontAwesome() {
faGamepad,
faGithub,
faGlobe,
faLinkSlash,
faScaleBalanced,
faStop,
faPlay,
Expand Down
10 changes: 7 additions & 3 deletions examples/chart/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ h2 {

.input {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-columns: repeat(4, 1fr);
align-items: center;
justify-content: center;
gap: 0.5rem;
width: 100%;
}
.input > button {
grid-column: span 1;
grid-column: span 2;
}

.input:last-of-type {
Expand All @@ -135,7 +135,7 @@ h2 {
}

.input > strong {
grid-column: span 3;
grid-column: span 4;
padding: 0.5rem;
}

Expand Down Expand Up @@ -257,6 +257,10 @@ footer a:hover {
flex: 0 0 auto;
}

.input > button {
grid-column: span 1;
}

#masses {
min-height: 40px;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/flappy-bird/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"devDependencies": {
"typescript": "^5.6.3",
"vite": "^5.4.9"
"vite": "^5.4.10"
},
"workspaces": [
"examples"
Expand Down
2 changes: 1 addition & 1 deletion examples/kilter-board/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"devDependencies": {
"typescript": "^5.6.3",
"vite": "^5.4.9"
"vite": "^5.4.10"
},
"workspaces": [
"examples"
Expand Down
2 changes: 1 addition & 1 deletion examples/pong/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"devDependencies": {
"typescript": "^5.6.3",
"vite": "^5.4.9"
"vite": "^5.4.10"
},
"workspaces": [
"examples"
Expand Down
Loading

0 comments on commit c131f37

Please sign in to comment.