Skip to content

Commit

Permalink
improve example
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevie-Ray committed Oct 15, 2024
1 parent 49c2c44 commit 8043c9d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 31 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $ npm install @hangtime/grip-connect

## Example usage (with a Motherboard)

Simply importing the utilities you need from `@hangtime/grip-connect`.
Simply importing the device you need from `@hangtime/grip-connect`.

```html
<button id="motherboard" type="button">Connect Motherboard</button>
Expand All @@ -52,20 +52,21 @@ Simply importing the utilities you need from `@hangtime/grip-connect`.
```js
import { Motherboard, active } from "@hangtime/grip-connect"

// Initiate device
const motherboard = new Motherboard()

// Add a custom notify handler
motherboard.notify((data) => {
// { massTotal: "0", massMax: "0", massAverage: "0", massLeft: "0", massCenter: "0", massRight: "0" }
console.log(data)
})

const motherboardButton = document.querySelector("#motherboard")

motherboardButton.addEventListener("click", () => {
// setup device
const motherboard = new Motherboard()
// connect to device
motherboard.connect(
await motherboard.connect(
async () => {
// Listen for stream notifications
motherboard.notify((data) => {
// { massTotal: "0", massMax: "0", massAverage: "0", massLeft: "0", massCenter: "0", massRight: "0" }
console.log(data)
})

// Reactive check if device is active
active(
(isActive) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/kilter-board/src/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const device = new KilterBoard()

export function setupDevice(element: HTMLButtonElement) {
element.addEventListener("click", async () => {
device.connect(async () => {
await device.connect(async () => {
// Map activeHolds array to objects with role_id and position properties
const placement = activeHolds.map((activeHold) => {
// Return the row from the extraced data with a matching placement ID
Expand Down
21 changes: 11 additions & 10 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $ npm install @hangtime/grip-connect

## Example usage (with a Motherboard)

Simply importing the utilities you need from `@hangtime/grip-connect`.
Simply importing the device you need from `@hangtime/grip-connect`.

```html
<button id="motherboard" type="button">Connect Motherboard</button>
Expand All @@ -52,20 +52,21 @@ Simply importing the utilities you need from `@hangtime/grip-connect`.
```js
import { Motherboard, active } from "@hangtime/grip-connect"

// Initiate device
const motherboard = new Motherboard()

// Add a custom notify handler
motherboard.notify((data) => {
// { massTotal: "0", massMax: "0", massAverage: "0", massLeft: "0", massCenter: "0", massRight: "0" }
console.log(data)
})

const motherboardButton = document.querySelector("#motherboard")

motherboardButton.addEventListener("click", () => {
// setup device
const motherboard = new Motherboard()
// connect to device
motherboard.connect(
await motherboard.connect(
async () => {
// Listen for stream notifications
motherboard.notify((data) => {
// { massTotal: "0", massMax: "0", massAverage: "0", massLeft: "0", massCenter: "0", massRight: "0" }
console.log(data)
})

// Reactive check if device is active
active(
(isActive) => {
Expand Down
21 changes: 11 additions & 10 deletions packages/docs/src/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $ bun add @hangtime/grip-connect

## Example usage (Motherboard)

Simply importing the utilities you need from `@hangtime/grip-connect`.
Simply importing the device you need from `@hangtime/grip-connect`.

```html
<button id="motherboard" type="button">Connect Motherboard</button>
Expand All @@ -52,20 +52,21 @@ Simply importing the utilities you need from `@hangtime/grip-connect`.
```js
import { Motherboard, active } from "@hangtime/grip-connect"

// Initiate device
const motherboard = new Motherboard()

// Add a custom notify handler
motherboard.notify((data) => {
// { massTotal: "0", massMax: "0", massAverage: "0", massLeft: "0", massCenter: "0", massRight: "0" }
console.log(data)
})

const motherboardButton = document.querySelector("#motherboard")

motherboardButton.addEventListener("click", () => {
// setup device
const motherboard = new Motherboard()
// connect to device
motherboard.connect(
await motherboard.connect(
async () => {
// Listen for stream notifications
motherboard.notify((data) => {
// { massTotal: "0", massMax: "0", massAverage: "0", massLeft: "0", massCenter: "0", massRight: "0" }
console.log(data)
})

// Reactive check if device is active
active(
(isActive) => {
Expand Down

0 comments on commit 8043c9d

Please sign in to comment.