Skip to content

Commit

Permalink
verify examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevie-Ray committed Oct 16, 2024
1 parent 839fea7 commit 28b3128
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ motherboard.notify((data) => {

// Optional: Check if the device is active
motherboard.active(
(isActive) => { console.log(isActive) },
(isActive) => {
console.log(isActive)
},
// Optionally using a weight threshold and duration
{ threshold: 2.5, duration: 1000 },
)

document.querySelector("#motherboard").addEventListener("click", () => {
document.querySelector("#motherboard").addEventListener("click", async () => {
// Connect to device
await motherboard.connect(
async () => {
Expand All @@ -80,8 +82,8 @@ document.querySelector("#motherboard").addEventListener("click", () => {
// await motherboard.led("red")
// await motherboard.led()

// Start weight streaming (for a minute) remove parameter for a continues stream
await motherboard.stream(60000)
// Start weight streaming (for 30s) remove parameter for a continues stream
await motherboard.stream(30000)

// Manualy tare the device when the stream is running
// await motherboard.tare(5000)
Expand All @@ -91,14 +93,15 @@ document.querySelector("#motherboard").addEventListener("click", () => {

// Download data as CSV, JSON, or XML (default: CSV) format => timestamp, frame, battery, samples, masses
// motherboard.download('json')

// Optionally disconnect from device after we are done
motherboard.disconnect(Motherboard)
},
(error) => {
// Optinal custom error handeling
console.error(error.message)
},
)
// Disconnect from device after we are done
motherboard.disconnect(Motherboard)
})
```

Expand Down
15 changes: 9 additions & 6 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ motherboard.notify((data) => {

// Optional: Check if the device is active
motherboard.active(
(isActive) => { console.log(isActive) },
(isActive) => {
console.log(isActive)
},
// Optionally using a weight threshold and duration
{ threshold: 2.5, duration: 1000 },
)

document.querySelector("#motherboard").addEventListener("click", () => {
document.querySelector("#motherboard").addEventListener("click", async () => {
// Connect to device
await motherboard.connect(
async () => {
Expand All @@ -80,8 +82,8 @@ document.querySelector("#motherboard").addEventListener("click", () => {
// await motherboard.led("red")
// await motherboard.led()

// Start weight streaming (for a minute) remove parameter for a continues stream
await motherboard.stream(60000)
// Start weight streaming (for 30s) remove parameter for a continues stream
await motherboard.stream(30000)

// Manualy tare the device when the stream is running
// await motherboard.tare(5000)
Expand All @@ -91,14 +93,15 @@ document.querySelector("#motherboard").addEventListener("click", () => {

// Download data as CSV, JSON, or XML (default: CSV) format => timestamp, frame, battery, samples, masses
// motherboard.download('json')

// Optionally disconnect from device after we are done
motherboard.disconnect(Motherboard)
},
(error) => {
// Optinal custom error handeling
console.error(error.message)
},
)
// Disconnect from device after we are done
motherboard.disconnect(Motherboard)
})
```

Expand Down
15 changes: 9 additions & 6 deletions packages/docs/src/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ motherboard.notify((data) => {

// Optional: Check if the device is active
motherboard.active(
(isActive) => { console.log(isActive) },
(isActive) => {
console.log(isActive)
},
// Optionally using a weight threshold and duration
{ threshold: 2.5, duration: 1000 },
)

document.querySelector("#motherboard").addEventListener("click", () => {
document.querySelector("#motherboard").addEventListener("click", async () => {
// Connect to device
await motherboard.connect(
async () => {
Expand All @@ -80,8 +82,8 @@ document.querySelector("#motherboard").addEventListener("click", () => {
// await motherboard.led("red")
// await motherboard.led()

// Start weight streaming (for a minute) remove parameter for a continues stream
await motherboard.stream(60000)
// Start weight streaming (for 30s) remove parameter for a continues stream
await motherboard.stream(30000)

// Manualy tare the device when the stream is running
// await motherboard.tare(5000)
Expand All @@ -91,13 +93,14 @@ document.querySelector("#motherboard").addEventListener("click", () => {

// Download data as CSV, JSON, or XML (default: CSV) format => timestamp, frame, battery, samples, masses
// motherboard.download('json')

// Optionally disconnect from device after we are done
motherboard.disconnect(Motherboard)
},
(error) => {
// Optinal custom error handeling
console.error(error.message)
},
)
// Disconnect from device after we are done
motherboard.disconnect(Motherboard)
})
```

0 comments on commit 28b3128

Please sign in to comment.